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 …
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
- Get the latest image for the HypriotOS for the PI https://github.com/hypriot/image-builder-rpi/releases
- Download Etcher from Etcher.IO, to put the ZIP image onto the micro SD card.
- 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)
What’s k8S ?
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
Success Kubernetes is running
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
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 –
Kubenetes are configured with YAML files. Drop a new YAML file into the manifest directory automatically creates pods.
- GitHub – weaveworks/flux: The GitOps Kubernetes operator
- Helm – The Kubernetes Package Manager
- My Dockercon Hack: LED powered IoT cluster
- Visiting Pimoroni
- Quickstart – Azure Kubernetes cluster for Linux | Microsoft Docs
- GitHub – rootdevelop/rpi-aspnetcore: Raspberry PI docker image for ASP.Net Core
- Penny Pinching in the Cloud: Deploying Containers cheaply to Azure – Scott Hanselman
- Portainer | Simple management UI for Docker
Build .NET Core apps for Raspberry Pi with Docker
- Visual Studio Tools for Docker with ASP.NET Core | Microsoft Docs
- Setup Kubernetes on a Raspberry Pi Cluster easily the official way! · Docker Pirates ARMed with explosive stuff
- GitHub – greensheep/plex-server-docker-rpi: Run Plex server in Docker on a Raspberry Pi
- Introducing Functions as a Service (FaaS)