Kubernetes on Raspberry Pi

WIP — unplugged Pi case for a cattle cluster

Hello K3s

curl -sfL https://get.k3s.io | sh -

Pre-requisites:

Device Prep

Imaging the card

dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=PARTUUID=7ee80803-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=PARTUUID=7ee80803-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait cgroup_memory=1 cgroup_enable=memory quiet

Setup Access

{
ssid: <a_network_ssid>
psk: <a_network_password>
}
### You should not have to change the lines below #####################country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
cd /mnt/boot
touch ssh

First Boot

[Unit]
Description=Copy user (/etc/)hostname
ConditionPathExists=/boot/hostname
Before=dhcpcd.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/mv /boot/hostname /etc/hostname
ExecStartPost=/bin/chmod 644 /etc/hostname
ExecStartPost=/bin/hostname --file /etc/hostname
[Install]
WantedBy=multi-user.target
k3s-base
curl -L -O https://github.com/ibuildthecloud/k3s/releases/download/v0.1.0-rc3/k3s-armhfchmod 755 k3s-armhf
sudo bash -c \'wpa_passphrase MYSSID passphrase > /boot/wpa_supplicant.conf' 
network={
ssid="ssid"
#psk="passphrase" <--- DELETE THIS LINE
psk=2b1d17284c5410ee5eaae7151290e9744af2182b0eb8af20dd4ebb415928f726
}
...

Validate Image Content

...
hostname
wpa_supplicant.conf
...
k3s_armhf
...
raspberrypi-hostname.service
...
...
lrwxrwxrwx 1 root root 48 Feb 8 16:13 raspberrypi-hostname.service -> /lib/systemd/system/raspberrypi-hostname.service
...

Master the image

Disk /dev/sda: 29.8 GiB, 32010928128 bytes, 62521344 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x7ee80803
Device Boot Start End Sectors Size Id Type
/dev/sda1 8192 98045 89854 43.9M c W95 FAT32 (LBA)
/dev/sda2 98304 3645439 3547136 1.7G 83 Linux
Disk k3s-base.img: 1.8 GiB, 1866465280 bytes, 3645440 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x7ee80803
Device Boot Start End Sectors Size Id Type
k3s-base.img1 8192 98045 89854 43.9M c W95 FAT32 (LBA)
k3s-base.img2 98304 3645439 3547136 1.7G 83 Linux
sudo raspi-config
Select Advanced Options
Select Expand Filesystem
Confirmation Dialog
sudo shutdown -h now

Device Use

Boot Up

ssh pi@k3s-base.local
sudo ./k3s-armhf server
sudo ./k3s-armhf kubectl get pods --all-namespaces
sudo ./k3s-armhf kubectl apply -f some-deployment.yml
...

Celebrate!

Additional notes for using fdisk on the Mac

Disk: /dev/disk2        geometry: 966/255/63 [15523840 sectors]
Signature: 0xAA55
Starting Ending
#: id cyl hd sec - cyl hd sec [ start - size]
------------------------------------------------------------------------
1: 0C 0 130 3 - 6 26 18 [ 8192 - 89854] Win95 FAT32L
2: 83 6 30 25 - 226 234 8 [ 98304 - 3547136] Linux files*
3: 00 0 0 0 - 0 0 0 [ 0 - 0] unused
4: 00 0 0 0 - 0 0 0 [ 0 - 0] unused
echo "$((98304+3547136))"
Device Block Size: 512 Bytes

Additional Security Suggestions

maker, dad, software mechanic

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store