Skip to content

1. Installing MicroK8s on Rocky Linux

MicroK8s is a lightweight, single-package Kubernetes distribution that you can install easily on your laptop, server, or Raspberry Pi. In this guide, we will install MicroK8s on a cPouta virtual machine.

Original Author: Sara Jokela
Last updated by Jesse Anttila
Last checked by Jesse Anttila
Lastmod: 09.10.2025
Status: OK
Comments: Tested with Rocky Linux version v9.6 and v10


Notes#

Create a NEW, CLEAN Rocky Linux virtual machine on cPouta for V2! Otherwise there might be conflicts!

The notes below old info, it is safe to skip. Leaving it as is for now.

This guide is based on the following resources:

It is recommended to go through those guides beforehand!

Next steps: commands for getting floating IP address and domain name in .gitlab-ci.yml instead of adding them as static variables.


Introduction#

Kubernetes (a.k.a. K8s) is an open-source platform for automating the deployment, scaling, and management of containerized applications.

MicroK8s is a lightweight, single-package Kubernetes distribution maintained by Canonical (the company behind Ubuntu).

Think of MicroK8s as a lightweight, all-in-one “mini Kubernetes” that you can install easily on your laptop, server, or Raspberry Pi.

It’s great for developers, hobbyists, or small environments where you don’t want the complexity of a full-blown Kubernetes cluster.

Prerequisites#

Installing MicroK8s on virtual machine#

First, we have to enable snap repositories to be available for Rocky Linux and do additional setup for snap. We need to do this because we have to install a bunch of snap packages and Rocky Linux does not come pre-installed with snap by default.

sudo dnf update -y

After this, it's a good idea to reboot the virtual machine.

sudo reboot

Wait a moment, and ssh back in. Continue with the following commands.

NOTE: If the epel release isn't updated with the release of snapd and you have errors on installing snap do the following and install specific packages from earlier version of snapd. NOTE: If you have problems with installing a package, try to install another one first because it needs a dependency for it.

wget https://kojipkgs.fedoraproject.org/packages/snapd/2.67/0.el10_0/x86_64/snapd-2.67-0.el10_0.x86_64.rpm
wget https://kojipkgs.fedoraproject.org/packages/snapd/2.67/0.el10_0/x86_64/snap-confine-2.67-0.el10_0.x86_64.rpm
wget https://mirror.kku.ac.th/epel/10.0/Everything/x86_64/Packages/s/snapd-selinux-2.67-0.el10_0.noarch.rpm

sudo dnf install <package_name>
Now you should be able to just continue with the rest of the guide without doing the "dnf -y install snapd" command because it get's installed with the manually downloaded packages.

sudo dnf -y install epel-release
sudo dnf -y install snapd
sudo ln -s /var/lib/snapd/snap /snap
echo 'export PATH=$PATH:/var/lib/snapd/snap/bin' | sudo tee -a /etc/profile.d/snap.sh
source /etc/profile.d/snap.sh
sudo systemctl enable --now snapd.socket 
systemctl status snapd.socket --no-pager
sudo setenforce 0
sudo sed -i 's/^SELINUX=.*/SELINUX=permissive/g' /etc/selinux/config

1. Install MicroK8s and kubectl#

First, check if any kernel updates are missing:

rpm -q kernel-core kernel-modules kernel-modules-extra

Install any uninstalled packages, for example:

sudo dnf install -y kernel-modules kernel-modules-extra

NOTE: If you encounter an error like error: system does not fully support snapd: cannot mount squashfs image using "squashfs"..., it means you are missing kernel modules

Next, install microK8s and kubectl:

sudo snap install microk8s --classic
sudo snap install kubectl --classic

2. Add rights to run MicroK8s command#

If you have logged as root user you should create separate user account for microk8s management.

eg. rocky. You need also to set password and group rights for this user

sudo useradd -m rocky
sudo usermod -a -G microk8s rocky

For the new group to take effect without having to reboot the system, run

newgrp microk8s

you can confirm that rocky was added to the microk8s group with the groups command

groups

3. Enable addons#

microk8s enable dns ingress cert-manager

NOTE If you get an error like: sudo: microk8s: command not found try without sudo and it should work

Here is a brief overview of the addons:

addon description
cert-manager Automates the issuance and renewal of TLS certificates for your services. Works well with Ingress and Let’s Encrypt to provide HTTPS automatically.
dns Installs CoreDNS, which provides internal DNS resolution for your Kubernetes cluster. It lets pods and services talk to each other using internal domain names instead of IPs (which change often)
helm Helm is the package manager for Kubernetes. It lets you install, configure, upgrade, and uninstall applications (like NGINX, Prometheus, or your own apps) easily using Helm charts — reusable templates for Kubernetes resources.
ingress Routes external web traffic into cluster services; enables an Ingress Controller (NGINX-based by default) that manages HTTP and HTTPS traffic into your cluster. It routes external requests to the right service using Ingress resources (YAML rules).
metallb Load balancer for your Kubernetes cluster. Enables LoadBalancer support for MicroK8s when running outside the cloud (e.g., on bare metal, VMs, or your local machine). It assigns external IPs to services of type LoadBalancer, making them accessible from outside your cluster.

4. Install Helm package manager#

Helm is a package manager for Kubernetes. (Just like apt for Debian or npm for Node). You can use helm scripts (charts) to define, install and upgrade applications. We will use Helm in later guides to install PrestaShop, Gitlab runner and other services/resources

sudo snap install helm --classic

5. Create a folder for Kubernetes config files#

mkdir -p ~/.kube

Give permissions

chmod 0700 ~/.kube

6. Get your floating IP address#

You have to first install dig tool.

sudo dnf install bind-utils

Create a variable with your virtual machine's floating ip.

FLOATING_IP=$(dig +short myip.opendns.com @resolver1.opendns.com)

You can do a sanity check to see what actually was stored in the variable

echo $FLOATING_IP

7. Enable MetalLB Load Balancer#

A load balancer distributes incoming network traffic (e.g., HTTP requests) across multiple backend servers (called pods in Kubernetes), making sure no single server gets overwhelmed.

MetalLB is a software load-balancer implementation for bare-metal Kubernetes clusters.

microk8s enable metallb "${FLOATING_IP}-${FLOATING_IP}"

8. Save the configuration#

Add kubectl's configuration from environment variable to kubectl's configuration file

microk8s kubectl config view --raw > ~/.kube/config

9. Testing MicroK8s setup#

You can check the kube config file contents if you want, using less -S cuts the long certificate and key data entries for easier viewing.

less -S .kube/config

Check if MicroK8s is up.

microk8s status

You should see some current info about MicroK8s, including enabled and disabled addons.

Command output for microk8s