{"id":54,"date":"2020-06-11T19:37:12","date_gmt":"2020-06-11T18:37:12","guid":{"rendered":"https:\/\/www.slowergram.com\/?p=54"},"modified":"2020-08-19T19:39:33","modified_gmt":"2020-08-19T18:39:33","slug":"kubernetes-cluster-on-a-rpi-part-1","status":"publish","type":"post","link":"https:\/\/www.slowergram.com\/index.php\/2020\/06\/11\/kubernetes-cluster-on-a-rpi-part-1\/","title":{"rendered":"Kubernetes cluster on a RPi (part 1)"},"content":{"rendered":"\n<p>This post, and subsequent ones in the series are going to be a bit of a learning journey, as I am using it to document my learning around kubernetes. Obviously k8s (as the cool kids call it) has been around for a while, 6 year anniversary today, 11th June 2020, and I get the concept of this and containers in theory, but I want to make that a reality, so have decided to build my own implementation without spending a fortune.<\/p>\n\n\n\n<p>As a fan of the Raspberry Pi, this was my go to hardware, so purchased a couple of RPi4 4GB (the 8GB version was released a few days later, doh!).<br>I\u2019ve also wanted to skill up around the networking side of things for a while, as it is a bit of black art, past IP addressing and routing, so bought myself a managed switch, with POE, to power the Pi\u2019s with a POE Hat (when they come back in stock!)<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.slowergram.com\/wp-content\/uploads\/2020\/06\/IMG_20200611_132946084.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p>My basic setup \u2013 no fancy cases (yet)<\/p>\n\n\n\n<p>I\u2019m going to be following&nbsp;<a href=\"https:\/\/opensource.com\/article\/20\/6\/kubernetes-raspberry-pi\" target=\"_blank\" rel=\"noreferrer noopener\">this existing tutorial<\/a>, but with a few changes, as I will be using the \u201cnewly\u201d released 64bit Raspberry Pi OS. I also want to incorporate my slightly different networking setup.<\/p>\n\n\n\n<p>I want to use the wireless adapter on the RPis for management and external access, and I want to use a segregated VLAN on the switch which the physical RPi ethernet ports are plumbed into for the k8s master &lt;\u2013&gt; node communication.<\/p>\n\n\n\n<p>The usual<a href=\"https:\/\/www.slowergram.com\/?p=72\" target=\"_blank\" rel=\"noreferrer noopener\">&nbsp;Pi set up routine<\/a>, such a writing the OS, configuring on the network, updating etc was followed, along with using raspi-config to set a proper hostname on each of the Pis.<\/p>\n\n\n\n<p>I have given my Master and Worker nodes static ethernet port IP\u2019s by editing the \/etc\/dhcpcd.conf file<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>interface eth0\nstatic ip_address=10.10.10.2\/24<\/code><\/pre>\n\n\n\n<p>I found that trying to restart the dhcpcd service caused the Pi to hang, so a reboot was easier to bring up the interface.<\/p>\n\n\n\n<p>The original tutorial didn\u2019t mention disabling swap, so I did that with the command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl stop dphys-swapfile.service\nsudo systemctl disable dphys-swapfile.service<\/code><\/pre>\n\n\n\n<p>After installing docker, and carrying out the remediation to remove the warnings. I still had some warnings relating to cfs support. I found from another post that these can be ignored.<\/p>\n\n\n\n<p>As I want all k8s connectivity to go through the physical ethernet ports, I added a parameter to the kubeadm init command in the tutorial, adding \u2013apiserver-advertise-address:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> sudo kubeadm init --token=${TOKEN} --kubernetes-version=v1.18.2 --pod-network-cidr=10.244.0.0\/16 --apiserver-advertise-address=10.10.10.2\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.slowergram.com\/wp-content\/uploads\/2020\/06\/14.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>After installing flannel as the CNI pod network the master node goes ready<\/p>\n\n\n\n<p>Some of the commands I learnt so far:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>kubectl get nodes (shows all nodes)\nkubectl get deploy --all-namespaces (shows all deployments)\nkubectl get po --all-namespaces (shows all pods)<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.slowergram.com\/wp-content\/uploads\/2020\/06\/15.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>Seeing what pods are running<\/p>\n\n\n\n<p>I could then join my worker node to the cluster, and wait a few seconds for it to become ready.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.slowergram.com\/wp-content\/uploads\/2020\/06\/16.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>Ta-da\u2026a basic Kubernetes cluster running and ready. Next to run something on it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This post, and subsequent ones in the series are going to be a bit of a learning journey, as I am using it to document my learning around kubernetes. Obviously k8s (as the cool kids call it) has been around for a while, 6 year anniversary today, 11th June 2020, <a href=\"https:\/\/www.slowergram.com\/index.php\/2020\/06\/11\/kubernetes-cluster-on-a-rpi-part-1\/\" class=\"btn btn-link continue-link\">Continue Reading<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1],"tags":[10,9,6],"class_list":["post-54","post","type-post","status-publish","format-standard","hentry","category-uncategorised","tag-homelab","tag-k8s","tag-raspberry-pi"],"_links":{"self":[{"href":"https:\/\/www.slowergram.com\/index.php\/wp-json\/wp\/v2\/posts\/54","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.slowergram.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.slowergram.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.slowergram.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.slowergram.com\/index.php\/wp-json\/wp\/v2\/comments?post=54"}],"version-history":[{"count":0,"href":"https:\/\/www.slowergram.com\/index.php\/wp-json\/wp\/v2\/posts\/54\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.slowergram.com\/index.php\/wp-json\/wp\/v2\/media?parent=54"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.slowergram.com\/index.php\/wp-json\/wp\/v2\/categories?post=54"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.slowergram.com\/index.php\/wp-json\/wp\/v2\/tags?post=54"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}