06 - Docker Swarm - Container Orchestration

 Docker Swarm - Container Orchestration

  • Create Cluster
  • Build & Deployment automated
  • Rolling Deployment
  • Update Version
  • Docker Swarm is clustering for Docker
  • It turns several Docker hosts into a single virtual Docker host
  • The Swarm is controlled by Swarm Manager
  • Each Docker code communicates with the manager
  • It can be installed manually or by using Docker Machine
  • Scheduler
  • Service Discover
  • Consul -> provide DNS
  • Zookeeper - configuration management tools


Cheat Sheet => https://lzone.de/cheat-sheet/Docker%20Swarm


LAB

mkdir DockerSwarm
cd DockerSwarm
mkdir manager vm1 vm2 


*** Manager Node ****
cd manager
vagrant ssh
sudo su -
hostnamectrl set-hostname managernode.unix.in
bash

vi /etc/hosts
192.168.33.14 managernode.unix.in
192.168.33.15 workernode1.unix.in
192.168.33.16 workernode1.unix.in

## Install Docker C
curl -fsSL get.docker.com | sh
## Add user Vagrant in Docker group
sudo usermod -aG docker vagrant
id vagrant
## Start Docker Service
systemctl start docker
systemctl enable docker
## Initialize docker swarm cluster - Become Manager node
docker swarm init --advertise-addr 192.168.33.14
## save token after initialized in token.txt
docker swarm join --token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 192.168.33.14:2377
docker node ls
** 1 *** Go to nodes and run "docker swarm join xxx"

## create service
docker service create --replicas 1 --name helloworld alpin ping docker.com
docker service ls
docker service inspect --pretty helloworld
docker ps
docker service ps helloworld
# Scale service in Nodes for high availability
docker service scale helloworld=2
docker ps
docker service scale helloworld=3
docker ps
# Perform Rolling deployment 
# create 3 redis container
docker service create --replicas 3 --name redis redis:3.0.6
docker service inspect --preety redis
docker service ps redis
=> Now Update my servie 
docker service update --image redis:3.0.7 redis
=> you monitoring updating redis service
docker service ps redis
# Stop one container - Docker swarm dedected and start again
docker stop <container>
docker ps


*** Worker Node 1 ****
cd vm1
vagrant ssh
sudo su -
hostnamectrl set-hostname workernode1.unix.in
bash

vi /etc/hosts
192.168.33.14 managernode.unix.in
192.168.33.15 workernode1.unix.in
192.168.33.16 workernode1.unix.in

curl -fsSL get.docker.com | sh

sudo usermod -aG docker vagrant
id vagrant

systemctl start docker
systemctl enable docker
*** 1 ***
docker swarm join --token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 192.168.33.14:2377
This node joined a swarm as a worker

*** Worker Node 2 ****
cd vm2
vagrant ssh
sudo su -
hostnamectrl set-hostname workernode2.unix.in
bash

vi /etc/hosts
192.168.33.14 managernode.unix.in
192.168.33.15 workernode1.unix.in
192.168.33.16 workernode1.unix.in

curl -fsSL get.docker.com | sh

sudo usermod -aG docker vagrant
id vagrant

systemctl start docker
systemctl enable docker

*** 1 ***
docker swarm join --token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 192.168.33.14:2377
This node joined a swarm as a worker

Comments

Popular posts from this blog

05 - Docker - Containers

08 - PUPPET - Configuration Management