Whenever you need a nice and small Kubernetes demo and test environment, Minikube is the way to go. There are plenty of different ways to setup a small Kubernetes test cluster, but Minikube is by far the fastest and easiest way.
Many people run it on Workstation software like Virtualbox or VMware Fusion, but also on Hyper-V and KVM.
As Minikube runs on Linux without any big requirements, we chose Photon OS 3 on top of VMware vSphere, to setup our demo environments.
The following guideline was the result of our efforts.
After installing the Photon OS 3 VM and configuring it with 4 vCPUs and 8 GB of memory (feel free to adjust), we can start installing Minikube.
Just use the following command to install the latest version.
_c_url -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && sudo install minikube-linux-amd64 /usr/local/bin/minikube
and run minikube version to check the installed version.
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.12.4/bin/linux/amd64/kubectl && chmod +x kubectl && sudo cp kubectl /usr/local/bin/ && rm kubectl
First make sure that docker is configured and started: systemctl start docker.service
minikube start –vm-driver=none
and the process will download all required installation files. The parameter –vm-driver=none is important to let Minikube know, that it shouldn’t use any local virtualization engine, like Virtualbox.
If all went well, you should see the following text:
WARNING: IT IS RECOMMENDED NOT TO RUN THE NONE DRIVER ON PERSONAL WORKSTATIONS
The ‘none’ driver will run an insecure kubernetes apiserver as root that may leave the host vulnerable to CSRF attacks
When using the none driver, the kubectl config and credentials generated will be root owned and will appear in the root home directory.
You will need to move the files to the appropriate location and then set the correct permissions. An example of this is below:
sudo mv /root/.kube $HOME/.kube # this will write over any previous configuration
sudo chown -R $USER $HOME/.kube
sudo chgrp -R $USER $HOME/.kube
sudo mv /root/.minikube $HOME/.minikube # this will write over any previous configuration
sudo chown -R $USER $HOME/.minikube
sudo chgrp -R $USER $HOME/.minikube
This can also be done automatically by setting the env var CHANGE_MINIKUBE_NONE_USER=true
Loading cached images from config file.
Everything looks great. Please enjoy minikube!
Run your first container on the Minikube Kubernetes Setup
Let´s run the first container
kubectl run hello-minikube –image=k8s.gcr.io/echoserver:1.4 –port=8080
Expose the port
kubectl expose deployment hello-minikube –type=NodePort
Check if the container is running
kubectl get pod
Test the service
curl $(minikube service hello-minikube –url)
To remove the whole test run the following commands:
kubectl delete service hello-minikube
kubectl delete deployment hello-minikube
The next posts will be around testing management tools and monitoring using Minikube.