Setup MicroK8s

Posted on November 12, 2019

How to build a developer kubernetes setup with MicroK8s

I needed a test kubernetes cluster to deploy my applications during the development. I have a Intel NUC which is perfect as small server and installed Ubuntu Server 19.10 and at the end of the installation the setup asked if I want to install MicroK8s.

As I have only installed a full featured kubernetes cluster on linux and on Windows I am using Docker Desktop for Windows with Kubernetes, I thought I give it a try.

It took a little while, but I ended up with a nice little kubernetes running which is perfect for my needs.

Install MicroK8s

This was done at the end of my Ubuntu Server installation. Have a look at the MicroK8s docs for other installations.

Enable RBAC

To be as similar as in the production system I want to enable rbac.

microk8s.enable rbac

Enable DNS

And also enable DNS

microk8s.enable dns

Enable Helm

All installatons in the kubernetes cluster I do with the help of Helm. MicroK8s has a helm addon which can be enabled with

microk8s.enable helm

After enabling helm, microk8s.helm ist the command to use. Before installing tiller in the cluster a service account and role binding must be applied to the cluster.

nano helm-rbac.yaml
apiVersion: v1
kind: ServiceAccount
  name: tiller
  namespace: kube-system


kind: ClusterRoleBinding
  name: tiller
  kind: ClusterRole
  name: cluster-admin
  - kind: ServiceAccount
    name: tiller
    namespace: kube-system

This file has to be applied to the cluster.

microk8s.kubectl apply -f helm-rbac.yaml

After the conditions were created, helm could be initialized.

microk8s.helm init --service-account tiller

Install MetalLB

LoadBalancers are an important when running a cluster. One of the ways to run a bare metal cluster is with the help of MetalLB.

microk8s.kubectl apply -f

Configure the MetalLB with the available IPs in the network.

apiVersion: v1
kind: ConfigMap
  namespace: metallb-system
  name: config
  config: |
    - name: default
      protocol: layer2
microk8s.kubectl apply -f metallb-conf.yaml

Install NGINX-Ingress

Helm is installed, a loadbalancer is running. Now it is time for the ingress controller as the last piece of my cluster.

microk8s.helm install stable/nginx-ingress --name my-nginx --set rbac.create=true

Cluster is running

microk8s.kubectl get all --all-namespaces
NAMESPACE        NAME                                                          READY   STATUS    RESTARTS   AGE
default          pod/my-nginx-nginx-ingress-controller-cfc8ccf95-8fz6z         1/1     Running   0          91m
default          pod/my-nginx-nginx-ingress-default-backend-6957b79cd7-jj28n   1/1     Running   0          91m
kube-system      pod/coredns-9b8997588-9wnvc                                   1/1     Running   5          27h
kube-system      pod/dashboard-metrics-scraper-566cddb686-b9hvc                1/1     Running   4          27h
kube-system      pod/heapster-v1.5.2-5c58f64f8b-l6rh6                          4/4     Running   19         27h
kube-system      pod/kubernetes-dashboard-678b7d865c-cm78b                     1/1     Running   4          27h
kube-system      pod/monitoring-influxdb-grafana-v4-6d599df6bf-g9xjt           2/2     Running   8          27h
kube-system      pod/tiller-deploy-79c578486f-2gfxt                            1/1     Running   0          92m
metallb-system   pod/controller-65895b47d4-wtxwc                               1/1     Running   2          26h
metallb-system   pod/speaker-65t9s                                             1/1     Running   2          26h

NAMESPACE     NAME                                             TYPE           CLUSTER-IP       EXTERNAL-IP       PORT(S)                      AGE
default       service/kubernetes                               ClusterIP     <none>            443/TCP                      30h
default       service/my-nginx-nginx-ingress-controller        LoadBalancer     80:32021/TCP,443:31373/TCP   91m
default       service/my-nginx-nginx-ingress-default-backend   ClusterIP   <none>            80/TCP                       91m
kube-system   service/dashboard-metrics-scraper                ClusterIP   <none>            8000/TCP                     27h
kube-system   service/heapster                                 ClusterIP    <none>            80/TCP                       27h
kube-system   service/kube-dns                                 ClusterIP    <none>            53/UDP,53/TCP,9153/TCP       27h
kube-system   service/kubernetes-dashboard                     ClusterIP   <none>            443/TCP                      27h
kube-system   service/monitoring-grafana                       ClusterIP    <none>            80/TCP                       27h
kube-system   service/monitoring-influxdb                      ClusterIP    <none>            8083/TCP,8086/TCP            27h
kube-system   service/tiller-deploy                            ClusterIP   <none>            44134/TCP                    92m

NAMESPACE        NAME                     DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR                 AGE
metallb-system   daemonset.apps/speaker   1         1         1       1            1    26h

NAMESPACE        NAME                                                     READY   UP-TO-DATE   AVAILABLE   AGE
default          deployment.apps/my-nginx-nginx-ingress-controller        1/1     1            1           91m
default          deployment.apps/my-nginx-nginx-ingress-default-backend   1/1     1            1           91m
kube-system      deployment.apps/coredns                                  1/1     1            1           27h
kube-system      deployment.apps/dashboard-metrics-scraper                1/1     1            1           27h
kube-system      deployment.apps/heapster-v1.5.2                          1/1     1            1           27h
kube-system      deployment.apps/kubernetes-dashboard                     1/1     1            1           27h
kube-system      deployment.apps/monitoring-influxdb-grafana-v4           1/1     1            1           27h
kube-system      deployment.apps/tiller-deploy                            1/1     1            1           92m
metallb-system   deployment.apps/controller                               1/1     1            1           26h

NAMESPACE        NAME                                                                DESIRED   CURRENT   READY   AGE
default          replicaset.apps/my-nginx-nginx-ingress-controller-cfc8ccf95         1         1         1       91m
default          replicaset.apps/my-nginx-nginx-ingress-default-backend-6957b79cd7   1         1         1       91m
kube-system      replicaset.apps/coredns-9b8997588                                   1         1         1       27h
kube-system      replicaset.apps/dashboard-metrics-scraper-566cddb686                1         1         1       27h
kube-system      replicaset.apps/heapster-v1.5.2-5c58f64f8b                          1         1         1       27h
kube-system      replicaset.apps/kubernetes-dashboard-678b7d865c                     1         1         1       27h
kube-system      replicaset.apps/monitoring-influxdb-grafana-v4-6d599df6bf           1         1         1       27h
kube-system      replicaset.apps/tiller-deploy-79c578486f                            1         1         1       92m
metallb-system   replicaset.apps/controller-65895b47d4                               1         1         1       26h

comments powered by Disqus