Kubernetes: Install using MicroK8s on Ubuntu

This guide will show you how to install Kubernetes using MicroK8s on Ubuntu. MicroK8s make it super easy to get going with Kubernetes. Also, MicroK8s is bundled with tools such as Prometheus. So you enable a feature if you need it.

About MicroK8s

Canonical is the publisher of MicroK8s, and you can install it on Linux, macOS, and Windows. As per Canonical, MicroK8s is a: low-ops, minimal production Kubernetes for devs, cloud, clusters, workstations, Edge, and IoT.

Also, MicroK8s:

  • Supports high availability and does self-healing with no administrative interventions.
  • It is small, with sensible defaults that just work.
  • It has the same APIs as provided by Kubernetes.
  • Has full enterprise support available with no license fees.
  • Will apply security updates automatically by default. You can defer them if you want.
  • MicroK8s runs in an immutable container, so your Kubernetes itself is fully containerized.
  • It is bundled with a whole bunch of apps that just need to be enabled. For example, Prometheus, Jaeger, Istio, LinkerD, and KNative.

Let's get started!

First, run the following command to install MicroK8s on Linux:

sudo snap install microk8s --classic

You then want to create a group for MicroK8s and add your user to the group.

sudo usermod -a -G microk8s $USER
sudo chown -f -R $USER ~/.kube
su - $USER

You can then verify the install status of MicroK8s using the following command:

microk8s status --wait-ready

Next, note that MicroK8s bundles its own version of kubectl for accessing Kubernetes. So instead of using "kubectl get nodes", you will use "microk8s kubectl get nodes". You can fix this by adding the following line to your ~/.bash_aliases file:

alias kubectl='microk8s kubectl'

MicroK8s commands

Use the following command to get the status:

microk8s status

Then, if you want, use this command to see the MicroK8s configuration:

microk8s config

Also, you can start MicroK8s using this command:

microk8s start

Then use this command to stop MicroK8s:

microk8s stop

Finally, you can enable MicroK8s using this command:

snap enable microk8s

Or, you can disable MicroK8s using this command:

snap disable microk8s

You can also remove MicroK8s if you wish using this command:

snap remove microk8s

Kubernetes commands

You use the following commands to get around your Kubernetes installation:

  • Use this command to get all the nodes in the cluster: microk8s kubectl get nodes
  • This command will show all the services: microk8s kubectl get services -o wide --all-namespaces
  • Next, you can create a deployment using this command: microk8s kubectl create deployment nginx --image=nginx
  • Finally, use this command to enable features: microk8s enable dashboard dns storage

Lastly, you can get the auth token for using these commands:

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

Wrapping up

You have now installed Kubernetes on your Ubuntu machine using MicroK8s. Which tools do you plan to enable on your fresh Kubernetes install?

You may also be interested in

Sources:



About the Authors

Anto's editorial team loves the cloud as much as you! Each member of Anto's editorial team is a Cloud expert in their own right. Anto Online takes great pride in helping fellow Cloud enthusiasts. Let us know if you have an excellent idea for the next topic! Contact Anto Online if you want to contribute.

Support the Cause

Support Anto Online and buy us a coffee. Anything is possible with coffee and code.

Buy me a coffee



Leave a Reply

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