Skip to content
Neil Cresswell, CEOFebruary 26, 20215 min read

Using Portainer to manage Canonical Charmed Kubernetes

So what about Deploying Portainer on a Canonical Charmed Kubernetes cluster? We have seen how to do this on MicroK8s that you can check on the link above but Charmed Kubernetes is an entirely different environment.

Canonical Charmed Kubernetes is demanding in terms of resources and is usually deployed on a Cloud provider like AWS, GCP or Azure. Oracle Cloud, Rackspace and CloudSigma can also be used to deploy Charmed Kubernetes. Local deployment is also possible but you have to make sure you have the right infrastructure to be able to do this.

Some pre-reqs for this tutorial:

  • Access to a Linux machine via a ssh terminal, preferably Ubuntu on the latest version;
  • You need the snap package management app installed on the machine you are going to use for your deployment;
  • Access to a Cloud Service Provider like AWS, GCP or Azure. We will use Azure as the CSP for this tutorial so make sure you know what can be the equivalent interfaces/commands if you use a different provider.

Initial setup

During the initial setup you will learn how to install the tools are required to setup Charmed Kubernetes and deploy the cluster.

Install the required tools

  1. Run the commands below on your terminal:
    1. snap install juju --classic
    2. snap install kubectl --classic
    3. apt -y install nmap -> this optional and can be used to check the ports that are open on the public IP address of your node(s)

Setup Juju with your cloud provider

  1. Add the cloud provider credentials with juju:
    1. juju add-credential azure
    2. You will be prompted to give this credential a name. You can use azure for example:

    3. The next prompt is the selection of the region you would like to use for the deployment. I picked eastus:

    4. The next step is to select the Auth Type, you can just go ahead and use [interactive] by simply hitting Enter:

    5. The next step is to type the Azure Subscription ID that you want to use to deploy your Charmed Kubernetes cluster:

    6. A link to finish setting up the credentials will appear that you need to open in your browser and paste the code to authenticate. A unique code will be generated every time you add the credentials via juju:
    7. If all goes well the following message will appear on your browser window:

Deploying the Charmed Kubernetes cluster

  1. Start the bootstrap of the juju controller you will deploy on your cloud provider:
    1. juju bootstrap azure <name> make sure to replace name with one of our preference. In this example I am going to use charmed01. This process can take up to 15 minutes:

    2. Deploy your Charmed Kubernetes cluster:
      1. For a full cluster you can use juju deploy charmed-kubernetes. This will deploy at least 8 machines with 2 redundant master nodes.
      2. An alternative is to deploy a smaller cluster with one master + one worker node and add more nodes afterwards: juju deploy cs:bundle/kubernetes-core-1200
      3. Add at least 2 more nodes with juju add-unit kubernetes-worker -n 2. You can run this right after step #2 above.
    3. You can monitor the progress of the deployment of your cluster with watch -c juju status --color:
    4. This will take at least 20+ minutes. If all goes well you should see on your screen the following status:

      You can hit CTRL+C to exit the juju status screen and go back to the prompt on your terminal window.
    5. Make sure you have a folder called .kube in your home folder. If you don't create is with mkdir -p $HOME/.kube
    6. Copy the config file from your master node in order to manage the cluster with kubectl: juju scp kubernetes-master/0:config ~/.kube/config
    7. Run a quick test to make sure you can access your cluster with kubectl with kubectl get nodes. You should see your worker nodes on your cluster:

Deploying OpenEBS

  1. OpenEBS is a amazing storage option for Kubernetes. Please visit their website to learn more about this project.
    1. Start by enabling the iscsid service on all of your nodes with juju ssh kubernetes-master/0 'sudo systemctl enable --now iscsid'.
    2. Repeat this command for every worker node by replacing kubernetes-master/0 with kubernetes-worker/0 for example: juju ssh kubernetes-worker/0 'sudo systemctl enable --now iscsid'
    3. Enable running privileged services on your master node: juju config kubernetes-master allow-privileged=true
    4. Download the yaml file needed to deploy OpenEBS on your cluster: wget
    5. Even though we enabled running privileged services on our master node we still need to make a small change to the privileged string on the file:
      sed -i 's/privileged: true/privileged: false/g' openebs-operator.yaml && cat openebs-operator.yaml
    6. Deploy OpenEBS with kubectl: kubectl apply -f openebs-operator.yaml
    7. You can check the status of the OpenEBS deployment with kubectl get pod -n openebs
    8. The deployment will finish once all the containers are running succesfully on your cluster:
    9. Finally we need to ensure that the openebs-jiva-default storageclass is set as default by running: kubectl patch storageclass openebs-jiva-default -p '{"metadata": {"annotations":{"":"true"}}}'

    10. Run kubectl get sc to make sure the patch worked:

      This is required otherwise Portainer cannot be installed

Deploying Portainer

  1. Installing Portainer is very easy. All you need is to run kubectl apply -n portainer -f to install Portainer using NodePort
  2. You can check the status of the instalation with kubectl get pod -n portainer. As soon as you see that the STATUS is Running then Portainer is ready to be used:
  3. Portainer when deployed on a NodePort will run on port 30777. We need to open this port on Azure (or on the CSP you deployed your cluster) to make sure it is accessible on the public IP of your node. You can do this by going to the All Resources page on your Azure portal and selecting the juju-internal-nsg in the juju-default-xxxxxxxx Resource group:

  4. Click on Inbound security rules:

  5. Create a rule that will open port 30777 like this:

  6. You should be able to access Portainer by opening your browser with the public IP address of any of your nodes + port 30777. In my case the public IP of my master node was therefore the link to open Portainer was

    On this page you need to setup the administrator user for Portainer
  7. The next step is to connect your Portainer instance to you Kubernetes cluster:

  8. The final step is to configure the Kubernetes features of your cluster on Portainer by enabling the metrics server features:

  9. and by enabling the openebs-jiva-default storage class with a RWO,RWX and Volume Expansion:
  10. Click on Save configuration and your Charmed Kubernetes cluster is ready to managed with Portainer!!


You can watch this all via youtube here:


Neil Cresswell, CEO

Neil brings more than twenty years’ experience in advanced technology including virtualization, storage and containerization.


Related articles