MicroK8s — lightweight kubernetes for workstations

Hari Manikkothu
Kubernetes
Published in
3 min readOct 3, 2019

--

MicroK8s is a lightweight CNCF certified kubernetes, packaged to run on 42 flavors of Linux according to the official documentation. Unlike minikube, MicroK8s runs natively on the host machine — no VMs used. This means MicroK8s doesn’t need a hypervisor support on the host machine to run, so it can be installed on other VMs (Virtualbox VM for example) without any overhead. The entire set of libraries and binaries are packaged using snap package, so the installation is lightning fast!

Current version of MicroK8s includes the following addons

https://microk8s.io/

Installation

Since the MicroK8s is packaged with snap, snapd is required on the host to install. The latest Ubuntu distribution comes with snapd already built in.

Install the latest MicroK8s with the following command

$ sudo snap install microk8s --classic

Now you are ready to use kubernetes on the workstation!

Enable addons

Enable necessary addons from the list above. The command below enables dashboard and dns addons.

$ sudo microk8s.enable dashboard dns

Dashboard deploys the kubernetes dashborad as well as grafana and influxDB.

Access kubernetes

Check the deployment status with ‘kubectl get all’ command. This should list all resources including the dashboard and dns addons enabled earlier.

$ sudo microk8s.kubectl get all --all-namespaces

Kubernetes dashboard

Notice the Cluster-IP and port of kubernetes-dashboard service in the above listing — 10.152.183.114. The dashboard UI will be accessible from the workstation through this IP:Port, for example — https://10.152.183.114/

Use either kubeconfig, or token to sign in.

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

Successful log in takes you to the homepage

Grafana dashboard

Use the ‘sudo microk8s.kubectl cluster-info’ command to see grafana url, navigate to the portal to view the dashboard.

$ sudo microk8s.kubectl cluster-info

Use the ‘sudo microk8s.config’, get user/pwd to sign in to grafana.

Create deployments

Now the basic setup is complete, you can start deploying your apps to the MicroK8s enviroment.

Use the following command to deploy a microbot sample app

# Creates deployment
$ sudo microk8s.kubectl create deployment microbot --image=dontrebootme/microbot:v1
# Scale
$ sudo microk8s.kubectl scale deployment microbot --replicas=2

Create a service to expose the deployment

$ sudo microk8s.kubectl expose deployment microbot --type=NodePort --port=80 --name=microbot-service

Use the ‘sudo microk8s.kubectl get all --all-namespaces’ command to see the new service.

Since the service is exposed as NodePort type, it will be available on the localhost at the port shown on the cluster IP. e.g. http://localhost:32534/

References

--

--

Hari Manikkothu
Kubernetes

kubernetes enthusiast | AWS certified Solution Architect