A Kubernetes cluster up and running (locally) in less than five minutes.

Unless for the last year you’ve been living under a rock, you’d know about Kubernetes. In a nutshell Kubernetes is a sophisticated container scheduler and solid orchestrator for scalable infrastructures. To a beginner the whole Kubernetes ecosystem and terminology might appear overwhelming. However, whether you would like to give a go to Kubernetes, the team behind it has developed Minikube, a tool that makes it easy to run Kubernetes locally. In this instalment I’m going to walk you thought from setting up Minikube and run a Docker image on top of a Kubernetes cluster.

Requirements:

brew https://brew.sh

xhyve https://github.com/mist64/xhyve

or

virtualbox https://www.virtualbox.org/wiki/Downloads

Installation and setup:

xhyve hypervisor (preferred way)

brew install docker-machine-driver-xhyve xhyve

sudo chown root:wheel $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve

sudo chmod u+s $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve

minikube config set vm-driver xhyve

Virtualbox hypervisor

Skip this whether you have Virtualbox already installed: brew update && brew install caskroom/cask/virtualbox caskroom/cask/virtualbox-extension-pack

brew update && brew install kubectl caskroom/cask/minikube

minikube config set vm-driver virtualbox

Kubernetes cluster bootstrap:

minikube start

https://gist.github.com/e56d6ffc001e592492f2866f7fb5a230

Cluster status check:

minikube status

https://gist.github.com/14e3b2257e6e2a0cd4dabf9729d109dc

Creating a flaskapp deployment.

kubectl run flaskapp --image=p0bailey/docker-flask:latest

kubectl get deployment

https://gist.github.com/0bf375c4d865bcbd612ae6cc461eb7a5

Get Kubernetes pods information:

kubectl get pod

https://gist.github.com/fe17340c5a2f80a6252458adbea2afb4

Operating the cluster:

Exposing flaskapp using a load balancer service:

kubectl expose deployment flaskapp --type=LoadBalancer --port=80

Accessing the flask application.

minikube service flaskapp --url

Once the url gets generated, point your browser to it and enjoy your first Kubernetes setup.

Kubernetes internals:

To view the the kubernetes dashboard URL for your local cluster:

minikube dashboard


One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.