Portainer on Swarm
April 10, 2021 | ClusterPortainer is a GUI admin tool for Docker (and K8s). And it is almost a "must have", not that you can't do without. But, this tool is really help full in getting and understanding of your whole cluster, it is stable and great for debugging.
The following "Stack" deployment will setup two services that run portainer:
version: '3.2'
services:
agent:
image: portainer/agent
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /var/lib/docker/volumes:/var/lib/docker/volumes
networks:
- agent_network
deploy:
mode: global
placement:
constraints: [node.platform.os == linux]
portainer:
image: portainer/portainer-ce
command: -H tcp://tasks.agent:9001 --tlsskipverify
ports:
- "9000:9000"
- "8000:8000"
volumes:
- portainer_data:/data
networks:
- agent_network
deploy:
mode: replicated
replicas: 1
placement:
constraints: [node.role == manager]
networks:
agent_network:
driver: overlay
attachable: true
volumes:
portainer_data:
Save the above file to a yaml file ex.: "portainer-deploy.yml". And use the following deploy command:
docker stack deploy --compose-file portainer-deploy.yml portainer
Then go to the master IP on port 9000: http://192.168.68.121:9000
And create a password for the admin user:
If you get en error unable to create admin user, try to change browser.
Portainer
Portainer will give you the full administrative CP that you need to get an overview of you cluster and its health.
Troubleshooting
I have experienced issues with connectivity to the nodes (agents). What seemed to help here were to restart both of the agents.