Running Docker in production: Swarm
You build a Swarm cluster across several servers, update services without downtime, manage secrets and back up and restore the cluster.
Level 401 · 14 lessons · 12 practice labs
Lessons
The cluster
- Building a Swarm: managers and workers
- Raft, quorum and the number of managers
- Overlay networks and the routing mesh
- Short task: build a three-node cluster and test losing a node
Services
- Services and stack files
- Rolling updates and automatic rollback
- Placement constraints and node labels
- Swarm secrets and configs
- Short task: update a service under load without downtime
Operations
- Backing up and restoring cluster state
- Taking a node into maintenance: drain and rejoin
- Cluster certificates and key rotation
- Short task: recover a cluster that lost two managers
Wrap-up
- Capstone: build, monitor and hand over a redundant production cluster
Practice labs
- A worker that can’t join: Join the node that can’t enter the cluster with an old join token using the right token and address, and show it Ready in docker node ls.
- If one manager goes down: Grow the cluster to three managers, stop one to show the quorum holds and services can still be managed, and record the leader change in a report.
- A service that doesn’t answer on one node: Find why a published service answers on two nodes but not the third by checking the ports the overlay network needs, remove the block and show all three nodes answer.
- A Compose file that won’t deploy as a stack: Adapt a Compose file that can’t be deployed because of keys Swarm doesn’t support into a stack file, deploy it and show every service reaches its desired replica count.
- Automatic rollback on a bad version: Add rolling update and rollback-on-failure settings to the service, update it with a deliberately broken image and show the cluster returns to the previous version by itself.
- An update paused halfway: On Windy Ridge Energy’s service left half old and half new, find from the task history why the update was paused, then fix and resume or roll back and justify your choice.
- Pin the database to the right node: Label the node with the fast disk, constrain the database service to nodes with that label and show the task runs there.
- Changing a password without downtime: Replace the Swarm secret a service uses with a new version, update the service without downtime and show the old secret is gone and the app runs with the new one.
- A service that fits on no node: Find all the constraint, resource reservation and drained-node problems keeping a service’s tasks pending, fix them and show every replica running.
- Take a node into maintenance: Drain a node for maintenance, show its tasks move to the other nodes, bring it back when done and rebalance the load.
- A manager left locked: Unlock the manager that was restarted with autolock on and can’t rejoin the cluster, rotate the unlock key and show the new key is the valid one.
- Evict a worker you no longer trust: Remove a worker node assumed compromised from your lab cluster, rotate the join tokens and the cluster certificate authority, and prove a join attempt with the old token is refused.
About this course
You build a Swarm cluster across several servers, update services without downtime, manage secrets and back up and restore the cluster.
What you will learn
- The cluster
- Services
- Operations
- Wrap-up
Prerequisites
You should have practised the topics of the same path up to level 301.
Lab environment
Lessons run in your own Kali Linux terminal in the browser, connected to a private lab network. Nothing to install.
Frequently asked questions
- Is this course right for my level?
- The course is at level 401; it assumes you know the topics of the lower-level courses.
- Is there anything to install?
- No. Every lesson runs in your own lab environment that opens in the browser.
- How do lessons work?
- Each lesson has 8 to 10 steps and a short quiz. Early steps show the command to type, later steps give less help; if two attempts fail, the solution opens.
- Can I try it for free?
- Yes. The first three lessons of every course are free.