How to set up Kubernetes on your local machine fast using Minikube.
Please note that this is not a guide. This is a cheat sheet. It would contain a list of commands, not a list of explanations. If you wanted more details, please check the article by Romin Irani which I based this from.
Note: Please make sure your Hyper-V is disabled. Docker Toolbox uses Virtual Box and VB doesn’t play nicely if your Hyper-V is enabled.
Install Docker Toolbox.
Minikube and Kubectl are console applications, so you don’t really need to install these. Just download and place them in some folder. Better still, add it to your path so you can run them anywhere.
We need this to get a list of Kubernetes versions Minikube currently supports.
Let’s start Minikube. But change the kubernetes-version to the latest. As of this writing, it’s v1.7.0 (your kubectl version must also be the same as this).
minikube.exe start --kubernetes-version="v1.7.0" --vm-driver="virtualbox" --show-libmachine-logs --alsologtostderr
Let’s see our kubectl version
Assuming your Minikube starts up well. We can now issue kubectl commands to it.
To further debug and diagnose cluster problems
kubectl cluster-info dump
If you simply want to get the IP address of your cluster.
And finally, the dashboard. My favorite part, simply because once you get to see it, it means your minikube setup is working as expected.
minikube dashboard or if just want the url:minikube dashboard --url=true
Launch your Kubernetes dashboard with the default port 8001.
Set the proxy with the default port number.
then you can access the dashboard by appending it with
Who would imagine a simple console application can give you a web based dashboard like that? Actually, if you watch minikube when it was starting up, you notice it downloading a bunch files? The dashboard is part of it, among other things.
Your Minikube setup is done. From this point on, most of the commands you will use will be kubectl.
Let’s start by getting a list of nodes.
kubectl get nodes
Now let’s run some app
kubectl run hello-nginx --image=nginx --port=80
What’s image=nginx? That’s actually a docker image. Docker will get it automatically for you.
kubectl expose deployment hello-nginx --type=NodePort
get the url
minikube service --url=true hello-nginx
This is just a convenience provided by minikube, but in production, you should rely on kubectl to get url.
Let’s get the nodes, so we can get the public IP address.
kubectl get nodes
Now we have the IP, all we need is the port number.
kubectl get svc
you will see something like
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
hello-nginx 10.10.10.207 <nodes> 80:31019/TCP 24m
In this case, the public port is 31019. You can now form the url by
kubectl scale --replicas=3 deployment/hello-nginx
get deployment status
kubectl get deployment
There are times that minikube IP changes.
When I run: minikube status, it says misconfigured
kubectl: Misconfigured: pointing to stale minikube-vm.
You can use:
This is where the config used by kubectl is located. This is how it knows which cluster to talk to. In production environments, there would be a lot of clusters. In our case, we just have one cluster created by minikube.
This is the folder minikube uses. It contains everything, settings, the virtual box machine image, ssl certs, etc…
Pay attention to this file disk.vmdk. This file would grow in size because all the apps you deploy goes into this machine image.
To be continued…