The Hotel Hero

Notes by a Sysadmin


Cluster | Philosophy | Stack

Portainer on Swarm

April 10, 2021 | Cluster

Portainer 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.


About

I'm a Sysadmin, network manager and cyber security entusiast. The main purpose of this public "notebook" is for referencing repetitive tasks, but it might as well come in handy to others. Windows can not be supported! But all other OS compliant with the POSIX-standard can (with minor adjustments) apply the configs on the site. It is Mac OSX, RHEL and all the Fedora based distros and Debian based (several 100's of OS's), all the BSD distros, Solaris, AIX and HP-UX.

Links