Docker Swarm is used as the native clustering and scheduling tool for Docker. It allows IT, administrators and developers, to establish and manage a cluster of Docker nodes as a single virtual system. It is described in Go and released for the first time by Docker, Inc. in November 2015.
Orchestration and the cluster management features integrated into the Docker Engine are built using swarmkit. Swarmkit is a discrete project which executes Docker’s orchestration layer and is used straight within Docker. It is a toolkit for orchestrating distributed systems at any scale. It contains primitives for raft-based consensus, node discovery, task scheduling and many more.
Latest versions of Docker contains swarm mode for natively managing a cluster of Docker Engines called a swarm. One is able to use the Docker CLI to form a swarm, deploy application services to a swarm, and monitor and control swarm behavior. All you essential is to start it to use the latest features which comes with the Docker Engine.
Docker Swarm Mode Architecture
Every node in Swarm Mode has a role which can be categorized as a Manager and Worker. Manager node has accountability to really orchestrate the cluster, do the health-check, running containers helping the API and so on.
The worker node just performs the tasks which are essentially containers. It is not able to decide to schedule the containers on different machine. It cannot change the desired state. The workers only precede the work and report back the status. You may enable node promotion or demotion easily with the help of one-liner command.
Docker Swarm Communication internals
Managers and Workers use two different communication models. Managers have existing RAFT system that permits them to share information for a new leader election. one time, the only manager is basically executing the scaling and they make use of leader-follower model to figure out which one is supposed to be what. No External K-V store is required as a built-in internal distributed state store is available.
Workers, on the other side, use GOSSIP network protocol which is quite fast and consistent. Whenever any new activity/task (container) get created in the cluster, the gossip is going to spread it to all the other containers in a particular overlay network that this new container has started.
Please keep in mind that ONLY the containers which are running in the particular overlay network will be communicated and NOT globally. Gossip is optimized for heavy traffic.
- Eventually consistent: Routing mesh, load balancing rules.
- High volume p2p network between workers
- Secure: Symmetric encryption with key rotation in Raft
How Docker swarm varies with Docker?
Today Docker Platform supports 3 variants of Swarm:
- Docker Swarm ( Classic)
- Swarmkit(a foundation for Docker Swarm Mode)
- Docker Swarm Mode
Let us discuss each one of them one by one Docker Swarm 1.0 was introduced for the first time in Docker Engine 1.9 Release during November 2015. It was a different GITHUB repository and software which required to be installed for turning a pool of Docker Engines into a single, virtual Engine. It was announced as the simple method to run Docker applications at scale on a cluster.
You don’t have to worry about where to put containers, or how they talk to each other – it just handles all that for you. In 2016 during Dockercon, Docker Inc. announced Docker Swarm Mode for the first time. Swarm Mode came combined straight into Docker Engine which means you do not have to install it separately.
All you need is to initiate it using `docker swarm in it` command. With an optional “Swarm Mode” feature rightly integrated into core Docker Engine, native management of a cluster of Docker Engines, orchestration, decentralized design, service and application deployment, scaling, desired state reconciliation, multi-host networking, service discovery and routing mesh implementation is just a matter of few liner commands.
The basic difference is listed below:
|Docker Classic Swarm||Docker Swarm Mode|
|Docker Swarm is a GITHUB depository and comes as a different project. It is NOT integrated into Docker Engine.||Docker Swarm Mode comes integrated into Docker Engine|
|Need external KV store based on Consul & etc.||Comes with inbuilt Service Discovery|
|Lack of inbuilt feature like Load Balancing, Scalability, Routing Mesh, etc.||Comes with inbuilt feature like:
· Rolling Updates
· Service Discovery
· Routing Mesh
· Topological Placement
|Control Plane and Data Plane are insecure||Secured Control & Data Plane|