Schedule an appointment

Setting Up Single-node Microk8s on Linux (Red Hat and Ubuntu), A Step-by-Step Guide


This is the second blog in a series of blogs for setting up Microk8s. Link to part 1

MicroK8s simplifies the deployment of Kubernetes on Linux (Red Hat and Ubuntu). The blog explores how to install MicroK8s on Red Hat and Ubuntu.

Microk8s Linux Setup


Update the server with the latest updates and install Snap:  

Red Hat:

Disable SELinux

When running Microk8s on Red Hat Linux, SELinux can prevent the proper functioning of the Microk8s components by blocking network communications or preventing access to specific files or directories.

Run the below command to disable SELinux.

sudo sed -i 's/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
sudo setenforce 0

Run the command below for Microk8s to use full memory resources.

swapoff -a
Firewall Setup for microk8s

Open the ports below if the firewall is running.

sudo firewall-cmd --add-port={16443/tcp,10250/tcp,10255/tcp,25000/tcp,12379/tcp,10257/tcp,10259/tcp,19001/tcp,4789/udp, 10248/tcp,10249/tcp,10251/tcp,10252/tcp,10256/tcp,10257/tcp,10259/tcp,2380/tcp,1338/tcp,80/ tcp,443/tcp,4443/tcp,6443/tcp,7946/tcp,7472/tcp} –permanent
sudo firewall-cmd --reload
sudo systemctl restart firewalld.service


You may need to configure your firewall to allow pod-to-pod and pod-to-internet communication:

sudo ufw allow in on cni0 && sudo ufw allow out on cni0 sudo ufw default allow routed

For Red Hat:

Snap installation:

The command below is for Red Hat Linux. This will install snapd in Red Hat Linux. Please refer to the documentation of your Linux flavor and the operating system.

sudo dnf install epel-release -y
sudo dnf update

Add a repo if you are using RHEL9 for Snapd installation.

sudo dnf install sudo dnf upgrade sudo dnf -y install snapd

Once the package has finished installing, the systemd unit that manages the main snap communication socket needs to be enabled as follows:

sudo systemctl enable --now snapd.socket

Furthermore, to enable classic snap support, enter the following to create a symbolic link between /var/lib/snapd/snap and /snap, then add snap to the PATH variable.

sudo ln -s /var/lib/snapd/snap /snap
echo 'export PATH=$PATH:/var/lib/snapd/snap/bin' | sudo tee -a /etc/profile.d/

For Ubuntu:

Use the below command to update the Ubuntu server before installing microk8s. Once the system is back, install microk8s.

sudo apt update && sudo apt upgrade
sudo reboot

Installation Steps for Installing MicroK8s.

For Red Hat:

sudo snap install microk8s --classic --channel=1.27/stable sudo usermod -aG microk8s $USER sudo chown -f -R $USER ~/.kube

For Ubuntu:

Run the below command.

sudo usermod -aG microk8s $USER sudo chown -f -R $USER ~/.kube sudo snap install microk8s --classic --channel=1.27/stable

Log out and log in from the server.

Check the status by using the below command:

microk8s status

Check nodes by using the below command:

microk8s kubectl get nodes

Check pods by using the below command:

microk8s kubectl get pods -A

Check services by using the below command:

microk8s kubectl get svc -A

Check resource utilization for nodes or pods by using the below command:

microk8s kubectl top nodes -A
microk8s kubectl top pods -A

Kubernetes Dashboard

Enable Dashboard

microk8s enable dashboard

Change the type from ClusterIP to NodePort. Change the last line from type: ClusterIp to NodePort. Run the below in cmd.

microk8s kubectl -n kube-system edit service kubernetes-dashboard

Save and close.

You can get the nodeport from the below command it starts with a higher number port from 30000.

microk8s kubectl get svc -n kube-system

For RedHat

Allow firewall rule to access Microk8s Dashboard.

sudo firewall-cmd --add-port=NodePort/tcp –permanent
sudo firewall-cmd –reload

Check for the Port on which Dashboard is listening. Access it using https://<ipaddress>:<nodeport>.

For Token

microk8s kubectl -n kube-system describe secret $(microk8s kubectl -n kube-system get secret | grep default-token | cut -d " " -f1)

Copy and paste the token into the browser to access the Kubernetes Dashboard.

Add a policy to the metric server.

Run the below command.

microk8s kubectl patch deployment metrics-server -n kube-system --patch '{"spec":{"template":{"spec":{"hostNetwork": true}}}}'

Deploy the Nginx pod in microk8s and access it via ingress.

Create a deployment for the nginx webserver. Run the below command.

microk8s kubectl create deployment nginx --image=nginx

Expose service for nginx webserver as nodeport.

microk8s kubectl create service nodeport nginx --tcp=80:80

Go to your Web browser to access http://IPaddress:<nodeport>. You will see the nginx welcome page.

Great! You have successfully installed MicroK8s on your Linux system, deployed the nginx web server, and exposed it via ingress.


MicroK8s provides a lightweight and simplified way to deploy Kubernetes clusters on Red Hat and Ubuntu distributions, with its ease of installation and convenient management of essential Kubernetes.


No items found.
Arystech Logo

We Love to Talk Tech

Whether you need advice or are ready to get started, we're here to help. We go the extra mile to empower your digital transformation.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.


AWS - Select Tier Services PartnerAWS - Lambda Delivery PartnerAWS - Well-Architected PartnerMicrosoft Partner