minikube – single node kubernetes cluster

Minikube is an open source tool that makes it easy to run Kubernetes locally. Minikube runs a single-node Kubernetes cluster inside a VM on your laptop for users looking to try out Kubernetes or develop with it day-to-day. This is ideal for development tests and POC purposes.

Before Installation

VT-x or AMD-v virtualization must be enabled in your computer’s BIOS. If you want to install on VM using VM Ware, you have to enable virtualization for Virtual Machine.

virtualization.png

I have created Virtual Machine with Ubuntu 18.04 operating system on VM Ware.

Update system

Run the following commands to update all system packages to the latest release.

$ sudo apt-get update -y
$ sudo apt-get install apt-transport-https -y
$ sudo apt-get upgrade -y

Install VirtualBox Hypervisor on Ubuntu

$ sudo apt install virtualbox virtualbox-ext-pack

Install kubectl

We need kubectl to deploy and manage applications on Kubernetes

$ curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
$ echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
$ sudo apt-get update
$ sudo apt-get install -y kubectl

Check version:

$ kubectl version -o json

Download minikube

$ wget https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64

$ chmod +x minikube-linux-amd64

$ sudo mv minikube-linux-amd64 /usr/local/bin/minikube

Check version:

$ minikube version
minikube version: v0.28.0

Start minikube

Now that components are installed, you can start minikube. VM image will be downloaded and configure d for Kubernetes single node cluster.

$ minikube start
Starting local Kubernetes v1.10.0 cluster...
Starting VM...
Downloading Minikube ISO
150.53 MB / 150.53 MB [============================================] 100.00% 0s
Getting VM IP address...
Moving files into cluster...
Downloading kubeadm v1.10.0
Downloading kubelet v1.10.0
Finished Downloading kubeadm v1.10.0
Finished Downloading kubelet v1.10.0
Setting 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.

minikube

Check nodes

$ kubectl get nodes
NAME     STATUS ROLES  AGE  VERSION
minikube Ready  master 6m1s v1.13.3

Run nginx container

$ kubectl run nginx --image=nginx:latest
$ kubectl get pods
NAME                  READY STATUS  RESTARTS AGE
nginx-585fddf4b-xz7t6 1/1   Running 0        63s

Expose the deployment to access the nginx

$ kubectl expose deployment nginx --port=80 --port=NodePort
$ kubectl get service
NAME       TYPE      CLUSTER-IP  EXTERNAL-IP PORT(S)      AGE
kubernetes ClusterIP 10.96.0.1   < none >    443/TCP      9m23s
nginx      NodePort  10.99.26.23 < none >    80:31728/TCP 10s

Now you can see the nginx page with node IP address.

Stop a running local kubernetes cluster

$ minikube stop

Delete a local kubernetes cluster

$ minikube delete

Kubernetes addons

$ minikube addons list

Enable Kubernetes Dashboard

$ minikube dashboard
Enabling dashboard ...
🤔  Verifying dashboard health ...
🚀  Launching proxy ...
🤔  Verifying proxy health ...
http://127.0.0.1:35837/api/v1/namespaces/kube-system/services/http:kubernetes-dashboard:/proxy/

It will open the dashboard in the browser.

dashboard