Introduction
As my crawling project with scrapy is progressing, I need to start processing the data that streams from the crawler. Since scrapy can work in an asynchronous manner, a message queue to receive the items should be good for me.
Thus, for the storage a document database is probably going to be used such as mongodb. And for the message processing, redis or rabbitmq seemed like a good idea.
Setting up K3S
First, in order to set up all these different components, such as the crawler server, message queue server, database servers etc., just random free-tier cloud services wasn't going to cut it. Besides, AWS on a personal project didn't seem likely and this project is trying to use open source projects mainly.
Well, there were 3 raspberry pis that weren't in use after the Hadoop project. So that's where the project took off to another level. I had to reset the images and OS to ubuntu servers from raspberry OS with Hadoop setup.
After that was done, now it was time to properly setup my working station. My laptop is a Razer Blade 14 inch 2021, 3070. It's main purpose being playing Apex Legends and other Steam games, I had to install a dual boot system with Manjaro. Ubuntu, Arch, Debian were also other considerations along with Pop OS. But after some tinkering with Debian and my frustration from its stability but lack of latest updates (got tired with my laptop settings) Manjaro with its nice green theme seemed to do the job. Besides, I'm currently writing this post on Manjaro and it's quite OK except for the fact that the HDMI support for both internal and dedicated GPU doesn't seem to work. And audio still needs some tweaking...
Youtube - Jeff Gerling
Personally, there is a person I take advice from for raspberry adventures and projects. Jeff Gerling has some nice sets of vides with good explanations and actual series that are helpful. His videos are on Youtube and has done quite a good job with a number of raspberry pi projects. He introduces the raspberry compute modules and PoE hats etc. And has different configurations and fun projects like running Minecraft server.
Although made last year, his video on Raspberry Pi Cluster Ep 3 is really good. Actually it's a series and quite helpful.
SSH Key and Copying them Over
To enable ssh keys and not passwords (for 'better' security), it's not that complicated. You need a file that basically tells each other that they are friends.
To generate this file, you can execute
$ ssh-keygen -t rsa
rsa is the encryption method. There are different methods and other options as well so be sure to check them out.
Then, copy them over to individual servers with
$ ssh-copy-id -i <path to generated file> <username>@<host of server>
An example could be
$ ssh-copy-id -i ~/.ssh/id_rsa ubuntu@192.168.0.62
After that, check to make sure it works by simply
$ ssh <username>@<host of server>
or
$ ssh 'ubuntu@192.168.0.62'
Next steps
Unfortunately, rancher's repository containing Ansible playbooks introduced in Jeff Gerling's video is nowhere to be seen now. So it means building a K3S cluster from scratch.
That's what I'm currently doing. Mainly getting reference from the official site with its Quick Start Guide.
Progress and successful first k3s setup
After some tinkering and following some instructions, I managed to hook up my 3 raspberry pis to one k3s cluster. The repository I used for setting up the k3s environment was from https://github.com/k3s-io/k3s-ansible. Where the author has set up ansible playbooks for easy installation and preparation.
Then I followed Geerling and installed a monitoring cluster with https://github.com/carlosedp/cluster-monitoring. Thanks calosedp really for setting up a monitoring cluster with experimental grafana and etc. for ARM64 architectures... really appreciate it.
And that was it! Well, I did have some trouble with pods going down and two nodes being 'NotReady' state.
But did some debugging and restarting the nodes.
For debugging, you can use
$ kubectl describe <node name>
if you need help with node names use this command
$ kubectl get nodes -n <name of cluster>
For me, it was some address was already in use. I tried some different things like exiting the process, firewalls etc. But after a hard reset, it seemed to work.
Conclusion
Kubernetes is a great piece of technology I guess. If the concept is well understood and used wisely with proper monitoring and such, I believe that although it may not be a silver bullet, it is quite a feat. Running a cluster with raspberry pis? Seriously, who would have thought. Anyways, the next step is to now build my own containers for my crawler server and get into the messy parts now.
'Hobby' 카테고리의 다른 글
라즈베리파이 클러스터 구축 (2) | 2023.10.04 |
---|---|
k3s Basic Setup (0) | 2022.06.01 |
Raspberry And Hadoop (0) | 2022.05.31 |