Validate the Kubernetes node by running kubectl get nodes Get kube config from master and set KUBECONFIG mkdir -p ~/.kube & scp ~/.kube/config Start provisioning of the cluster using the following command ansible-playbook site.yml -i inventory/raspberry-pi/hosts.ini ⚠️ Alternatively, hostname can also be changed manually by ssh’ing into each Pis and editing hostnames in /etc/hostname and /etc/hosts then issuing reboot command ⚠️Ĭd into the clonned k3 ansible repository cd k3s-ansible/ Rpi-k3/configure/03-change-hostname.yml \
Update the hostnames of Raspberry Pis by running below playbook ansible-playbook -e 'reboot=True' \ ⚠️ Alternatively, RSA key can be copied manually by running following command for each Pi ⚠️ cat /home/ubuntu/.ssh/id_rsa.pub | ssh 'mkdir -p ~/.ssh & chmod 700 ~/.ssh & cat > ~/.ssh/authorized_keys & chmod 600 ~/.ssh/authorized_keys' ⚠️ Alternatively, RSA key can be generated manually by running following command ⚠️ ssh-keygen -t rsaĬat /home/ubuntu/.ssh/id_rsa.pub > ~/.ssh/authorized_keysĬopy RSA keys to all Raspberry Pis by running following playbook export ANSIBLE_HOST_KEY_CHECKING=FalseĪnsible-playbook rpi-k3/configure/02-copy-rsa.yml -i rpi-k3/configure/hosts.ini -ask-pass Generate RSA key by running following playbook ansible-playbook rpi-k3/configure/01-generate-rsa.yml Generate RSA key and setup passwordless loginĬd into the clonned ansible config repository cd kubernetes-examples/ Prepare playbooksĬd into the clonned ansible config repository cd kubernetes-examples/rpi-k3/configure/Įdit hosts.ini with the IP addresses gathered above and a user friendly host name which you would like to set for the Raspberry Pis in below format.Įdit inventory/raspberry-pi/group_vars/all.yml to set ansible_user to ubuntu Its advisable to reserve the IP address for all Raspberry Pis in the router setting so that the IP addresses won’t change in future with restarts. Identify the IP address of all Raspberry Pis using nmap command nmap -sn 192.168.1.0/24 OR from the routers admin console. Validate ansible by running ansible -version SSH into the container by running docker exec -it kube-tools /bin/bash Validate the container by running docker ps Start kube-tools container by running docker-compose up -d This directory contains Dockerfile and docker-compose.yml to bring up a docker container with ansible. Open a new terminal and cd into kubernetes-examples/kube-tools directory.
? Ansible Playbook - Pi Config Prerequisiteĭownload and install docker for your platform. Please clone below repositories to get started We will use the official ansible template from k3 and few additional ansible playbooks to install and configure k3. Insert SD card into Raspberry Pi’s SD slot and power on the devices Insert SD card into your machine and flash it using Etcher to install Ubuntu for Raspberry Pi Safely attach the Raspberry Pi to the case and connect the power supply and ethernet cablesĪttach the network switch, router and power supply to the case using double sided tapes (optional)ĭownload and install Etcher in your machine Install the fan by connecting RED wire to second pin and BLACK wire to third pin in top row from left side Install heat sinks on CPU, RAM and USB controller chip Unbox the Raspberry Pi and all accessories
If you are looking for a newer model then go for a 8 port switch and the latest Wireless N Nano Router. Wireless router and network switch used here are outdated models, this is because I resused something which I already had available. Wireless router is optional to make the cluster portable. TP-Link 5 Port Gigabit Ethernet Network Switch List of required hardware components: Hardware TypeĪnker PowerPort 6 (60W 6-Port USB Charging Hub)
K3s is a fully compliant light weight Kubernetes distribution. Docker, Ansible, k3s and Raspberry Pi 4 (8GB) version were used for this setup.
In this article we will see how to install and configure Kubernetes cluster in Raspberry Pi. Generate RSA key and setup passwordless login.