# Swarm

Stuff about Docker swarm


# My Swarm

Build notes about the Docker swarm running this stack.

# Keepalived

The docker swarm shares a single IP on the network, this is passed around using the Keepalived Docker image.

You can use the individual command on each swarm node as below, or you can use ansible (opens new window) to automatically take care of it.

Docker1

docker run -d --name keepalived --restart=always --cap-add=NET_ADMIN --network=host -e KEEPALIVED_INTERFACE="ens160" -e KEEPALIVED_UNICAST_PEERS="#PYTHON2BASH:['192.168.10.205', '192.168.10.206', '192.168.10.207']" -e KEEPALIVED_VIRTUAL_IPS=192.168.10.151 -e KEEPALIVED_PRIORITY=200 osixia/keepalived:latest

Docker2

docker run -d --name keepalived --restart=always --cap-add=NET_ADMIN --network=host -e KEEPALIVED_INTERFACE="ens160" -e KEEPALIVED_UNICAST_PEERS="#PYTHON2BASH:['192.168.10.205', '192.168.10.206', '192.168.10.207']" -e KEEPALIVED_VIRTUAL_IPS=192.168.10.151 -e KEEPALIVED_PRIORITY=190 osixia/keepalived:latest

Docker3

 docker run -d --name keepalived --restart=always --cap-add=NET_ADMIN --network=host -e KEEPALIVED_INTERFACE="ens160" -e KEEPALIVED_UNICAST_PEERS="#PYTHON2BASH:['192.168.10.205', '192.168.10.206', '192.168.10.207']" -e KEEPALIVED_VIRTUAL_IPS=192.168.10.151 -e KEEPALIVED_PRIORITY=189 osixia/keepalived:latest

# Commands

# Join Swarm

Run this on the master to get the join token

docker swarm join-token worker

Run this on the master to get the join token to add another manager

docker swarm join-token manager

# Swarm status

docker node ls

# Drain/Undrain

Empty a node

docker node update --availability drain <node>

Re-enable a node

 docker node update --availability active <node>
Last Updated: 2021/03/31 12:28+00:00