All HowTo's Kubernetes & Docker Linux Ubuntu, Mint & Debian Linux Web Servers

Kubernetes (MicroK8s) Part 1 – Installation on Ubuntu 20.04

This article walks you through the process of installing the minimal Kubernetes environment on Ubuntu 20.04. Kubernetes comes in two forms; a single node cluster and a multi-node cluster. In this walk through, we’ll be using the single node cluster called MicroK8s.

I suggest starting with a Ubuntu 20.04 server (or workstation) with the following installed:

apt update
apt install openssh-server curl

Ensure the firewall is open to you can access it later using SSH and a web browser:

ufw allow 22
ufw allow 10443
ufw enable

Now install the MicroK8s suite:

sudo snap install microk8s --classic
sudo microk8s enable dashboard dns registry istio

Now start MicroK8s:

sudo microk8s kubectl get all --all-namespaces

It’s running. But you need to start the proxy to get to it. Here’s how:

sudo microk8s dashboard-proxy &

Tip: The above shows that we’re starting the proxy in the background but it’s bound to this shell session.

The output from the above command will produce a token for you. Copy that. You’ll get the token to log into the MicroK8s dashboard.

Visit the dashboard and login at:

Tip: Where “” is the hostname or IP address of your new MicroK8s environment. It will ask you to log in using a Token (or another option), enter the token here – the one you copied in the last step.

Some things are simpler on the command line. We’ll create a basic Nginx pod called “agix-nginx”:

sudo microk8s.kubectl run agix-nginx --image=nginx:alpine --port=80

List your pods:

sudo microk8s.kubectl get pod

Now we can expose that pod to the wider network (not just within the Kubernetes environment). Note that the port “80” specified below is the port that the pod is using as described in the command above. See below for the command:

sudo microk8s kubectl expose pod agix-nginx --type=NodePort --port=80 --name=agix-nginx
sudo microk8s kubectl get services

My output from the above “get services” command shows:

NAME         TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
kubernetes   ClusterIP            443/TCP          121m
agix-nginx   NodePort           80:30045/TCP   19s

Now you can browse to the Kubernetes host from a remote machine and see the Nginx welcome page.

Make sure your exposing the port at the firewall level:

sudo ufw allow 30045

Continue to Part 2 – scaling applications.

Leave a Reply

Your email address will not be published. Required fields are marked *