Skip to content

ifarfan/k3s-on-raspberrypi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

K3S installation on Raspberry Pi cluster

Pre-requisites

  1. Download Raspbian lite, look for most recent OS image –– unzip file

  2. Use balena's Etcher to write the Raspbian image to an SD card; to install it on a Mac via Homebrew:

    $> brew cask install balenaetcher
    
  3. Launch Etcher and,

    • Select the downloaded, unzipped .img file
    • Select the SD card as the target (you already plugged it into your Mac, right?)
    • Click on Flash!
    • If prompted, enter your password to override the contents of the SD card
    • Etcher will automatically eject the SD card
  4. Re-mount the SD card (i.e., eject + reinsert it)

  5. Create /boot/ssh file to allow SSH on RPi

    $> touch /Volumes/boot/ssh
    
  6. Append IP settings to the end of /boot/cmdline.txt to hard-set the static IP config ip=192.168.136.XX::192.168.136.1:255.255.255.0:eth0:false Refer to this page for an explanation + configuration string format

  7. Unmount + eject SD card, pop it into a Raspberry-pi and boot

  8. Repeat the previous 4 steps on each SDs per RPi available

  9. On first boot, login as pi and use raspberry as the default password

    $> ssh pi@192.168.136.33
    
  10. Rejoice + enjoy!

Cluster Specs

Below are listed my cluster's current configuration specs:

Model IP Proc CPU Mem Disk
RPI 3 Model B 192.168.136.30 armv7l 4 1GB 32GB
RPI 3 Model B 192.168.136.31 armv7l 4 1GB 32GB
RPI 3 Model B 192.168.136.32 armv7l 4 1GB 32GB
RPI 3 Model B 192.168.136.33 armv7l 4 1GB 32GB
RPI Model B+ 192.168.136.34 armv6l 1 512MB 8GB

See: Raspberry Pi model comparison

Installation + configuration via Ansible

  1. Check for correct IP settings under hosts.yml, note that the master is tagged as k3s_master and the agents as k3s_agent

  2. Ensure you have passlib installed since we'll be resetting the RPi's passwords

    $> pip3 install passlib
    
  3. Reset pi user's password and add the Ansible ssh key (you'll be prompted for the default password and the ssh key under vars/main.yml > ansible_ssh_key will be added)

    $> ansible-playbook playbooks/reset_pi_password.yml
    
  4. Ensure you can ssh to the RPi cluster, see ~/.ssh/config sample excerpt below:

    Host 192.168.136.3*
         User pi
         IdentityFile ~/.ssh/ansible_rsa
         IdentitiesOnly yes
         PasswordAuthentication no
         StrictHostKeyChecking no
         UserKnownHostsFile=/dev/null
         ControlMaster auto
         ControlPath /tmp/%r@%h:%p
         LogLevel FATAL
    
  5. Configure default RPis host settings (using your ssh key from now on)

    $> ansible-playbook playbooks/configure_host.yml
    
  6. Install k3s on all RPis (1 master + 3 agents)

    $> ansible-playbook playbooks/k3s_install.yml
    

Oh god, why?!?

Kubernetes is all the rage these days but it's bloated as hell! 😱. I've had a small cluster of Raspberry Pis that I've used for all sorts of shenanigans (even trying to install Kubernetes on them 🙈) and ever since I've heard that the Rancher guys managed to slash the bejesus out of k8s it was just a matter of time before these puppies were going to be repurposed (once again!?! 😳).

Performance is great and what better way to get k8s in every IOT device in the world!

Next stop... getting rid of the OS altogether and running bare k3os on these RPis. 😏

Releases

No releases published

Packages

No packages published