Donc quand on veut ajouter un node de type MANAGER :
pi@pi4node001:~ $ docker swarm join-token manager
To add a manager to this swarm, run the following command:
docker swarm join --token SWMTKN-1-2kr5jo0trm2o9bvnypqlzizx1exxivfeitqzi9smnhv6gxsd0f-95rzv0a1mbp0f8k1xkg55176n 192.168.0.201:2377
pi@pi4node001:~ $
et pour un de type WORKER :
pi@pi4node001:~ $ docker swarm join-token worker
To add a worker to this swarm, run the following command:
docker swarm join --token SWMTKN-1-2kr5jo0trm2o9bvnypqlzizx1exxivfeitqzi9smnhv6gxsd0f-8agpq7585s28ppp6gu1ldkf2x 192.168.0.201:2377
pi@pi4node001:~ $
maintenant, il faut se connecter sur le node voulu et exécuter la commande ci-dessus (en fonction du rôle voulu).
Voici un exemple de swarm :
pi@pi4node001:~ $ docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
ppyfmhdq6p4xpflqj17eay2cm * pi4node001 Ready Active Leader 20.10.5
pwsktgnu30hvtx5zkgsz4ay2v pi4node002 Ready Active 20.10.5
pi@pi4node001:~ $
Pour ajouter 2 noeuds de type WORKER (notez les hostnames… ):
sur pi4node004:
pi@pi4node004:~ $ docker swarm join --token SWMTKN-1-2kr5jo0trm2o9bvnypqlzizx1exxivfeitqzi9smnhv6gxsd0f-8agpq7585s28ppp6gu1ldkf2x 192.168.0.201:2377
This node joined a swarm as a worker.
pi@pi4node004:~ $
sur pi4node003:
pi@pi4node003:~ $ docker swarm join --token SWMTKN-1-2kr5jo0trm2o9bvnypqlzizx1exxivfeitqzi9smnhv6gxsd0f-8agpq7585s28ppp6gu1ldkf2x 192.168.0.201:2377
This node joined a swarm as a worker.
pi@pi4node003:~ $
Le résultat est :
pi@pi4node001:~ $ docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
ppyfmhdq6p4xpflqj17eay2cm * pi4node001 Ready Active Leader 20.10.5
pwsktgnu30hvtx5zkgsz4ay2v pi4node002 Ready Active 20.10.5
ucelbnf80e6ledibr1qcy9znd pi4node003 Ready Active 20.10.5
awl41iytsw3me002o9gh6u96h pi4node004 Ready Active 20.10.5
pi@pi4node001:~ $
Docker Swarm Visualizer – Interface Web
[callout type= »tip » title= »Quick Win »]
Déploie une interface web en une commande pour visualiser en temps réel l’état de ton cluster Docker Swarm.
[/callout]
Contexte
Quand tu gères un cluster Docker Swarm multi-nœuds, il est essentiel d’avoir une vue d’ensemble de l’état des services et des conteneurs. Le Swarm Visualizer d’Alex Ellis fournit exactement ça.
pi@pi4node001:~ $ docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
ppyfmhdq6p4xpflqj17eay2cm * pi4node001 Ready Active Leader 20.10.5
pwsktgnu30hvtx5zkgsz4ay2v pi4node002 Ready Active 20.10.5
zmt3lly41a9ultipey0p42oor pi4node003 Ready Active 20.10.5
ushbeebwkt20orsg29uhy8420 pi4node004 Ready Active 20.10.5
Déployer le visualizer
docker service create
–name viz
–publish 8080:8080/tcp
–constraint node.role==manager
–mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock
alexellis2/visualizer-arm:latest
Vérifier le déploiement
docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
ki6uzmz4myuu viz replicated 1/1 alexellis2/visualizer-arm:latest *:8080->8080/tcp
[/code]
[callout type= »note » title= »Architecture ARM »]
Utilise alexellis2/visualizer-arm:latest pour Raspberry Pi. Pour x86, utilise dockersamples/visualizer.
[/callout]
Accès
Une fois déployé, accède à l’interface via: http://IP_MANAGER:8080
[callout type= »success »]
Docker Swarm est significativement moins gourmand en ressources que K3s, ce qui est idéal pour des clusters Raspberry Pi.
[/callout]