How to Install Minikube on Ubuntu
Preparation
Before installing Minikube, I was to install the updates for my packages first:
$ sudo apt-get update
The above, fetches the list of all available updates
$ sudo apt-get upgrade
To update the current packages.
$ sudo apt autoremove
To remove the packages that are no longer in use.
$ sudo apt-get dist-upgrade
To install the new updates.
Next, we need to use curl to install the Minikube binaries. If you are not sure if you have curl installed you can run the following:
$ curl --version
If you don’t have curl, you can install it by running the following command:
$ sudo apt-get install curl
Minikube requires hardware virtualization to be enabled. You can check it in the BIOS. To check through the BIOS we need to restart the machine and press F12 when machine starts to enter into the BIOS:
We are good to go. Now we can install VirtualBox:
$ sudo apt-get install virtualbox virtualbox-ext-pack
After you run the command, you will get something similar:
To press OK, you need to press Tab first, and then Enter key.
Press enter key, then in a few minutes installation will be finished:
Installation & Setup
It’s not my first time installing Minikube ( fifth actually…), first time I followed official documentation, and that didn’t work for me. Eventually, I found out how to exactly install Minikube on my machine for it to work perfectly. I figured if I had issue, probably other people have them too, so I am sharing in all the details how to install & setup Minikube.
Go to the Downloads directory:
$ cd ~/Downloads
Form there, download Minikube binary via curl:
$ curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
Run ls command:
As you can see, minikube binary is installed, but it’s not an executable. For minikube to work we must make it executable, with this command:
$ chmod +x minikube
And then run ls command again:
Basically, we just changed the permissions of minikube binary to allow us to execute. It worked as you can check if the color of the minikube have changed.
Now we have to move the minikube file:
$ sudo mv -v minikube /usr/local/bin
Now we have to download kubeclt binary, by running the following:
$ curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.8.0/bin/linux/amd64/kubectl
Once the download is complete, we can run ls:
Same thing, we have to make it executable:
$ chmod +x kubectl
Then as with minikube, I will move the file:
$ sudo mv -v kubectl /usr/local/bin
Done!
Let’s test our minikube:
$ minikube start
Now, I can get a list of all Minikube nodes:
$ kubectl get pod
I am going to create a simple ‘echoserver’ Minikube pod with kubectl:
$ kubectl run hello-world --image=gcr.io/google_containers/echoserver:1.4 --port=8080
Let’s list the pods again:
$ kubectl get pod
To expose the pod’s port, we need to run the following:
$ kubectl expose deployment hello-world --type=NodePort
After which, we can get the url of our pod:
$ minikube service hello-world --url
Then, if I copy the url link and enter it into the browser:
Tadam! It’s alive!
We can also see same info from the command line if we run the following:
$ curl http://192.168.99.100:30818
Please note, your url will be different.
To delete the service:
$ kubectl delete service hello-world
To delete the pod:
$ kubectl delete deployment hello-world
To stop the Minikube, run:
$ minicube stop