Difference between revisions of "Docker Swarm Mode"
(→Create swarm) |
|||
Line 95: | Line 95: | ||
+ | Létrehozunk egy szolgáltatást az nginx image-ből. Három példányban fog futni. | ||
<pre> | <pre> | ||
# docker-machine ssh master docker service create --name nginx --replicas 3 nginx | # docker-machine ssh master docker service create --name nginx --replicas 3 nginx | ||
Line 105: | Line 106: | ||
+ | Nézzük meg, hogy hol jöttek létre a konténerek az új szolgáltatásunkhoz. 2 a masteren, 1 pedig a node1-en fut. | ||
<pre> | <pre> | ||
# docker-machine ssh master docker service ps nginx | # docker-machine ssh master docker service ps nginx | ||
Line 111: | Line 113: | ||
k4osxnv0a8lm nginx.2 nginx:latest master 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 | t28ndarnryl5 nginx.3 nginx:latest master Running Running about a minute ago | ||
+ | </pre> | ||
+ | |||
+ | |||
+ | Ha csak a '''docker ps''' parancsot futtatjuk le, akkor láthatjuk, hogy csak azt a két konténert látjuk,amit a swarm a master node-on helyezett el. | ||
+ | <pre> | ||
+ | # docker-machine ssh master docker ps -a | ||
+ | CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES | ||
+ | 0386b9b36ad1 nginx:latest "nginx -g 'daemon of…" 3 minutes ago Up 3 minutes 80/tcp nginx.3.t28ndarnryl5r6plfbgcwb9sw | ||
+ | 568088b05844 nginx:latest "nginx -g 'daemon of…" 3 minutes ago Up 3 minutes 80/tcp nginx.2.k4osxnv0a8lm0qvwma0qvfat3 | ||
</pre> | </pre> |
Revision as of 13:41, 14 July 2018
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
Létrehozunk egy szolgáltatást az nginx image-ből. Három példányban fog futni.
# 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:
Nézzük meg, hogy hol jöttek létre a konténerek az új szolgáltatásunkhoz. 2 a masteren, 1 pedig a node1-en fut.
# 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
Ha csak a docker ps parancsot futtatjuk le, akkor láthatjuk, hogy csak azt a két konténert látjuk,amit a swarm a master node-on helyezett el.
# docker-machine ssh master docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 0386b9b36ad1 nginx:latest "nginx -g 'daemon of…" 3 minutes ago Up 3 minutes 80/tcp nginx.3.t28ndarnryl5r6plfbgcwb9sw 568088b05844 nginx:latest "nginx -g 'daemon of…" 3 minutes ago Up 3 minutes 80/tcp nginx.2.k4osxnv0a8lm0qvwma0qvfat3