kubernetes on a 5-node Raspberry Pi 2 cluster

This post documents my experiences with trying to run kubernetes on a five-node Raspberry Pip 2 cluster.

I started by setting up each of the five Raspberry Pis with Hypriot v1.1.1.

I have internal DNS & DHCP services on my Lab network so I used hardware addresses to ensure each node has a DNS entry and always gets the same IP, as follows:


On each node, I ensured all packages were up-to-date:

apt-get update && apt-get -y upgrade

I used the kubeadm guide for the following steps.

Add a new repo and install various kubernetes commands on all nodes:

curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
cat <<EOF > /etc/apt/sources.list.d/kubernetes.list
deb http://apt.kubernetes.io/ kubernetes-xenial main

apt-get update
apt-get install -y kubelet kubeadm kubectl kubernetes-cni

I designated node01 as the master and ran the following commands on the master only:

Initialise the master:

kubeadm init --pod-network-cidr=

Install flannel networking:

export ARCH=arm
curl -sSL "https://github.com/coreos/flannel/blob/master/Documentation/kube-flannel.yml?raw=true" | sed "s/amd64/${ARCH}/g" | kubectl create -f -

Check everything is running OK:

$ kubectl get pods --all-namespaces
NAMESPACE     NAME                                          READY     STATUS    RESTARTS   AGE
kube-system   dummy-2501624643-8gpcm                        1/1       Running   0          24m
kube-system   etcd-node01.rpi.yo61.net                      1/1       Running   0          23m
kube-system   kube-apiserver-node01.rpi.yo61.net            1/1       Running   0          23m
kube-system   kube-controller-manager-node01.rpi.yo61.net   1/1       Running   0          23m
kube-system   kube-discovery-2202902116-j9zjn               1/1       Running   0          24m
kube-system   kube-dns-2334855451-lu3qh                     3/3       Running   0          22m
kube-system   kube-flannel-ds-p32x1                         2/2       Running   0          15m
kube-system   kube-proxy-28edm                              1/1       Running   0          22m
kube-system   kube-scheduler-node01.rpi.yo61.net            1/1       Running   0          23m

Join the other nodes:

kubeadm join --token=c2a0a6.7dd1d5b1c26795ef

Check they've all joined correctly:

$ kubectl get nodes

NAME                  STATUS    AGE
node01.rpi.yo61.net   Ready     27m
node02.rpi.yo61.net   Ready     45s
node03.rpi.yo61.net   Ready     54s
node04.rpi.yo61.net   Ready     16s
node05.rpi.yo61.net   Ready     25s

Install the dashboard:

export ARCH=arm
curl -sSL "https://rawgit.com/kubernetes/dashboard/master/src/deploy/kubernetes-dashboard.yaml" | sed "s/amd64/${ARCH}/g" | kubectl create -f -

You should now have something like this:

$ kubectl get pods --all-namespaces
NAMESPACE     NAME                                          READY     STATUS    RESTARTS   AGE
kube-system   dummy-2501624643-8gpcm                        1/1       Running   0          1h
kube-system   etcd-node01.rpi.yo61.net                      1/1       Running   0          1h
kube-system   kube-apiserver-node01.rpi.yo61.net            1/1       Running   0          1h
kube-system   kube-controller-manager-node01.rpi.yo61.net   1/1       Running   0          1h
kube-system   kube-discovery-2202902116-j9zjn               1/1       Running   0          1h
kube-system   kube-dns-2334855451-lu3qh                     3/3       Running   0          1h
kube-system   kube-flannel-ds-2g1tr                         2/2       Running   0          1h
kube-system   kube-flannel-ds-a2v7q                         2/2       Running   0          1h
kube-system   kube-flannel-ds-iqrs2                         2/2       Running   0          1h
kube-system   kube-flannel-ds-p32x1                         2/2       Running   0          1h
kube-system   kube-flannel-ds-qhfvc                         2/2       Running   0          1h
kube-system   kube-proxy-0agjm                              1/1       Running   0          1h
kube-system   kube-proxy-28edm                              1/1       Running   0          1h
kube-system   kube-proxy-3w6e8                              1/1       Running   0          1h
kube-system   kube-proxy-fgxxp                              1/1       Running   0          1h
kube-system   kube-proxy-ypzyd                              1/1       Running   0          1h
kube-system   kube-scheduler-node01.rpi.yo61.net            1/1       Running   0          1h
kube-system   kubernetes-dashboard-3507263287-so0mw         1/1       Running   0          1h

To be continued…

Setting Up a Raspberry Pi without a Monitor or Keyboard

There are a lot of how-to’s online describing ways to set up a Raspberry Pi without a monitor or keyboard, but none of them are simple or straightforward. This will be.

I’m going to walk through how to do this on a Mac, but something like this should also work on Windows using internet connection sharing and the Event Viewer.

1. Connect an unpowered raspberry pi to your Mac via an ethernet cable.

Unpowered Raspberry Pi

2. Enable internet connection sharing.

  • Open “Sharing” in system preferences. (You can just type “Sharing” into spotlight.)
  • Click on “Internet sharing.”
  • In the “To computers using:” box, select the adapter you have the ethernet cable from the Raspberry Pi connected to. In my case this is “Thunderbolt ethernet.” Beware: if you are using a USB ethernet adapter, the generically named “USB Ethernet” is probably not what you want. Your USB adapter is will probably have a different name in this list.
  • Check the “On” checkbox for “Internet sharing.”

Screen Shot 2015-06-17 at 4.30.56 PM

3. Open Console.

You can just type “Console” into spotlight.

Console in spotlight

4. Power-On your Raspberry Pi.

Powered Raspberry Pi

5. Watch Console output for DHCP ACK.

DHCP output with IP address in Console

6. Log on to your Pi.

You can now log onto your Raspberry Pi via ssh using the ip address acquired in the previous step:
Screen Shot 2015-06-17 at 4.32.58 PM

The default user for the raspbian image is pi, the password is raspberry.

And there you go!

This method also works for other headless computers that use DHCP and start an ssh server by default. I’ve used it for Raspberry Pi’s, Odroids, and other weird things.

The post Setting Up a Raspberry Pi without a Monitor or Keyboard appeared first on Atomic Spin.

“Have you ever thought about learning to program?”

"A student at Joan of Arc Junior High masters a Logo procedure."

“Have you ever thought about learning to program?”

That’s the first sentence in a recent blog post by the Swedish game company Mojang, creator of the hit game, Minecraft. The post describes their recent and upcoming work to create a virtual environment where beginners can explore the power of programming on a low-cost, open platform. While this may not seem interesting to anyone unfamiliar with Minecraft or the Raspberry Pi, the combination with early programming learning is a big deal to me. Here’s why. 

Teaching Programming Is Playing the Long Game

Part of my job is to hire people who will raise the average at Atomic Object. Even when we aren’t actively hiring (we are), we’re thinking of ways to plant seeds that will eventually improve our professional community and our own hiring prospects. An important component of that is investing in young programmers. That’s why we run BitCamp and support local FIRST robotics teams.

I’m also a father. Ushering my kids into a world of ubiquitous computing is an interesting and reflective challenge. Even if they end up nowhere near computing career-wise, at least they will have a better understanding of what Dad and his friends do all day at work, and they won’t be dumbstruck by their smart phones.

Early Programming Can Be Simplistic or Dull

Projects like Scratch or Alice are amazing efforts, but they were created by educators and students with learning in mind. While there’s nothing wrong with that, I feel that there’s too big of a disconnect between animating a 2D sprite of a cartoon cat and the average experience an 8-year-old would have playing Angry Birds or Minecraft. To me, they seem either too hermetic or too broad to capture young attention before learning kicks in.

Minecraft Is Fun and Engrossing

As a simplified “model” of the real world, Minecraft is instantly more accessible to youth than a blank canvas and a text editor — or even a drag-n-drop code toolbox. Kids love it. Don’t take my word for it, just look at the average Minecon attendee. The game itself allows primitive programming via its redstone circuits, encouraging the sort of low-level understanding of digital electronics that most kids won’t even recognize as learning about how computers work.

Dig deeper and you find that Minecraft has an API or two, and even high-level interfaces like the amazingly cool Purugin. Using JRuby, Purugin allows players to execute LOGO-like programs in-game and see results instantly in an immersive and collaborative environment. Again, I’m not the only one to see this: Minecraft is already seen in education, replacing icons like Oregon Trail.

Logo vs. Minecraft

Early Programming Can Be Expensive

As a kid, I could learn to code using cheap, decade-old hardware without being too far behind. Now, the same opportunity seems to cost a lot: a few hundred dollars for a tablet or reasonably useful Craigslist computer. Arduino and the maker movement have provided a tantalizingly low barrier to entry, but microcontroller programming is probably a skill for older kids, compared to the ease of early BASIC or LOGO environments. (Side note: why did all the early languages have to raise their voice?)

A Raspberry Pi Is Cheap and Capable

Enter the Raspberry Pi Foundation. Their single-board computer is cheap and even targeted at learning. It plugs into any modern monitor or TV and can easily be connected to the internet. There are already examples of it being set to this purpose, both in primary schools and universities.

Two Great Tastes…

So back to this announcement from Mojang that they’ve been working on a special Raspberry Pi port of Minecraft with the specific intent of teaching programming to kids:

You can start by building structures in the traditional Minecraft way, but once you’ve got to grips with the in-game features, there’s opportunity to break open the code and use programming language to manipulate things in the game world. You’ll be learning new skills through Minecraft.

So, a cheap platform and an exciting gateway drug of an environment. I predict a big uptake on this one, and I’m very excited to hear the details as they develop.

Minecraft on the Raspberry Pi

Maybe You Already Knew All of This

Ok, so you’ve already written a Minecraft plugin or two, and one of your Raspi’s is currently serving up a Python web app remote control for your Christmas lights. Well, how about some ideas to apply when Mojang releases their port?

  • Make scripts to build entire buildings procedurally, using composition, or even L-systems.
  • Make 3D interactive versions of existing programming games such as Robocode or Corewar.
  • Make a “live” version of Light Bot.
  • Make a “rewind button” for use in otherwise-normal Minecraft play that works like a time-warp undo.

Light Bot

Or Maybe You’re Thinking Bigger

Finally, if you’d like to step back a little from my enthusiasm on this topic, here’s a historic, moving opinion on technocentrism and the future of education by Seymour Papert, inventor of LEGO Mindstorms.