[Guide] Installing Kubernetes Dashboard on HypriotOS

Kubernetes dashboard is to replace kube-ui when the project is ready for production. Unfortunately the kubernetes for Raspberry project already excluded kube-ui (for more information see the github issue). However luckily it is possible to install the brand new Kubernetes dashboard on the Raspberry Pi instead. This guide will take you through the steps on the HypriotOS distribution. At the time of writing the dashboard is with limited functionality, and some links are still not working properly.

Prerequistites

  • Docker (1.3+)
  • go (1.5+)
  • nodejs (4.2.2+)
  • npm (1.3+)
  • java (7+)
  • gulp (3.9+)
  • Kubernetes (1.1.2+ - as described in a previous post)

Getting started

Before installing any of the above mentioned prerequistites, make sure your master node is up to date, and ready to GO!

$ sudo apt-get update && sudo apt-get upgrade

Installing python

$ sudo apt-get install python
$ sudo apt-get install python2

Installing GCC

$ sudo apt-get install gcc-4.8 g++-4.8
$ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50

Verify

$ sudo gcc --version
gcc (Raspbian 4.8.4-1) 4.8.4  
Copyright (C) 2013 Free Software Foundation, Inc.  
This is free software; see the source for copying conditions.  There is NO  
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  

Installing make

$ sudo apt-get install make

Installing Java

sudo apt-get install openjdk-7-jdk  

Verify

$ java -version
java version "1.7.0_91"  
OpenJDK Runtime Environment (IcedTea 2.6.3) (7u91-2.6.3-1~deb8u1+rpi1)  
OpenJDK Zero VM (build 24.91-b01, mixed mode)  

Installing Node.js

$ wget https://nodejs.org/dist/v4.2.2/node-v4.2.2.tar.gz
$ tar -xzf node-v4.2.2.tar.gz
$ cd node-v4.2.2
$ ./configure
$ make
$ sudo make install

Be aware, this will take some time to finish! When the installation is finished. Verify that node and npm is installed correctly

$ node -v
v4.2.2  
$ npm -v
2.14.7  

Installing gulp

We need gulp to serve the dashboard, install it as follows

$ npm install -g gulp

Local in the dashboard folder

$ npm install gulp

Verify that gulp is correctly installed

$ gulp -v
[09:51:28] CLI version 3.9.0

Installing GO

We need Go 1.5 or later, but at the moment we haven't been able to locate a version for the Raspberry Pi 2, and we therefore have to use an older version and build 1.5 ourselves.

Clone the GO repository

$ git clone https://go.googlesource.com/go

Change directory to GO.

$ cd go

Check out Go1.4.3

$ git checkout go1.4.3

Change directory to 'src'

$ cd src

Run the bash script to build Go. (This takes some time, go out an make yourself a nice cup of coffee).

$ ./all.bash

When the bash script is finished, we need to update the $PATH.

$ nano /root/.bashrc

Input the following to lines in the bottom of the file and save:

export GOROOT=$HOME/go  
export PATH=$PATH:$GOROOT/bin  

To check if the of GO installation succeeded you can source the .bashrc and test go version.

$ source /root/.bashrc
$ go version
go version go1.4.3 linux/arm  

To check if GO is working correctly, we create a small "Hello World" script

$ nano helloworld.go

paste the following into the file and save:

package main

import "fmt"

func main() {  
        fmt.Printf("hello, world\n")
}

run the helloworld.go application and verify that you see the output below.

$ go run helloworld.go
hello, world  

Now we have GO 1.4.3 up and running, but we need to upgrade to Go 1.5 for the Kubernetes Dashboard.

Update to Go 1.5

There are different ways to do this. We tried following this guide by The University of Glasgow's Raspberry Pi project, but unfortunately ran into problems. Instead we found this guide by Denis Papathanasiou.

First, make sure you have a working version of bzip2.

$ apt-get install bzip2

Next go to your home directory:

$ cd $HOME 

Download the unofficial tarball:

$ wget http://rpi-cloud.com/files/go.1.5.tar.bz2

Move the downloaded file to /usr/local

$ sudo mv go.1.5.tar.bz2 /usr/local

Change directory

$ cd /usr/local

Extract the tarball

$ sudo tar jxf go.1.5.tar.bz2

Change permissions

$ sudo chown -R root:staff /usr/local/go

Lastly, delete the tarball

$ sudo rm go.1.5.tar.bz2

The last thing we need to do is to change our GOROOT in the .bashrc file. Go back to the home directory

$ cd $HOME

and open .bashrc

$ nano .bashrc

Edit the line we inserted earlier to the following:

export GOROOT=/usr/local/go  
export PATH=$PATH:$GOROOT/bin  

Verify that the Go 1.5 is now running

$ go version
go version go1.5 linux/arm  

Installing Kubernetes Dashboard

Now that everything is installed, we can begin building the dashboard.

git clone https://github.com/kubernetes/dashboard.git  

Change the directory

cd dashboard  

We also need to install bower, type in the following

npm install -g bower  

Now we need to install the dashboards dependencies.

npm install  

To run the dashboard, serve it using gulp as follows

$ gulp serve
[11:19:12] Requiring external module babel-core/register
[11:20:50] Using gulpfile ~/dashboard/gulpfile.babel.js
[11:20:50] Starting 'package-backend-source'...
[11:20:50] Starting 'kill-backend'...
[11:20:50] Finished 'kill-backend' after 1.39 ms
[11:20:50] Starting 'scripts'...
[11:20:53] Starting 'styles'...
[11:21:41] Finished 'scripts' after 50 s
[11:21:42] Finished 'package-backend-source' after 52 s
[11:21:42] Starting 'backend'...
[11:21:43] Finished 'styles' after 49 s
[11:21:43] Starting 'index'...
[11:21:44] Finished 'index' after 1.43 s
[11:21:44] Starting 'watch'...
[11:21:45] Finished 'watch' after 1.41 s
[11:23:27] Finished 'backend' after 1.73 min
[11:23:27] Starting 'spawn-backend'...
[11:23:27] Finished 'spawn-backend' after 88 ms
[11:23:27] Starting 'serve'...
2016/02/01 11:23:27 Starting HTTP server on port 9091  
2016/02/01 11:23:27 Creating API client for http://localhost:8080  
2016/02/01 11:23:27 Creating Heapster REST client for http://localhost:8082  
[11:23:27] Finished 'serve' after 312 ms
[BS] [BrowserSync SPA] Running...
[BS] Access URLs:
 --------------------------------------
       Local: http://localhost:9090/
    External: http://192.168.1.21:9090/
 --------------------------------------
          UI: http://localhost:3001
 UI External: http://192.168.1.21:3001
 --------------------------------------
[BS] Serving files from: /root/dashboard/.tmp/serve
[BS] Serving files from: /root/dashboard/src/app/frontend
[BS] Serving files from: /root/dashboard/src/app

We had some problems in the first try. However after cleaning npm and bower cache and running npm install again, it finally worked. If you run into problems with missing dependencies install them with npm install --save-dev <dependency> and try serving with gulp serve again.