/k8s-home

A repo for the configuration for my home Kubernetes cluster using ArgoCD

Flux Home

The repository for the flux configuration of my home kubernetes cluster.

Getting Started

Bootstrap cluster on Raspberry PIs

  1. Login to your Raspberry PI
sudo sed -i '$ s/$/ cgroup_enable=cpuset cgroup_enable=memory cgroup_memory=1 swapaccount=1/' /boot/firmware/cmdline.txt
  1. Install Microk8s
sudo snap install microk8s --classic
  1. Update permissions to be able to execute commands without sudo
sudo usermod -a -G microk8s $USER
sudo chown -f -R $USER ~/.kube
su - $USER
  1. Wait until the cluster is up
microk8s status --wait-ready
  1. Enable useful services
microk8s enable dns storage ingress helm3 metrics-server

Optional: Adding additional nodes

  1. Login to your first Raspberry PI

  2. Run command to obtain join token

microk8s add-node 
  1. Login to second Raspberry PI

  2. Run command collected from output step 2

  3. Fin

Enable gitops integration via flux

These steps assume you have already configured your .kube/config file to allow access to the cluster via the kubectl CLI. 0. Install flux CLI

curl -s https://toolkit.fluxcd.io/install.sh | sudo 
  1. Set github personal access token (with all repo permissions):
export GITHUB_TOKEN=INSERT_TOKEN_HERE
  1. Configure cluster
flux bootstrap github --personal --repository=k8s-home --owner=jamesgawn --read-write-key --personal --components-extra=image-reflector-controller,image-automation-controller

How to

How to generate a new sealed secret

  1. Create the insecure secret file or using the template provided:
kubectl -n default create secret generic example-secret \
--from-literal=key1=value1 \
--from-literal=key2=value2 \
--dry-run=client \
-o yaml > example-secret.yaml
  1. Secure it using public key
kubeseal --format=yaml --cert=sealed-secret-public-cert.pem < example-secret.yaml > example-secret-sealed.yaml

You can obtain the public key with the following command:

kubeseal --fetch-cert \
--controller-name=sealed-secrets \
--controller-namespace=flux-system \
> sealed-secret-public-cert.pem