Skip to content

Instantly share code, notes, and snippets.

@kchien
Last active March 30, 2022 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kchien/d06240314a24885cdec2558ea23e7e6d to your computer and use it in GitHub Desktop.
Save kchien/d06240314a24885cdec2558ea23e7e6d to your computer and use it in GitHub Desktop.
Docker Swarm Notes, taken as I'm reading https://docs.docker.com/engine/swarm/key-concepts/

What is a swarm?

Consists of:

  • multiple Docker hosts running in swarm mode
  • act as managers and workers

A given host can be a:

  • manager
  • worker
  • or perform both roles

Managers: manage membership and delegation

Workers: run Swarm services

Nodes

Description

A node is an instance of the Docker engine participating in the swarm

  • Think of this as a Docker node.
  • You may run one+ nodes on a single physical computer or cloud server, BUT
  • ... production swarm deployments typically include Docker nodes distributed across MULTIPLE physical & cloud machines

Deployment

  • Submit a service definition to a manager node
  • Tasks: Manager node dispatches uints of work called tasks to worker nodes

Functions of manager nodes

  • Perform orchestration and cluster management functions required to maintain desired state of the swarm
  • Elect a single leader to conduct orchestration tasks

Worker nodes

  • receive and execute tasks dispatched from manager nodes

    • an agent runs on each worker node and reports on tasks assigned to it
  • worker node notifies manager node of current state of its assigned tasks
  • by default, manager nodes also run servcies as worker nodes; but you can configure them to run manager tasks exclusively

Services and tasks

Services

A service: defintion of tasks to execute on the manager or worker nodes

  • CENTRAL STRUCTURE of swarm system
  • primary root of user interaction wih the swarm
  • replicated services model: swarm manager distributes specific number of replica tasks among nodes based up the scale you set in the desired state.
  • global services: the swarm runs one task for the service on every available node in the cluster.

Tasks

  • A task carries a Docker container and the commands to run inside the container.

  • atomic scheduling unit of swarm
  • who: manager nodes assign tasks to worker nodes, according to number of replicas set in the service scale
  • caution! once task is assigned to a node, it can't move to another node; it must run on assigned node or fail.

Load balancing

  • ingress load balancing
  • internal load balancing

Creating a Swarm

Reference

For now, I'll write these steps as if I'm creating/running a single-node swarm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment