lauantai 5. maaliskuuta 2016

Raspberry Pi cluster with Kubernetes

I got my first Raspberry Pi as a gift when I was an a Architecting on AWS -course. I’ve been mostly just playing with it, but wanted to use it for something useful. Then I read a blog post about making a cluster out of them and got really interested.

Creating a Raspberry Pi cluster running Kubernetes, the shopping list (Part 1) and Creating a Raspberry Pi cluster running Kubernetes, the installation (Part 2).

I ordered three (so I have one less than in the original recipe) more Raspberrys and started making a cluster. Initially I was thinking about some new database cluster but then changed to scaling Uutispuro, a rss feed title lister that I’ve been making for quite some time now. It uses Mongodb from outside of the Kubernetes.

Making the actual cluster went nicely with the help of the blog posts I followed. I did also setup ntpd and used fi_FI.UTF-8 as a locale for each Pi. Each worker node connected nicely to master, only the last one had a hickup of some kind (it got stuck to “NotReady”) but restart helped.

Docker Hub

It was a surprise for me that I had to use Docker Hub for getting the docker image to Kubernetes. At least it should be possible to use the image straigth away that I'm making.

# build a docker image
docker build -t jelinden/newsfeedreader:0.2 .
# push to docker hub
docker push jelinden/newsfeedreader:0.2
# get the image from docker hub and expose port 1300 and run it in one of the Pi's
kubectl run newsfeedreader --image=docker.io/jelinden/newsfeedreader:0.2 --port=1300
You can view what's going on inside the cluster with
kubectl get events -w
And then you can scale it up to run on three instances
kubectl scale rc newsfeedreader --replicas=3

I couldn’t get Docker Hub to work with a private repo, you can read more about it at Kubernetes PullImageError using Docker Hub with a private image. Luckily for me it doesn't matter if it's public or private.

What next?

Worker node ports are only accessible to master node, so I have to add a load balancer to the setup. Adding a haproxy or nginx is too easy, so I will make my own with Go.

Ei kommentteja:

Lähetä kommentti

Huomaa: vain tämän blogin jäsen voi lisätä kommentin.