Part 1 – Test Kubernetes with minikube

Introduction

The first part of this series of article start with the easiest way to test K8S. Minikube is a tool to deploy kubernetes locally on your machine using a virtual machine running with virtual box.

Pre-requisite

  • Virtual Box
  • A linux or Mac Os system

First we will have to download the minikube image for virtualbox

curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-darwin-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/

Deploy

As I said before, minikube is very easy, the only thing to deploy your cluster is to run :

⇒ minikube start
Starting local Kubernetes cluster...
Kubectl is now configured to use the cluster.

It will take a couple of minutes to get it ready. You can see in your virtual box console that a minikube machine as been created. You can track the deployment of your k8s cluster with the following command :

watch kubectl get pods --namespace kube-system

It will show you the deployment status of the different pods necessary for k8s to run. Once it show the following your cluster is ready :

Every 2.0s: kubectl get pods --namespace kube-system HOLBMAC0404: Tue Jan 24 15:04:39 2017

NAME READY STATUS RESTARTS AGE
kube-addon-manager-minikube 1/1 Running 0 21m
kube-dns-v20-bsdcc 3/3 Running 0 16m
kubernetes-dashboard-7zm9h 1/1 Running 0 17m

As you can see, by default minikube run DNS and Dashboard services.

You can see your kubectl config :

- See the config file : cat ${HOME}/.kube/config

- See the different contexts configured : kubectl config get-contexts
- See current context : kubectl config current-context

- See all cluster configured in the config file : kubectl config get-clusters

To interact with your kubernetes cluster :

- See your nodes : kubectl get nodes

- See the available namespaces : kubectl get namespaces

- See the pods : kubectl get pods --namespace kube-system

To access the dashboard simply run the proxy command

kubectl proxy

and browse to :

http://localhost:8001/api/v1/proxy/namespaces/kube-system/services/kubernetes-dashboard/

Or you could simply run the following :

 minikube dashboard
Opening kubernetes dashboard in default browser...

Stop/delete you cluster

If you want to reuse your cluster later :

minikube stop

Otherwise delete your cluster (and the virtual machine)

minikube delete

Conclusion

Minikube is a very easy and efficient tool to test k8s locally and is also a great tool to have a local test/dev environment. However, because it’s running locally when it comes to complex application it could be very slow and impact your own computer performances.

Leave a Reply

Your email address will not be published. Required fields are marked *