Goal: Install Kubernetes (microk8s) on Ubuntu on VirtualBox (Windows host) and get access to it from a laptop.
The host machine is Windows 10 x64 with IP: 10.0.99.166
Guest OS is Ubuntu 20.04 LTS
Laptop OS MacOS Catalina
Create a virtual machine with such minimum parameters: CPU – 1 min, RAM from 3Gb, HDD from 15Gb.
Download Ubuntu 20.04 x64
Installation is regular but you need to remember your password and chose to install K8s & Docker.
After installation completed tap “Reboot”. If it seems that the system hangs just push “Enter” several times.
Log in to the kubmaster virtual machine and check the IP.
Install DNS and Dashboard.
# microk8s.enable dns dashboard
Then you can use the following command to see if your services are running yet:
Let’s make port forward for K8s dashboard, SSH and kubectl.
Login via ssh to the server from laptop.
$ ssh firstname.lastname@example.org
to be possible connect to cluster via host Windows machine we need to add an IP of the host to microk8s config.
$ sudo -s
# cp /snap/microk8s/current/certs/csr.conf.template /var/snap/microk8s/current/certs/csr.conf.template
look to the
/snap/microk8s/current/certs/csr.conf and check the amount of the IP (will need it in the next step)
# vim /var/snap/microk8s/current/certs/csr.conf.template and add a similar line like
IP.7 = 10.0.99.166
you should add IP.x bigger than in csr.conf. If in csr.conf the last one was IP.4 then in csr.conf.template host IP should go by key IP.5.
After that stop/start k8s:
# microk8s.refresh-certs -i
To run dashboard forwarding in the background:
To log in to the dashboard token is needed. Here are commands to get it:
# token=$(microk8s kubectl -n kube-system get secret | grep default-token | cut -d " " -f1)
# echo $token
if not working here is another way:
# microk8s kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep default-token | cut -d " " -f1)
and search here for kubernetes-dashboard-token
Via browser in laptop go to https://10.0.99.166/ (use token to log in).
In the kubmaster server run such command to get the configuration of the cluster:
# microk8s.kubectl config view --raw
and paste it to
~/.kube/config in laptop.
Kubernetes up and running. Goal is reached.