1 – Different options to make a Kubernetes up and running
In order to play with a Kubernetes cluster, we first need to install one. Multiple options to get to it :
- Install a full complete cluster on multiple nodes
- Use katacoda and run demos
- Install minikube
Installing a full real Kubernetes cluster on multiple physical or virtual nodes is challenging, but time and money consuming for a first approach of the tool. We leave this one for a later post.
Second possibility, the fastest one, we can use katacoda to learn kubernetes. This very interesting site allow us to browse the major concepts of kubernetes (pods, nodes, services, rolling updates, and so on) online, with a real remote kubernetes cluster, and without any downloads. This is a real time saving one, but still I want to test my real applications on a Kubernetes cluster I can manage.
Ok then, minikube is what we are looking for : it is a lightweight Kubernetes implementation that deploys a Virtual Machine locally, and runs a basic cluster with one master and one minion together running on this unique VM :
2 – Minikube installation on a simple Linux Mint laptop
Let’s get through the installation process for minikube which leads us towards https://github.com/kubernetes/minikube/releases. The computer on which I install Minikube has the following configuration :
- Laptop with 4 CPU, 4 Go RAM
- Linux Mint 18.1 Serena
First of all, as we need a virtualization layer, I needed to activate virtualization in the BIOS or UEFI of my laptop :
VT-x or AMD-v virtualization must be enabled in your computer’s BIOS.
Let’s check that the virtualization layer has been activated on CPU :
lscpu | grep Virtualisation
Which returns :
Virtualisation : VT-x
Actually all recent computers include a virtualization layer.
Next step :
If you do not already have a hypervisor installed, install one now. For OS X, install VirtualBox or VMware Fusion, or HyperKit. For Linux, install VirtualBox or KVM. For Windows, install VirtualBox or Hyper-V.
From Linux kernel 2.6.20 (February 2007), KVM hypervisor is installed, and can be used as the required virtualization layer for Minikube.
Let’s proceed by getting latest version of Minikube and moving the installer to /usr/local/bin (the version 0.25.0 I used has to be updated of course) :
curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.25.0/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
Then the very first start of minikube will :
– Download the ISO file to use as image for the VM
– Create an instance of VM inside KVM, named ‘minikube’
– Proceed with its installation inside this VM :
My very first install displays this error :
Starting local Kubernetes v1.9.0 cluster... Starting VM... Downloading Minikube ISO 142.22 MB / 142.22 MB [============================================] 100.00% 0s E0222 07:28:09.886096 6577 start.go:159] Error starting host: Error creating host: Error executing step: Running precreate checks. : VBoxManage not found. Make sure VirtualBox is installed and VBoxManage is in the path. Retrying. E0222 07:28:09.887418 6577 start.go:165] Error starting host: Error creating host: Error executing step: Running precreate checks. : VBoxManage not found. Make sure VirtualBox is installed and VBoxManage is in the path ================================================================================ An error has occurred. Would you like to opt in to sending anonymized crash information to minikube to help prevent future errors? To opt out of these messages, run the command: minikube config set WantReportErrorPrompt false ================================================================================ Please enter your response [Y/n]:
Actually Minikube tries to use VirtalBox as default virtualization driver. We must explicitly require Minikube to use KVM driver (future Minikube starts will remind this setting) :
minikube start --vm-driver kvm
This time Minikube go through a correct installation process (also mentioning a new kvm2 driver to use) :
Starting local Kubernetes v1.9.0 cluster... Starting VM... WARNING: The kvm driver is now deprecated and support for it will be removed in a future release. Please consider switching to the kvm2 driver, which is intended to replace the kvm driver. See https://github.com/kubernetes/minikube/blob/master/docs/drivers.md#kvm2-driver for more information. To disable this message, run [minikube config set WantShowDriverDeprecationNotification false] Getting VM IP address... Moving files into cluster... Downloading localkube binary 162.41 MB / 162.41 MB [============================================] 100.00% 0s 0 B / 65 B [----------------------------------------------------------] 0.00% 65 B / 65 B [======================================================] 100.00% 0sSetting up certs... Connecting to cluster... Setting up kubeconfig... Starting cluster components... Kubectl is now configured to use the cluster. Loading cached images from config file.
3 – Installation of kubectl
Kubectl is the process used to communicatewith the master of the Kubernetes cluster. We need to install it to use our Minikube through CLI, on our same Linux laptop or even remotly if we have network access.
Let’s follow the instructions :
# Download the latest release with the command: curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl # Make the kubectl binary executable. chmod +x ./kubectl # Move the binary in to your PATH. sudo mv ./kubectl /usr/local/bin/kubectl
The configuration file of kubectl can be found here :
We can modify it if we want to access an already existing Kubernetes cluster. Otherwise the installation of a local Minikube cluster will automatically modify this configuration file, so there is nothing to do here, kubectl is configured to access the local Minikube.
To add autocompletion on kubectl commands, we can run :
source <(kubectl completion bash)
And in order to make it permanent :
echo "source <(kubectl completion bash)" >> ~/.bashrc
Now let’s see the state of our Minikube cluster and local kubectl after installation :
Should return :
minikube: Running cluster: Running kubectl: Correctly Configured: pointing to minikube-vm at 192.168.42.81