The Journey

This is my journey into the realm of Docker, Kubenetes, and OpenFaaS. This tutorial or least my notes here should help you setup everything from scatch. I’ll cover OpenFaaS in my next blog post …

Distributed Computing

Certainly distributed computing has always being a thing out of reach for most hobbyists and home users due to a considerable amount of expense and sheer volume space required for such a giant size machine.

So along comes the humble Raspberry PI while at the same time parallel development of Docker is happening. It seems clear to most that both shall meet and form a kind of synergy.

In recent years, Docker has matured to the point of an industry standard. What still remains at heart is an exciting innovative community that drives the spirit behind Docker. It’s still very much in the sphere of developers. More technologies are seeing that Docker is something that allows folks to forget about hardware platforms and OS and all that configuration administration network-y stuff of the 90’s. Don’t get me wrong it’s still there but Docker offers us the ability to focus on applications that all scalable, robust and reliable.

One of those interesting pieces of Technology within the Docker world is Google’s Open Source Kubenetes. This allows managing and assigning resources etc – otherwise known professionally as ‘orchestrating’ Docker containers.

Build the Raspberry PI Cluster

I had four Raspberry Pi’s v3 for some time and wish to create a Docker cluster either using Swarm or Kubenetes. I took my trusty bike to my local electronics store to get 16 metal barrel raisers and 4 small metal barrel raisers to stack my Raspberry Pies.

The Raspberry PI’s on my desk looks pretty awesome – me thinks!

Image is everything!

Yes, image is everything! I choose to use HypriotOS which is specific for little raspberries who wish to host Docker containers. It’s lightweight and made for ARM. There are actually plenty of Docker images for various Hypriot OS combinations on Dockerhub. However I’m interested in running Kubernetes (K8S) and OpenFaaS.

Instructions to Flash

To get the Raspberry PI up and running a micro SD card is required for the OS. An 8Gb card is a good start.

  1. Get the latest image for the HypriotOS for the PI https://github.com/hypriot/image-builder-rpi/releases
  2. Download Etcher from Etcher.IO, to put the ZIP image onto the micro SD card.
  3. Once the Raspberry is booted with the Hypriot OS, login with the default hypriotOS password and run Raspi-Config and choose the advance options to expand the SD card storage. (TIP: You can update and rename the hostname within this utility too)
    sudo raspi-config

    Raspi-Config expand sd space
    Raspi-Config expand sd space

Kubernetes

What’s k8S ?

https://www.youtube.com/watch?v=PH-2FfFD2PU

My preference is to use Kubenetes to do all the cluster stuff or as they say ‘orchestral’ Docker containers to be exact. Of Docker Swarm can also be used along side OpenFaaS

Add repo lists & install kubeadm

You now have two new commands installed:

  • kubeadm – used to create new clusters or join an existing one
  • kubectl – the CLI administration tool for Kubernetes

Modify 10-kubeadm.conf on the master node only

$ sudo sed -i '/KUBELET_NETWORK_ARGS=/d' /etc/systemd/system/kubelet.service.d/10-kubeadm.conf

Initialize your master node:

$ sudo kubeadm init --token-ttl=0 --pod-network-cidr=10.244.0.0/16
Initialise Kubelet
Initialise Kubelet

Success Kubernetes is running

Your Kubernetes master has initialized successfully!
Your Kubernetes master has initialized successfully!

Setup the Cluster

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

Now check the status of Pod

kubectl get pods --namespace=kube-system
kubectl get pods –namespace=kube-system

Install Flannel network driver

curl -sSL https://rawgit.com/coreos/flannel/v0.9.1/Documentation/kube-flannel.yml | sed “s/amd64/arm/g” | kubectl create -f –

Fannel
Fannel

Kubenetes Resources

Kubenetes Manfests

Kubenetes are configured with YAML files. Drop a new YAML file into the manifest directory automatically creates pods.

“/etc/kubernetes/manifests/etcd.yaml”

OpenFaas

Link Dump

August 1, 2018