VOOZH about

URL: https://thenewstack.io/kubernetes-101-deploy-portainer-to-a-microk8s-cluster/

⇱ Kubernetes 101: Deploy Portainer to a MicroK8s Cluster - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

What’s next?

Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.

Follow TNS on your favorite social media networks.

Become a TNS follower on LinkedIn.

Check out the latest featured and trending stories while you wait for your first TNS newsletter.

PREV
1 of 2
NEXT
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2022-12-31 06:00:19
Kubernetes 101: Deploy Portainer to a MicroK8s Cluster
Kubernetes

Kubernetes 101: Deploy Portainer to a MicroK8s Cluster

With the help of MicroK8s, you can deploy Portainer in such a way as to make managing Kubernetes exponentially easier.
Dec 31st, 2022 6:00am by Jack Wallen
👁 Featued image for: Kubernetes 101: Deploy Portainer to a MicroK8s Cluster

Portainer is a powerhouse container management platform that is not only perfectly at home with Docker deployments but with Kubernetes environments as well. However, as anyone who’s ever dealt with Kubernetes will tell you…it’s hard. Given how many moving pieces are to be had with a Kubernetes cluster, unless you really know what you’re doing, you’ll find managing such an environment can be an absolute nightmare.

Thankfully, there are GUIs like Portainer that go a very long way to simplify your Kubernetes experience. Yes, you still have to have an understanding of how Kubernetes works — you need to know about namespaces, pods, networks, applications, ingresses, and much more. Imagine having a web-based GUI to clear away some of that confusion so you can actually get to the important part…deploying your applications and services.

That’s what Portainer does and with the help of MicroK8s, you can deploy Portainer in such a way as to make managing Kubernetes exponentially easier.

Let me show you how.

Requirements

To make this work, you’ll need at least three machines running Ubuntu Server 22.04 (because that’s my go-to server distribution). Yes, you can do this on another Linux distribution, but you’ll need to modify the installation procedure. The steps for deploying MicroK8s and Portainer are the same, so once you get beyond the MicroK8s installation, everything here will work as it stands.

Step 1: Install MircoK8s

The first thing we must do is install MicroK8s. There is, however, a trick. Portainer will not work with any version of MicroK8s earlier than 1.24. To add to that issue, I’ve found versions later than 1.24 don’t reliably cluster. Because of that, we’ll install version 1.24 of MicroK8s. Here are the steps.

Edit the Hosts Files

The first thing you’ll want to do is edit the host files on all three machines. To open the file for editing, issue the command:

sudo nano /etc/hosts

At the bottom of that file, add the following (making sure to use your IP addresses and hostnames):

192.168.1.70 k8s1
192.168.1.71 k8s2
192.168.1.72 k8s3

Save and close the file. Make sure you edit the hosts file the same way on all three machines.

Change the Hostnames

You’ll also need to change the hostname for each machine. We’ll stick with our convention above. On each machine, you’ll run a command like this:

sudo hostnamectl set-hostname k8s1

Do the same thing on each machine, using k8s2, and k8s3 as the other hostnames. Once you’ve done that, log out of each machine and log back in.

Set the Correct Timezone

You will also need to make sure all machines are on the same (correct) timezone. For this, you’ll run a command like this:

sudo timedatectl set-timezone America/Kentucky/Louisville

Make sure to substitute America/Kentucky/Louisville for your timezone, which can be found with the command:

sudo timedatectl list-timezones

Install MicroK8s

MicroK8s can be easily installed on Ubuntu Server with snap. On each machine, you’ll issue the command:

sudo snap install microk8s --channel=1.24/stable --classic

Next, add your user to the MicroK8s group with:

sudo usermod -aG microk8s $USER

Log out and log back in.

Finally, change the ownership of the .kube folder with:

chown -f -R $USER ~/.kube

With MicroK8s installed on all three machines, you’re ready to create the cluster.

Cluster Your Machines

On the controller (k8s1), issue the command:

microk8s add-node

The output will include the join command that you will run on all your nodes. The command will look something like this:

microk8s join 192.168.1.70:25000/5c4af12af72cef10c631e5db00e3b3c5/5786c9b07835

Back on the controller, verify the nodes have successfully joined with the command:

microk8s kubectl get nodes

The output should look something like this:

k8s1   Ready    <none>   9d    v1.24.8-2+1dda18a15eea38
k8s2   Ready    <none>   9d    v1.24.8-2+1dda18a15eea38
k8s3   Ready    <none>   9d    v1.24.8-2+1dda18a15eea38

You’re now ready to deploy Portainer to the cluster.

Deploying Portainer to the MicroK8s

On the controller you must first enable a few add-ons, which can be done with the following commands:

microk8s enable dns
microk8s enable ha-cluster
microk8s enable ingress
microk8s enable metrics-server
microk8s enable rbac
microk8s enable hostpath-storage

Next, you must enable the MicroK8s community repository with the command:

microk8s enable community

Finally, you can enable Portainer with:

microk8s enable portainer

Give Portainer a minute or so to finish deploying. To check on the status of Portainer, issue the following command:

microk8s kubectl get pods -n portainer

Once Portainer is listed in a running state, open your default web browser and point it to either http://SERVER:30777 or https://SERVER:30799 (where SERVER is the IP address or domain of the hosting server).

Portainer will prompt you to create a new admin user. Once you’ve done that, make sure to select the local environment and you’ll then be greeted by the Portainer Dashboard (Figure 1), clearly showing you have a Kubernetes environment to work with.

👁 Image

Figure 1: Portainer is now ready for your first Kubernetes deployment.

And that’s all there is to deploying the Portainer management platform for a Kubernetes environment. Thanks to MicroK8s, this is a great way to get up to speed with Kubernetes without being overwhelmed by too many commands or the nightmare that can be deploying Kubernetes itself.

TRENDING STORIES
Jack Wallen is what happens when a Gen Xer mind-melds with present-day snark. Jack is a seeker of truth and a writer of words with a quantum mechanical pencil and a disjointed beat of sound and soul. Although he resides...
Read more from Jack Wallen
SHARE THIS STORY
TRENDING STORIES
TNS owner Insight Partners is an investor in: Docker.
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.