K3[8]S @ HOME OPS

September 28, 2023 ยท View on GitHub


k3s pre-commit renovate Lines of code GitHub repo size


This repo contains my home infrastructure defined as Kubernetes helm releases, CRDs, and other set of helper scripts deployed via FluxCD. The underlying infrastructure is maintained through a whole personal (still private) arsenal of Ansible playbooks and roles to automate my home setup.

I am a firm believer in GitOps and Kubernetes as the defacto cloud orchestrator for running everything as containers in the private and public clouds alike.

๐Ÿงฌ Repository structure

The cluster components break down all their services into 6 well-defined "categories" under the cluster directory:

๐Ÿณ GitOps

Flux watches the aforementioned cluster folders in the main Git branch. Also, it makes the appropriate changes in the K8s cluster based on the Kustomization and Helm controllers specifications.

๐Ÿค– RenovateBot

Med Renovate watches the entire repository looking for dependency updates, when they are found, a Pull Request is automatically created (and auto-applied oftentimes).

Personally, I use a Github app under the name of Henry PA that kindly assist me with the PR creation, and fillings.

๐Ÿ”ง Hardware

DeviceCountOS Disk SizeData Disk SizeCPURamOperating SystemPurpose
Raspberry Pi 4B+1256GB SSDN/ABCM27118GBRaspberryOSK3s worker && Master
Beelink U59001512GB M.2 SSD500GB HDDIntel N509516GBUbuntu 22.04K3s Master && Worker
Dell Optiplex 7070 Micro1512GB M.2 SSD480GB SSDIntel i5-8500T16GBUbuntu 22.04K3s Master && Worker
Trigkey Green G1 MiniPC1256GB M.2 SSD500GB HDDIntel J41258GBUbuntu 22.04K3s worker
Dell Precision 351012TB M.2 SSD500GB HDD + 500GB SSDIntel i7-6800HQ32 GBUbuntu 22.04K3s worker
Raspberry Pi 4B+3256GB SSDN/ABCM27114GBRaspberryOSK3s workers

Bootstrap cluster using Flux

Make sure to follow the steps described (here)[cluster/flux/flux-system/README.md] to bootstrap de cluster, the GPG/AGE keys are deployed in the cluster already.

kubectl apply -k cluster/bootstrap
kubectl apply -k cluster/flux/flux-system
export FLUX_KEY_FP=<<KEY_ID>>
gpg --export-secret-keys --armor "${FLUX_KEY_FP}" |
kubectl create secret generic sops-gpg \
    --namespace=flux-system \
    --from-file=sops.asc=/dev/stdin
sops -d cluster/flux/flux-system/github-deploy-key.sops.yaml | kubectl apply -f -

After the aforementioned command is fired off against a nuked cluster, the cluster bootstrapping logic should take place starting with CRDs, sources, and config categories, them moving to core items, whilst finalising with the apps objects.

Uninstall FluxCD alongside all CRDs

The following CLI command will uninstall FluxCD alongside all CRDs:

flux uninstall --resources --crds --namespace=flux-system

Troubleshooting - NOT YET IMPLEMENTED (WIP)

A dedicated directory with a set of runbooks should live under /docs/troubleshooting.

Frequently Answered Questions (FAQ)

Why do K8s namespaces live in a single folder?

This is quite important. Despite adding extra management overhead, it ensures the namespace must exist before deploying any K8s objects.

Credits :handshake:ย 

A high representation as well as inspiration of this repository came from the following three sources predominantly: