Setting up my local Kubernetes cluster with MicroK8s – installation, network configuration, activation of key modules, and secure access through UFW.
Now that the project foundation is laid, it’s time to set up the Kubernetes infrastructure on my VPS using MicroK8s.
This will be the technical base on which I’ll deploy my portfolio.
Step 1 - Installing MicroK8s
I start by installing MicroK8s using the snap
package manager (already present on Ubuntu):
sudo snap install microk8s --classic
Step 2 - Adding My User
By default, all microk8s
commands require sudo
.
To get rid of that, I add my user to the microk8s
group:
sudo usermod -a -G microk8s $USER
newgrp microk8s
Step 3 - Verifying Installation
I check that the cluster is properly installed and ready:
microk8s status --wait-ready
Step 4 - Enabling Essential Modules
I enable the following components:
microk8s enable dns ingress storage
Quick explanations:
-
dns
: internal name resolution within the cluster -
ingress
: Ingress Controller (nginx reverse proxy) -
storage
: management of persistent volumes
Step 5 - Testing the Cluster
I verify everything is working with:
microk8s kubectl get all -A
Step 6 - Using kubectl Without microk8s Prefix
To use kubectl
directly without prefix, I export the config:
microk8s config > ~/.kube/config
Step 7 - Opening Ports with UFW
I configure the firewall (ufw
) to allow necessary connections:
sudo ufw allow 22/tcp # SSH
sudo ufw allow 80,443/tcp # HTTP / HTTPS (Ingress)
sudo ufw allow 16443/tcp # Kubernetes API
sudo ufw enable
Cluster Ready 🚀
The Kubernetes cluster is now ready to host my upcoming deployments.
In the next article, I’ll focus on building the Docker image for my site and setting up the first CI/CD pipeline to automatically publish it.