{"id":26351600,"url":"https://github.com/barnes-c/infrastructure","last_synced_at":"2025-03-16T10:33:29.551Z","repository":{"id":282589217,"uuid":"483388404","full_name":"barnes-c/infrastructure","owner":"barnes-c","description":"Repository for my home lab","archived":false,"fork":false,"pushed_at":"2025-03-15T15:51:08.000Z","size":18532,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-15T16:34:59.898Z","etag":null,"topics":["argocd","gitops"],"latest_commit_sha":null,"homepage":"https://barnes.biz","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/barnes-c.png","metadata":{"files":{"readme":"ReadMe.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-19T19:49:34.000Z","updated_at":"2025-03-15T15:51:12.000Z","dependencies_parsed_at":"2025-03-15T19:31:47.284Z","dependency_job_id":null,"html_url":"https://github.com/barnes-c/infrastructure","commit_stats":null,"previous_names":["barnes-c/infrastructure"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barnes-c%2Finfrastructure","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barnes-c%2Finfrastructure/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barnes-c%2Finfrastructure/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barnes-c%2Finfrastructure/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/barnes-c","download_url":"https://codeload.github.com/barnes-c/infrastructure/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243858888,"owners_count":20359257,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["argocd","gitops"],"created_at":"2025-03-16T10:33:27.059Z","updated_at":"2025-03-16T10:33:29.530Z","avatar_url":"https://github.com/barnes-c.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Raspberry Pi - Master/Worker Setup DEPRECATED\n\nFist of all, we need to install and configure **Raspbian Linux Operating System** on each node of the future Kubernetes cluster. Our goal is it to build an architecture that looks something like this.\n\nWe are adding an SSD because Micro SD cards are not reliable and the bunch of Read/Write Requests from Kubernetes would pretty quick destroy a Micro SD card. We are using a Portable SSD connected to the master node and exposed to the worker via NFS to store the volume data.\n\n![Architecture](/assets/architecture.jpeg)\n\n## OS Configuration\n\nWe are using Raspberry Pi OS Lite (formerly Raspbian) for all of the RaspberryPi’s. In the RaspberryPi Imager software you can enable SSH and change the hostname, thus you can make the setup without a screen. Make sure you add `arm_64bit=1` to the end of `/boot/config.txt`.\n\n### Setting up a static IP\n\nBy default, the router assigns an arbitrary IP address to the device which means it is highly possible that the router will assign a new different IP address after a reboot. To avoid to recheck our router, it is possible to assign a static IP to the machine.\n\nEdit the file `/etc/dhcpcd.conf` and add the four lines below:\n\n```bash\ninterface eth0\nstatic ip_address=192.168.0.\u003cX\u003e/24\nstatic routers=192.168.0.1\nstatic domain_name_servers=1.1.1.1\n```\n\nor this if you are using Wi-fi\n\n```bash\ninterface wlan0\nstatic ip_address=192.168.0.\u003cX\u003e/24\nstatic routers=192.168.0.1\nstatic domain_name_servers=1.1.1.1\n```\n\n### Enable container features\n\nWe need to enable *container features* in the kernel in order to run containers.\n\nEdit the file `/boot/cmdline.txt` and add the following properties at the end of the line:\n\n```bash\ncgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory\n```\n\n## Enabling legacy iptables on Raspberry Pi OS\n\nRaspberry Pi OS defaults to using **`nftables`** instead of **`iptables`**.  **K3S** networking features require **`iptables`** and do not work with **`nftables`**. Follow the steps below to switch configure **Buster** to use **`legacy iptables`**:\n\n```bash\nsudo apt-get install -y iptables arptables ebtables\nsudo update-alternatives --set iptables /usr/sbin/iptables-legacy\nsudo update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy\n```\n\n### Configure the SSD disk share\n\nAs explained during the introduction, I made the choice to connect a portable SSD to the Master node and gave access via NFS to each worker.\n\n**====== Master node only - Mount the disk and expose a NFS share ======**\n\n**Find the disk name (drive)**\n\nRun the command `fdisk -l` to list all the connected disks to the system (includes the RAM) and try to identify the SSD. Output:\n\n```bash\nDisk /dev/ram0: 4 MiB, 4194304bytes, 8192 sectors\nUnits: sectors of 1 * 512 = 512bytes\nSector size (logical/physical): 512bytes / 4096bytes\nI/O size (minimum/optimal): 4096bytes / 4096bytes\n(...)\nDisk /dev/sda: 465.76 GiB, 500107862016 bytes, 976773168 sectors\nDisk model: PSSD T7\nUnits: sectors of 1 * 512 = 512 bytes\nSector size (logical/physical): 512 bytes / 512 bytes\nI/O size (minimum/optimal): 512 bytes / 33553920 bytes\n```\n\n**Create a partition**\n\nIf your disk is new and freshly out of the package, you will need to create a partition with `sudo mkfs.ext4 /dev/sda`.\n\n```bash\nmke2fs 1.44.5 (15-Dec-2018)\n/dev/sda contains a ext4 filesystemlast mountedon /mnt/ssdonMonSep921:06:472019\nProceed anyway? (y,N) y\nCreating filesystem with 58609664 4k blocks and 14655488 inodes\nFilesystem UUID: 5c3a8481-682c-4834-9814-17dba166f591\nSuperblock backups storedonblocks:\n    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,\n    4096000, 7962624, 11239424, 20480000, 23887872\n\nAllocating group tables: done\nWriting inode tables: done\nCreating journal (262144 blocks):\ndone\nWriting superblocks and filesystem accounting information: done\n```\n\n**Manually mount the disk**\n\nYou can manually mount the disk to the directory `/mnt/ssd`.\n\n```bash\nsudo mkdir /mnt/ssd\nsudo chown -R pi:pi /mnt/ssd/\nsudo mount /dev/sda /mnt/ssd\n```\n\n**Automatically mount the disk on startup**\n\nNext step consists to configure `fstab` to automatically mount the disk when the system starts.\n\nYou first need to find the Unique ID of the disk using the command `blkid`.\n\n```bash\n/dev/mmcblk0p1: LABEL_FATBOOT=\"boot\" LABEL=\"boot\" UUID=\"F021-066F\" BLOCK_SIZE=\"512\" TYPE=\"vfat\" PARTUUID=\"fb9cde7a-01\"\n/dev/mmcblk0p2: LABEL=\"rootfs\" UUID=\"99f9cf68-e6fa-4b90-aeee-7fa3e9ed5c2d\" BLOCK_SIZE=\"4096\" TYPE=\"ext4\" PARTUUID=\"fb9cde7a-02\"\n/dev/sda: UUID=\"4f0ee438-771d-44b9-98b4-a2fe92c49080\" BLOCK_SIZE=\"4096\" TYPE=\"ext4\"\n```\n\nOur SSD located in `/dev/sda` has a unique ID `4f0ee438-771d-44b9-98b4-a2fe92c49080`.\n\nEdit the file `/etc/fstab` and add the following line to configure auto-mount of the disk on startup. After that reboot the system.\n\n```bash\n4f0ee438-771d-44b9-98b4-a2fe92c49080 /mnt/ssd ext4 defaults 0 0\n```\n\nYou can verify the disk is correctly mounted on startup with the following command: `df -ha /dev/sda`\n\n```bash\nFilesystem      Size  Used Avail Use% Mounted on\n/dev/sda        458G   73M  435G   1% /mnt/ssd\n```\n\n**Share via NFS Server**\n\nWe now gonna make the directory `/mnt/ssd` of master accessible to other machines via NFS\n\n**Install the required dependencies**\n\n```bash\nsudo apt-getinstall nfs-kernel-server -y\n```\n\n**Configure the NFS server**\n\nEdit the file `/etc/exports` and add the following line\n\n```bash\n/mnt/ssd *(rw,no_root_squash,insecure,async,no_subtree_check,anonuid=1000,anongid=1000)\n```\n\n**Start the NFS Server**\n\n```bash\nsudo exportfs -ra\n```\n\n**====== Worker nodes only - Mount the NFS share ======**\n\nI**nstall the necessary dependencies**\n\n```bash\nsudo apt-get install nfs-common -y\n```\n\n**Create the directory to mounty the NFS Share**\n\nCreate the directory `/mnt/ssd` and set the ownership to your user\n\n```bash\nsudo mkdir /mnt/ssd\nsudo chown -R user:user /mnt/ssd/\n```\n\n**Configure auto-mount of the NFS Share**\n\nIn this step, we will edit `/etc/fstab` to tell the OS to automatically mount the NFS share into the directory `/mnt/ssd` when the machine starts.\n\nAdd the following line where `192.168.0.\u003cx\u003e:/mnt/ssd` is the IP of `kube-master` and the NFS share path.\n\n```bash\n192.168.0.63:/mnt/ssd   /mnt/ssd   nfs    rw  0  0\n```\n\n**Reboot the system**\n\n```bash\nsudo reboot\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbarnes-c%2Finfrastructure","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbarnes-c%2Finfrastructure","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbarnes-c%2Finfrastructure/lists"}