Skip to content
Industrial IoT and Edge

Portainer is your solution to securely deploy software containers across your fleet of Edge devices.

blog-banner
Adolfo DelorenzoFebruary 9, 20215 min read

Easy Multi Cluster Management for Kubernetes, Docker/Swarm and Edge

 

In this blog post, you will learn how to use Portainer to easily handle multi cluster management from a single instance of Portainer's easy Kubernetes GUI. This is accomplished by deploying an instance of the Portainer agent in every cluster you wish to manage and then connecting the central Portainer instance to the agents. We've also posted a 'how-to' video on this topic on our YouTube channel here.

For the purpose of this blog, the central instance of Portainer is running on a dedicated management instance using Docker,

Pre-reqs and assumptions:

  • Run the commands as super-user (root) or with sudo;
  • Use a modern Linux OS with snap support (not necessary for the deployment of the agent on Azure);

 

Deploy the centralized Portainer instance on Docker

Let's start by deploying a standalone Portainer instance. This can be done on a machine running on a local network, personal computer or laptop.

  1. On a terminal app of your preferences with docker installed (you can follow the official documentation here on how to install docker) run the commands below:
    1. docker volume create portainer_data
    2. docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce
  2. Once Portainer has been installed you can access the UI by opening a browser and typing the IP address of the machine where it has been deployed on port 9000, for example http://192.168.1.100:9000. You will land on Create the administrator user page:
  3. On the next screen make sure to select the Manage the local Docker environment option, click on Connect ...
  4. ...and you should land on the local endpoint where your standalone Portainer instance is running:

 

Deploy the Kubernetes NodePort agent on the first remote cluster

  1. Open your preferred terminal app;
  2. Login to the main node machine of your kubernetes cluster via ssh;
  3. Run the commands below as super-user or with sudo:
    1. curl -L https://downloads.portainer.io/portainer-agent-k8s-nodeport.yaml -o portainer-agent-k8s.yaml; kubectl apply -f portainer-agent-k8s.yaml
    2. kubectl get pods --namespace=portainer –> this will show the state of the agent
  4. Open Portainer on your browser and select Home->Endpoints:
  5. Select Add endpoint:
  6. Select Portainer Agent:
  7. Fill the following variables on the form:
    1. Name: pick a name to identify your environment cluster, for example local kubernetes cluster
    2. Endpoint URL: {IP address:30778} where IP address is the ip of the machine where you installed the agent.
  8. If all goes well you should see a Endpoint created pop-up box and the Kubernetes features configuration page :
  9. For a kubernetes cluster running on-premise you can set the Enable features using metrics server and the microk8s-hostpath options
  10. Your Portainer home screen should show the new Endpoint:

 

Deploy the Docker Swarm agent on the second remote cluster

The Docker Swarm agent installation is straightforward and easy.

  1. Open your preferred terminal app;
  2. Login to the manager machine via ssh;
  3. Run the commands below as super-user or with sudo:
    1. curl -L https://downloads.portainer.io/agent-stack.yml -o agent-stack.yml && docker stack deploy --compose-file=agent-stack.yml portainer-agent
    2. docker service ls –> this will show the state of the agent
  4. Repeat steps 4 through 7 from the Deploy the Kubernetes NodePort agent but making sure to use port 9001 instead of 30778 on the Endpoint URL

 

Deploy the Azure AKS Load Balancer agent on the third remote cluster

Installing the Portainer agent on Azure AKS can be 100% on the Azure Portal.

  1. Open Cloud Shell on your Azure Portal:


  2. Run the commands below:
    1. az aks get-credentials --resource-group portainer-endpoint-demo --name portainerEndpointDemo –> downloads the credentials to the .kube/config file so you can manage the kubernetes cluster with kubectl, make sure to replace the resource group and the cluster name accordingly
    2. curl -L https://downloads.portainer.io/portainer-agent-k8s-lb.yaml -o portainer-agent-k8s.yaml; kubectl apply -f portainer-agent-k8s.yaml
    3. kubectl get pods --namespace=portainer –> this will show the state of the agent
  3. Once the agent is installed you can close the Cloud Shell box and go to:
    1. Kubernetes services:
    2. Select the cluster where the agent was deployed:
    3. Open the Services and ingresses option and you will see the public IP address deployed by the Portainer agent on the cluster:
  4. Repeat steps 4 through 7 from the Deploy the Kubernetes NodePort agent but making sure to use the public IP assigned by the Azure service with port 9001 on the Endpoint URL.
  5. The Kubernetes features configuration is slightly different than the one used for the on-premise kubernetes cluster:
    1. Enable the ingress controller. For Azure the name of the controller is nginx and type nginx
    2. Enable at least one Storage option:
  • Explanation of the Azure Storage types can be found here.

 

Deploy the DigitalOcean Load Balancer agent on the fourth remote cluster

  • For DigitalOcean the pre-req is that you have their doctl command line utility installed and authenticated. Please refer to the installation page for doctl here.
  • The other pre-req is kubectl installed via the snap package manager. Make sure to install the same version of kubectl as the one on your hosted cluster.
  1. Open your preferred terminal app
    1. curl -L https://downloads.portainer.io/portainer-agent-k8s-lb.yaml -o portainer-agent-k8s.yaml; kubectl apply -f portainer-agent-k8s.yaml
    2. kubectl get pods --namespace=portainer –> this will show the state of the agent
  2. Go to the Networking option on your DigitalOcean dashboard:
  3. Will should see a public IP address assigned via a Load Balancer to your cluster:
  4. Repeat steps 4 through 7 from the Deploy the Kubernetes NodePort agent but making sure to use port 9001 and the public IP assigned by Digital Ocean on the Endpoint URL
Hope that worked well for you, and you're up and running with Portainer. If you have any questions or comments, please drop them into the comments section below, or join us on our Slack channel.

COMMENTS

Related articles