2.docker swarm - установка.

Thank you for reading this post, don't forget to subscribe!

Име­ет­ся несколь­ко хостов:
192.168.1.180 swarm_master1_180
192.168.1.181 swarm_master2_181
192.168.1.182 swarm_master3_182
192.168.1.183 swarm_node1_183
192.168.1.184 swarm_node2_184
192.168.1.185 swarm_node3_185

ини­ци­и­ру­ем кластер:
[root@swarm_master1_180~]# docker swarm init

Для добав­ле­ния вто­рой управ­ля­ю­щей ноды, выпол­ним коман­ду на дей­ству­ю­щей управ­ля­ю­щей ноде

[root@swarm_master2_181~]# docker swarm join --token SWMTKN-1-3ce1cv9a3lh4eulgw93epia3ksv4jds8bx6sx5y4ifeooaxvid-8v82bfxc20bu4telzgo9p2rq7 192.168.1.180:2377
This node joined a swarm as a manager.

[root@swarm_master3_182~]# docker swarm join --token SWMTKN-1-3ce1cv9a3lh4eulgw93epia3ksv4jds8bx6sx5y4ifeooaxvid-8v82bfxc20bu4telzgo9p2rq7 192.168.1.180:2377
This node joined a swarm as a manager.

 

теперь добав­ля­ем воркеры:

на масте­ре выпол­ня­ем команду:

[root@swarm_master1_180~]# docker swarm join-token worker

To add a worker to this swarm, run the following command:

docker swarm join --token SWMTKN-1-3ce1cv9a3lh4eulgw93epia3ksv4jds8bx6sx5y4ifeooaxvid-b4hyll4eh37i9vd15zzwft0tn 192.168.1.180:2377

 

[root@swarm_node1_183 ~]# docker swarm join --token SWMTKN-1-3ce1cv9a3lh4eulgw93epia3ksv4jds8bx6sx5y4ifeooaxvid-b4hyll4eh37i9vd15zzwft0tn 192.168.1.180:2377
This node joined a swarm as a worker.

[root@swarm_node2_184 ~]# docker swarm join --token SWMTKN-1-3ce1cv9a3lh4eulgw93epia3ksv4jds8bx6sx5y4ifeooaxvid-b4hyll4eh37i9vd15zzwft0tn 192.168.1.180:2377
This node joined a swarm as a worker.

[root@swarm_node3_185 ~]# docker swarm join --token SWMTKN-1-3ce1cv9a3lh4eulgw93epia3ksv4jds8bx6sx5y4ifeooaxvid-b4hyll4eh37i9vd15zzwft0tn 192.168.1.180:2377
This node joined a swarm as a worker.

 

[root@swarm_master1_180 ~]# docker node demote 0ihuax8tievdrp3m8xjz5v1ys
Manager 0ihuax8tievdrp3m8xjz5v1ys demoted in the swarm.

после поки­да­ем сам кластер:
[root@swarm_master1_180 ~]# docker swarm leave
Node left the swarm.

далее можем уда­лять ноды:
[root@swarm_master3_182 ~]# docker node rm 2u47nhxy05amaut0ljehr5hwe
2u47nhxy05amaut0ljehr5hwe
[root@swarm_master3_182 ~]# docker node rm y13tvpnm3oi520ab4tc891y7q
y13tvpnm3oi520ab4tc891y7q
[root@swarm_master3_182 ~]# docker node rm z9jxfogx18aadldbotsbqhofa
z9jxfogx18aadldbotsbqhofa