본문 바로가기
Hobby

k3s Basic Setup

by Calvin H. 2022. 6. 1.

Introduction

After finally receiving my last raspberry pi 4 8gb, I setup a k3s cluster.

To those reading this post, they may think that it's a great feat or something magical. But no, unfortunately or fortunately, there are smart people out there who already coded repositories for people like me.

Steps

All you really need to do are small steps, literally no coding at all.

  1. First and foremost you will need some raspberry pis to run your cluster. I have 3 raspberry pi 4 and 1 raspberry pi 3. And my 8gb pi serves as the main node while the others are worker nodes.

  2. Fork and clone the repository https://github.com/k3s-io/k3s-ansible which is basically an ansible playbook to setup the raspberry pis and get them ready to become a single cluster.

  3. Fork and clone the repository https://github.com/carlosedp/cluster-monitoring if you need some initial pods running to test your cluster (completely optional but fun)

  4. Burn the right OS images to each raspberry (I used a 64 bit Ubuntu Server). You can do this easier if you simply use the raspberry image utility.

  5. Connect to each raspberry pi and make sure they are working. Also modify each pi to have distinct hostnames. Hostname file can be edited with sudo vi /etc/hostname. If you need, add ssh to ufw by sudo ufw allow ssh.

  6. After burning each image, setup the ssh from the computer you'll be working on (not the raspberry pis but the computer you will run the ansible playbooks and kubectl).

    • To help with these steps, if you don't have an ssh file simply generate one like this ssh-keygen -t rsa this will generate an ssh file id_rsa and id_rsa.pub in your .ssh folder.

    • To copy the ssh files, you can run ssh-copy-id -i <location-of-ssh-file> <username-of-raspberry>@<ip-of-raspberry> (you will probably have to enter the password for the user you setup for each raspberry pi)

    • And finally check to see if you can access your raspberry pis without passwords ssh <username-of-raspberry>@<ip-of-raspberry>

  7. After making sure each raspberry pis can be connected with ssh, go to your k3s-ansible github repository cloned folder and follow the instructions in README.md.

    • It has detailed instructions on how to copy the inventory folder and modify the hosts.ini file and apply them all by running the playbook.
  8. That's it! Check kubectl get nodes -n monitoring (change monitoring to other name if you edited it) to see your nodes in action.

  9. If you need some initial pods running go to the cluster-monitoring github repository and follow the Readme.md file. After that you can run kubectl get ingress -n monitoring to get links to the sites your k3s cluster is hosting!

'Hobby' 카테고리의 다른 글

라즈베리파이 클러스터 구축  (2) 2023.10.04
Basic k3s with Raspberry Pi  (0) 2022.06.01
Raspberry And Hadoop  (0) 2022.05.31