Skip to content

SwarmKit setup and Demos

Chakradhar Rao Jonagam edited this page Jun 21, 2016 · 9 revisions

In this Notes i'am going to show how to setup swarmkit and deploy a simple image on swarmkit
Pre-req are vagrant and docker installed on your machine

Spin 1 manager and 2 worker node instances. (basically 3 centos images)

git clone https://github.com/debianmaster/openshift-playground.git
cd openshift-playground
./up.sh        # This command should spin up 3 vms
./copykeys.sh  # This should copy your ssh keys to the running centos images

Install docker on each machine.

# On each server 
ssh [email protected]
ssh [email protected]
ssh [email protected]   
sudo su
yum erase -y docker-1.9.1-40.el7.centos.x86_64
yum erase -y docker-common-1.9.1-40.el7.centos.x86_64
yum erase -y docker-selinux-1.9.1-40.el7.centos.x86_64
curl -sSL https://experimental.docker.com/ | sh

Compile swarmkit sources (on your laptop)

git clone https://github.com/docker/swarmkit.git
docker run -it -v `pwd`/swarmkit:/go/src/github.com/docker/swarmkit golang:1.6 /bin/bash
root@9678dhje7bbc:/go# cd /go/src/github.com/docker/swarmkit/
root@9678dhje7bbc:/go/src/github.com/docker/swarmkit# make binaries
root@9678dhje7bbc:/go/src/github.com/docker/swarmkit# exit 

Copy the binaries to each server in temp location

scp -r `pwd`/swarmkit/bin  [email protected]:/tmp/bin   
scp -r `pwd`/swarmkit/bin  [email protected]:/tmp/bin  
scp -r `pwd`/swarmkit/bin  [email protected]:/tmp/bin   

Create manger and worker nodes

cd master1
vagrant ssh
cd /tmp/bin
./swarmd -d /tmp/master1 --listen-control-api /tmp/master1/swarm.sock --listen-remote-api 192.168.11.10:4242  --hostname master1   ## Manager creation

cd node11
vagrant ssh
cd /tmp/bin
./swarmd -d /tmp/node1 --listen-control-api /tmp/node1/swarm.sock --listen-remote-api 192.168.11.11:4242  --hostname node1  --join-addr 192.168.11.10:4242   #node


cd node2
vagrant ssh
cd /tmp/bin
./swarmd -d /tmp/node2 --listen-control-api /tmp/node2/swarm.sock --listen-remote-api 192.168.11.12:4242  --hostname node2 --join-addr 192.168.11.10:4242   #node

Login to master and deploy an image

cd master1
vagrant ssh
cd /tmp/bin
export SWARM_SOCKET=/tmp/master1/swarm.sock
./swarmctl service create --name welcome --image veermuchandi/welcome
./swarmctl  task ls   ## see list of tasks
./swarmctl  node ls   ## see list of hosts joined

Other notes

Comparision with kube:-

worker -- node --- can be promoted to manager manager -- master -- raft algo -- no centralized db task -- pod (may not be 100% true) service -- service

Swarmkit ~ API server + Etcd + Deployment Controller (in k8s)

Auth:--

Mutual TLS -- rotated certs -- min 30 1st master will create certs

Features:-

replicas rolling updates scheduling evac, pause, unpause secure auth

Missing:-

spec -- no file spec yet loadbalancing -- not clear yet --- Built-in Virtual-IP based internal and ingress load-balancing using IPVS upgrades -- how to stop missng logs -- no way to see

Architecture

Swarmctl --> Swarmd --> DockerEngine Swarmctl/swarm is embedded inside docker client in 1.12

Creating swarm cluster

on master (master.example.com)
--> docker swarm init

on node --> docker swarm join master.example.com:4777

Clone this wiki locally