Kubernetes [1] is a system for automated container deployment, scaling and management. Sometimes users find it hard to setup a Kubernetes cluster in their machines. So Minikube [2] let you run a single node Kubernetes cluster in a VM. This is really useful for developing and testing purposes.
- Minikube supports Kubernetes features such as:
– DNS
– NodePorts
– ConfigMaps and Secrets
– Dashboards
– Container Runtime: Docker, and rkt
– Enabling CNI (Container Network Interface)
– Ingress
Pre-requisites for Minikube installation
- OS X – xhyve driver, VirtualBox or VMware Fusion installation
- Linux – VirtualBox or KVM installation
- VT-x/AMD-v virtualization must be enabled in BIOS
- Kubectl
Follow the guide in [3] to setup the Minikube tool.
Following commands will be helpful to play with Minikube.
- minikube start / stop / delete
Brings up the Kubernetes cluster locally / stop the cluster / delete the cluster
- minikube ip
IP address of the VM. This IP address is the Kubernete’s node IP address which you can use to access any service which runs on K8s.
- minikube dashboard
This will bring up the K8s dashboard where you can access it via the web browser.
- minikube ssh
You can ssh to the VM. Using following command, you can do the same with the following command.
ssh -i ~/.minikube/machines/minikube/id_rsa docker@192.168.99.100
The IP address 192.168.99.100 is the IP address which returns from the minikube ip command.
How to load locally built docker images to the Minikube
You can setup a docker registry for image pulling. Another option is to manually load the docker image as follows (You can use a script to automate this).
docker save mysql:5.5 > /home/user/mysql.tar
scp -i ~/.minikube/machines/minikube/id_rsa /home/user/mysql.tar docker@192.168.99.100:~/
docker load < /home/docker/mysql.tar
Troubleshooting guide for setting up Minikube
- Starting local Kubernetes cluster…
E1230 20:23:39.975371 11879 start.go:144] Error setting up kubeconfig: Error writing file : open : no such file or directory
This issue occurred when using minikube start command. This is due to incorrect KUBECONFIG environment variable. You can find the KUBECONFIG value using the following command.
env |grep KUBECONFIG
KUBECONFIG=:/home/pubudu/coreos-kubernetes/multi-node/vagrant/kubeconfig
Unset the KUBECONFIG to solve the issue.
unset KUBECONFIG
- Starting local Kubernetes cluster…
E1231 17:54:42.685405 13610 start.go:94] Error starting host: Error creating host: Error creating machine: Error checking the host: Error checking and/or regenerating the certs: There was an error validating certificates for host “192.168.99.100:2376”: dial tcp 192.168.99.100:2376: i/o timeout
You can attempt to regenerate them using ‘docker-machine regenerate-certs [name]’.
Be advised that this will trigger a Docker daemon restart which might stop running containers.
.Retrying.
E1231 17:54:42.688091 13610 start.go:100] Error starting host: Error creating host: Error creating machine: Error checking the host: Error checking and/or regenerating the certs: There was an error validating certificates for host “192.168.99.100:2376”: dial tcp 192.168.99.100:2376: i/o timeout
You can attempt to regenerate them using ‘docker-machine regenerate-certs [name]’.
Be advised that this will trigger a Docker daemon restart which might stop running containers.
You can solve this issue by removing the cache in minikube using the following command.
rm -rf ~/.minikube/cache/
[1] – http://kubernetes.io
[2] – http://kubernetes.io/docs/getting-started-guides/minikube/