Skip to content
jonakoudijsPublic

Latest commit

 

History

77 Commits

Folders and files

Repository files navigation

MIT License

Homelab

Setup configuration for my homelab cluster. The entire setup and configuration is defined as IAC. This platform runs Kubernetes 24/7 at my home and is used to run various tools and services I use personally and for testing new things.

Currently it consists of a Talos 3-node cluster. The hardware used are BOSGAME E4 mini PC's. These are relatively cheap and have a low power consumption.

Requirements

The following local tools are needed to set everything up:

Customization

Although the code in this repository is opinionated and contains hardcoded references, I tried to allow for easy customization where feasable via environment variables. The following settings can be set by exporting the variables or creating an .env file in the root of this repository:

Variable Default Description
LAB_CLUSTER_NAME "" Name of the Kubernetes cluster.
LAB_CLUSTER_ENDPOINT_HOST "" IP or host of the Kubernetes API VIP.
LAB_CLUSTER_ENDPOINT_PORT "6443" Port of the Kubernetes API VIP.

Kubernetes specific configuration is either defined in Helm values in the helmfile- files or in manifests in the helm/config/ directory.

Talos Setup

First generate the Talos image that will be used for installing the nodes from the Talos Factory. Make sure to select the following System Extensions:

  • siderolabs/iscsi-tools
  • siderolabs/util-linux-tools

Alternatively you can use this schematic that contains the required extensions:

https://factory.talos.dev

These manual setups are needed for the initial setup. The first step is to generate the cluster secrets into talos/generated/:

task talos:secrets

Then run the setup command to generate the required files and apply them to the three defined nodes. This command will ask the temporary DHCP IP of each node. Run the command, boot the first node, enter the IP and hit enter. Then repeat this for the other two nodes:

task talos:setup

After node configuration has been applied to the first node, the bootstrap command should still be executed manual once:

talosctl bootstrap -n 10.0.0.210

Helm Charts

Almost everything is configured via Helm charts and deployed with Helmfile. Documentation on configurations of various components can be found here:

Configuration

Where possible the setup and configuration of the applications deployed in Kubernetes are either defined as manifests/helm charts or automatically generated and used. However the following components require manual steps:

  1. Step CA - To locally issue certificates Step CA is used. Both Step CA and Step Issuer are installed via Helm charts. During setup things like the root certificate are generated and should be defined in the helm/config/issuers/step-issuer.yaml file. See the step-issuer documentation for details.

  2. Root CA - After Step CA has been deployed and configured make sure to import the generated root CA on every devices that is going to connect to endpoints with using these certificates. Use this command to retrieve the root CA directly:

kubectl get configmap step-certificates-certs -n kube-system -o jsonpath='{.data.root_ca\.crt}'

Secrets

Sensitive data like passwords, api keys etc. are stored in secrets. The tool kubeseal is used to be able to store secrets encrypted in the repository. Remember to specify the namespace in the secret before encrypting. For example:

apiVersion: v1
kind: Secret
metadata:
  name: secret-basic-auth
  namespace: mynamespace
stringData:
  username: admin
  password: t0p-Secret

Then encrypt this secret file with the kubeseal command:

kubeseal -f original-secret.yaml -w secret.yaml

Used by

Contributors