Setting Up Kubernetes On Raspberry Pis - Part 1

This post is focused on preparing the Raspberry Pi's prior to setting up Kubernetes.

Go back to Part 0 or forward to Part 2

Setup Raspberry Pi

Download Raspbian Stretch Lite

Setup SD Cards

  • Burn to SD card using ETCHER

Boot into Pi

  • Boot up the pi.
  • Login:
    • username: pi
    • password: raspberry
  • Change the default password.
    • Open the Raspberry Pi Configuration Tool.
    • Select Change User Password and follow instructions.

Update Hostname

$ sudo raspi-config
  • Open the Raspberry Pi Configuration Tool.
  • Select Network Options > Hostname.
  • Change the hostname (e.g. k8s-master-1)

Enable SSH

$ sudo raspi-config
  • Open the Raspberry Pi Configuration Tool.
  • Select Interfacing Options > SSH.
  • Select Yes.

Restart the Rashberry Pi

$ sudo reboot

Setup a Static IP

We want to setup static IPs so we know what to SSH into. Either set this up on your DHCP server or/and locally on the Pi.

  • Open the DHCP config file:
$ cat >> /etc/dhcpcd.conf
  • Paste the following code:
profile static_eth0
static ip_address=192.168.123.100/24
static routers=192.168.123.1
static domain_name_servers=8.8.8.8

interface eth0
fallback static_eth0

Change static IP address for each Raspberry Pi.

  • Type Ctrl and d.

Install Docker

  • Install the latest version of Docker:
$ curl -sSL get.docker.com | sh && \
  sudo usermod pi -aG docker
  • Add current user to Docker group
$ sudo usermod -aG docker pi

Install Git

  • Install git now on the master if you want to manage yaml files locally:
$ sudo apt-get install git-core

Disable Swap

  • For Kubernetes 1.7 and newer you will get an error if swap space is enabled.

  • Check for entries:

$ sudo swapon --summary
  • Turn off swap:
$ sudo dphys-swapfile swapoff && \
  sudo dphys-swapfile uninstall && \
  sudo update-rc.d dphys-swapfile remove
  • This should now show no entries:
$ sudo swapon --summary

Edit /boot/cmdline.txt

  • Open the cmdline.txt file with an editor:
$ sudo nano /boot/cmdline.txt
  • Add this text at the end of the line, but don't create any new lines:
 cgroup_enable=cpuset cgroup_memory=1

Reboot!

  • Make sure you reboot before proceeding.
$ sudo reboot

Update Your Pi!

  • Lets make sure we're keeping the Pi up to date.
  • First, update your system's package list by entering the following command:
$ sudo apt-get update
  • Next, upgrade all your installed packages to their latest versions with the command:
$ sudo apt-get dist-upgrade

Continue to Part 2

References

Author image
IT guy trying to break the IT stereotype, whilst being addicted to IT stereotypical things.