Andreas Koop
Feb 1 · 3 min read

Kubernetes is a popular container orchestration platform. This post is a short summary & reference for getting hands dirty on your local machine — in my case on a macOS.

Since Kubernetes is made for real world production demands there is a special distribution for local machines named Minikube. It runs on a single-node cluster inside a VM.

Prerequites

Make sure you have the following developer tools installed.

  • VirtualBox (at the time of writing version 6.0 worked for me)
  • homebrew (at the time of writing version 1.9.3)

(on macOS 10.14.2)

Install Minikube

Installation of Minikube is easy as follows

$ brew install kubernetes-cli
...
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.2", GitCommit:"cff46ab41ff0bb44d8584413b598ad8360ec1def", GitTreeState:"clean", BuildDate:"2019-01-13T23:15:13Z", GoVersion:"go1.11.4", Compiler:"gc", Platform:"darwin/amd64"}
The connection to the server localhost:8080 was refused - did you specify the right host or port?
$ brew cask install minikube
...
🍺 minikube was successfully installed!

Verify Minikube installation

$ minikube start
Starting local Kubernetes v1.13.2 cluster...
...
Everything looks great. Please enjoy minikube!

Looking into VirtualBox you should see a running VM “minikube”.

Next lets turn on the dashboard (Kubernetes Web UI) to get some more insights of the running single-node Kubernetes Cluster (yes I know there is not much to see.

$ minikube dashboard
...
Opening http://127.0.0.1:52015/api/v1/namespaces/kube-system/services/http:kubernetes-dashboard:/proxy/ in your default browser...
Kubernetes Web UI

Test a container deployment

Now that there is a running Kubernetes Cluster lets see how to deploy some simple (good looking 😎) stuff

$ kubectl create deployment grafana-deployment --image=grafana/grafana
deployment.apps/grafana-deployment created
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
grafana-deployment-6696c557c6-ktx4s 1/1 Running 0 30s
$ kubectl get deployments
NAME READY UP-TO-DATE AVAILABLE AGE
grafana-deployment 1/1 1 1 60s

The sample container (grafana) is already running but only accessible by its internal IP address. To make it accessible from outside it must be exposed through a Kubernetes service.

$ kubectl expose deployment grafana-deployment --type=LoadBalancer --port=3000
service/grafana-deployment exposed
$ kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
grafana-deployment LoadBalancer 10.111.177.171 <pending> 3000:30285/TCP 52s
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 61m

On Minikube the container deployment now simply can be accessed by

$ minikube service grafana-deployment
Opening kubernetes service default/grafana-deployment in default browser…

With the default admin / admin you are able to start exploring Grafana. e.g. Visualizing some metrics of the TestDB.

Grafana Sample Dashboard Panel

Clean up

Do not forget to free resources on your machine

$ minikube stop
Stopping local Kubernetes cluster...
Machine stopped.

Summary

With a handful commands a single-node Kubernetes Cluster is up and running. It is the smallest possible Kubernetes installation (Minikube) . Do not run this in production.

This Post is brought to you by enpit.de from our lovely feelgood-workspace.com. Follow us on instagram.com/enpit for more cool 😎 things.

Further information

enpit-developer-blog

From time to time, we post about the aspects that concern, amaze and suprise our developers during their day-to-day work.

Andreas Koop

Written by

Developer, Architect, Enabler, CEO at enpit.

enpit-developer-blog

From time to time, we post about the aspects that concern, amaze and suprise our developers during their day-to-day work.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade