[Guide] Setting up visualization for Kubernetes

In our previous post, we described how to install Kubernetes on a Raspberry Pi cluster. A demonstration of such a cluster was given at Devoxx 2015 as seen below

Since we saw the presentation from Devoxx of the Raspberry Pi setup visualized, we knew that we had to try it out.

Google Cloud Platform live k8s visualizer

The visualizer used in the video is called gcp-live-k8s-visualizer. We found a fork of it that worked out of the box, and used that one instead.

The visualization below shows replica scaling and rescheduling, and it is explained in greater detail below the GIF.
First the amount of pods is scaled from 3 replicas to 2 replicas, and then up to 5 replicas. Afterwards a node is disconnected (network failure) and the replication controller handles rescheduling of a pod. In the end the disconnected node is connected again.

The colors indicate status and kind

  • White indicates a healthy node
  • Red indicates a non-healthy node
  • Gray indicates a running pod
  • Yellow indicates a pending pod
  • Green indicates a service
  • Blue indicates a replication controller

Installing on Mac

Macs can use brew or CoreOS guide. The command to install kubectl with brew is shown below.

$ brew install kubernetes-cli

Installing on Linux (Ubuntu)

Installing kubectl on Ubuntu is easy. Download the kubectl with the following command

wget https://storage.googleapis.com/kubernetes-release/release/v1.1.2/bin/linux/amd64/kubectl  

Change permissions and copy to /usr/local/bin/

chmod +x kubectl  
mv kubectl /usr/local/bin/  

Now you should now be ready to use kubectl.

Setting up and running the visualization tool

The following commands will execute the kubectl commands on a local Kubernetes master on IP 192.168.1.51.

$ kubectl config set-cluster cluster51 --server=http://192.168.1.51:8080
$ kubectl config set-context cluster51 --cluster=cluster51
$ kubectl config use-context cluster51

# Test that it is working with
$ kubectl get nodes

For a real-world setup you should take security into consideration as well. This guide shows how to configure certificates in the kubectl configuration.

Afterwards, we need to launch the webserver. Do so by executing the following commands:

$ git clone https://github.com/saturnism/gcp-live-k8s-visualizer.git
$ cd gcp-live-k8s-visualizer
$ kubectl proxy --www=.

Now you should be able to launch your browser and head to localhost:8001/static and see your nodes.

The last step is to set up the labels when you run a new replication controller.
To launch start visualization you need to add the visualize label when you call run, furthermore you can name it with run. The command below starts an busybox testserver (for ARM).

kubectl run busybox --image=hypriot/rpi-busybox-httpd -l visualize=true,run=busybox  

Now you should have a very illustrative representation of your Kubernetes cluster!