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.
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:
- Deploy custom PrestaShop Helm chart (internal repos)
- Installation of MicroK8S and Gitlab integration
- How to Build and Deploy an app Helm Chart on Kubernetes Cluster with GitLab CI/CD
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#
- Rocky Linux based virtual machine in cPouta (this guide has been tested with Rocky Linux versions 9.6 and 10).
- Check installation guide for cPouta VMs.
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.
After this, it's a good idea to reboot the virtual machine.
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>
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:
Install any uninstalled packages, for example:
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:
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
For the new group to take effect without having to reboot the system, run
you can confirm that rocky was added to the microk8s group with the groups command
3. Enable addons#
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
5. Create a folder for Kubernetes config files#
Give permissions
6. Get your floating IP address#
You have to first install dig tool.
Create a variable with your virtual machine's floating ip.
You can do a sanity check to see what actually was stored in the variable
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.
8. Save the configuration#
Add kubectl's configuration from environment variable to kubectl's configuration file
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.
Check if MicroK8s is up.
You should see some current info about MicroK8s, including enabled and disabled addons.
