Docker Swarm Mode
Contents
Bevezető
IPTV
IPVS (IP Virtual Server) implements transport-layer load balancing, usually called Layer 4 LAN switching, as part of the Linux kernel. IPVS can direct requests for TCP- and UDP-based services to the real servers, and make services of the real servers appear as virtual services on a single IP address. IPVS is built on top of the Netfilter.[
SWARM
Introduction
A swarm is a group of machines that are running Docker and joined into a cluster. After that has happened, you continue to run the Docker commands you’re used to, but now they are executed on a cluster by a swarm manager. The machines in a swarm can be physical or virtual. After joining a swarm, they are referred to as nodes.
Source: https://docs.docker.com/get-started/part4/#introduction
docker@manager:~$ docker node ls ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION uzhpeg3ug0ip6f9o3l51c749y * manager Ready Active Leader 18.05.0-ce kstfblenhtb0dbpzkxo2olssn worker1 Ready Active 18.05.0-ce pf8jdfmlegbx7dogi6jnbxu2y worker2 Ready Active 18.05.0-ce
https://docs.docker.com/engine/swarm/swarm-tutorial/deploy-service/
Create swarm
docker@manager:~$ docker swarm init --advertise-addr 192.168.42.118 Swarm initialized: current node (uzhpeg3ug0ip6f9o3l51c749y) is now a manager. To add a worker to this swarm, run the following command: docker swarm join --token SWMTKN-1-21qaw0xpv9tj2kjxbmj6jn2jqpbcjjkyeze2nno9yy0wvt0vp9-9k2yyit1x8a11ca50ejxalzhz 192.168.42.118:2377 To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
docker@master:~$ docker swarm join-token worker To add a worker to this swarm, run the following command: docker swarm join --token SWMTKN-1-25li3z5dk9qianluoo2kk35geu2rwegg6ku6kfpefnyuhq00l5-6lj0p6lhrn0ytr28xohyy74zd 192.168.123.166:2377
# docker-machine create -d kvm --kvm-network "docker-network" --kvm-disk-size "5000" node1 Running pre-create checks... Creating machine... ... To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env node1
# docker-machine ssh node1 ## . ## ## ## == ## ## ## ## ## === /"""""""""""""""""\___/ === ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~ \______ o __/ \ \ __/ \____\_______/ _ _ ____ _ _ | |__ ___ ___ | |_|___ \ __| | ___ ___| | _____ _ __ | '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__| | |_) | (_) | (_) | |_ / __/ (_| | (_) | (__| < __/ | |_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_| Boot2Docker version 18.05.0-ce, build HEAD : b5d6989 - Thu May 10 16:35:28 UTC 2018 Docker version 18.05.0-ce, build f150324 docker@node1:~$
docker@node1:~$ docker swarm join --token SWMTKN-1-25li3z5dk9qianluoo2kk35geu2rwegg6ku6kfpefnyuhq00l5-6lj0p6lhrn0ytr28xohyy74zd 192.168.123.166:2377 This node joined a swarm as a worker. docker@node1:~$ exit
[root@adamDell2 ~]# docker-machine ssh master docker node ls ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION lstjx5br3i0nry3xijgeoc0u8 * master Ready Active Leader 18.05.0-ce 77yip8j71murtcu9kqki2m2in node1 Ready Active 18.05.0-ce
# docker-machine ssh master docker service create --name nginx --replicas 3 nginx o7dgqt3yynw3rs7yh2snmyybi overall progress: 0 out of 3 tasks 1/3: 2/3: 3/3:
# docker-machine ssh master docker service ps nginx ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS 5pfmf0noxxfp nginx.1 nginx:latest node1 Running Running about a minute ago k4osxnv0a8lm nginx.2 nginx:latest master Running Running about a minute ago t28ndarnryl5 nginx.3 nginx:latest master Running Running about a minute ago