Install MicroK8s:
You can simply follow the instruction on ubuntu initial setup as follow
If you already setup your system, you can install it in snap store or with:
sudo snap install microk8s --classic
NOTE: 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
Join the group:
MicroK8s creates a group to enable seamless usage of commands which require admin privilege. To add your current user to the group and gain access to the .kube caching directory, run the following two commands:
sudo usermod -a -G microk8s $USER
sudo chown -f -R $USER ~/.kube
Enable addons:
You can enable addons with:
microk8s enable dns
microk8s enable dashboard
microk8s enable storage
Or disable with:
microk8s disable dns
microk8s disable dashboard
microk8s disable storage
With microk8s status
you can see the list of available addons and the ones currently enabled.
Here are some addons most important:
- dns: Deploy DNS. This addon may be required by others, thus we recommend you always enable it.
- dashboard: Deploy kubernetes dashboard.
- storage: Create a default storage class. This storage class makes use of the hostpath-provisioner pointing to a directory on the host.
- ingress: Create an ingress controller.
- gpu: Expose GPU(s) to MicroK8s by enabling the nvidia-docker runtime and nvidia-device-plugin-daemonset. Requires NVIDIA drivers to be already installed on the host system.
- istio: Deploy the core Istio services. You can use the
microk8s istioctl
command to manage your deployments. - registry: Deploy a docker private registry and expose it on localhost:32000. The storage addon will be enabled as part of this addon.
Accessing the Kubernetes dashboard:
First check the deployment progress of our addons with microk8s kubectl get all --all-namespaces
. You should see outputs like this:
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system pod/calico-kube-controllers-847c8c99d-fmbsl 1/1 Running 0 92s
kube-system pod/metrics-server-8bbfb4bdb-gwbch 1/1 Running 0 14s
kube-system pod/dashboard-metrics-scraper-6c4568dc68-5xpbb 1/1 Running 0 14s
kube-system pod/calico-node-sc2pv 1/1 Running 0 92s
kube-system pod/coredns-86f78bb79c-lfjtr 1/1 Running 0 23s
kube-system pod/kubernetes-dashboard-7ffd448895-7n5j2 1/1 Running 0 14s
NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
default service/kubernetes ClusterIP 10.152.183.1 <none> 443/TCP 100s
kube-system service/kube-dns ClusterIP 10.152.183.10 <none> 53/UDP,53/TCP,9153/TCP 23s
kube-system service/metrics-server ClusterIP 10.152.183.158 <none> 443/TCP 15s
kube-system service/kubernetes-dashboard ClusterIP 10.152.183.64 <none> 443/TCP 14s
kube-system service/dashboard-metrics-scraper ClusterIP 10.152.183.223 <none> 8000/TCP 14s
NAMESPACE NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
kube-system daemonset.apps/calico-node 1 1 1 1 1 kubernetes.io/os=linux 95s
NAMESPACE NAME READY UP-TO-DATE AVAILABLE AGE
kube-system deployment.apps/calico-kube-controllers 1/1 1 1 95s
kube-system deployment.apps/metrics-server 1/1 1 1 15s
kube-system deployment.apps/dashboard-metrics-scraper 1/1 1 1 14s
kube-system deployment.apps/coredns 1/1 1 1 23s
kube-system deployment.apps/kubernetes-dashboard 1/1 1 1 14s
NAMESPACE NAME DESIRED CURRENT READY AGE
kube-system replicaset.apps/calico-kube-controllers-847c8c99d 1 1 1 93s
kube-system replicaset.apps/metrics-server-8bbfb4bdb 1 1 1 15s
kube-system replicaset.apps/dashboard-metrics-scraper-6c4568dc68 1 1 1 14s
kube-system replicaset.apps/coredns-86f78bb79c 1 1 1 23s
kube-system replicaset.apps/kubernetes-dashboard-7ffd448895 1 1 1 14s
As we see above the kubernetes-dashboard service in the kube-system namespace has a ClusterIP of 10.152.183.64
and listens on TCP port 443
. The ClusterIP is randomly assigned, so if you follow these steps on your host, make sure you check the IP adress you got. Point your browser to https://10.152.183.64:443
and you will see the kubernetes dashboard UI. To access the dashboard use the default token retrieved with:
token=$(microk8s kubectl -n kube-system get secret | grep default-token | cut -d " " -f1)
microk8s kubectl -n kube-system describe secret $token
Or, if you don’t have access to 10.0.0.0/8, you can forward the dashboard port 443 to 10443 with:
microk8s kubectl port-forward -n kube-system service/kubernetes-dashboard 10443:443 --address 0.0.0.0
Now, you can access the dashboard via https://<host.ip>:10443.
In case you need proxy for the container:
Edit /var/snap/microk8s/current/args/containerd-env
:
HTTP_PROXY=http://<your.proxy>
HTTPS_PROXY=http://<your.proxy>
NO_PROXY=10.0.0.0/8,192.168.0.0/16,127.0.0.1,172.16.0.0/16,microk8s-vm,.svc
Leave a Reply