Files

11 KiB
Raw Permalink Blame History

Environment Description

Reference for other agents/automata working on this repo. Describes the homelab Kubernetes cluster's shape, conventions and gotchas. No secrets or credentials are included — see Secrets section below for how they are handled.

Repository

Type: Plain Kubernetes manifests (no Helm/kustomize/build for the majority of the tree; two exceptions managed by Helm). Applied directly with kubectl apply -f <path>. No CI/lint/test pipeline — verify by applying and inspecting kubectl get/describe/logs.

Platform: Homelab cluster on Hetzner Cloud.

Repo root layout:

Directory Purpose
Cilium/ Cilium networking: LoadBalancerIPPool, L2AnnouncementPolicy, ingress example
Cluster_admin/ Operational notes (node reboot/update sequences, kubectl cp example) — not manifests applied to cluster
Docker/PostgreSQL/ Custom PostgreSQL image build (Dockerfile + build script)
DockerRegistry/ Private Docker registry Deployment + Service + PVC, and a registry UI subdirectory
Email/ Mailu mail server (Helm) + namespace + Cilium LB pool manifests
Gitea/ Gitea Deployment/Service/Ingress/Namespace/PVC/DB-secret
Immich/ Immich server + machine-learning + redis Deployments/Services, config + secret
Monitoring/ kube-prometheus-stack Helm values + hand-managed Grafana manifests
PostgreSQL/ PostgreSQL manifests (only hetzner/ subdir currently present)
Secrets/ Docker registry login credentials (gitignored — not committed)
volume/ PVC and SMB volume examples

Cluster Infrastructure

  • CNI/LB: Cilium. Provides pod networking and Layer 2-announced LoadBalancer IPs via CiliumLoadBalancerIPPool + CiliumL2AnnouncementPolicy.

  • L2 Announcement: l2-policy in Cilium/L2AnnouncementPolicy.yaml — announces externalIPs and loadBalancerIPs on nodes that are not control-plane (node-role.kubernetes.io/control-plane DoesNotExist).

  • LoadBalancer IP Pools (CiliumLoadBalancerIPPool):

    Pool Range File Purpose
    lan-pool 10.1.0.101–10.1.0.199 Cilium/LoadBalancerIPPool.yaml General Cilium ingresses / services
    mailu-pool 10.4.0.0–10.4.0.255 Email/mailu_lbippool.yaml Mailu mail LB (SMTP/IMAP/Submission)
  • LB IP pinning: Annotation lbipam.cilium.io/ips: <ip> on a Service, backed by a matching pool. Example: Mailu front service pins 10.4.0.122 (see Email/mailu.values.yaml).

  • Ingress class: cilium. Ingresses use ingress.cilium.io/loadbalancer-mode: "dedicated".

Network / IP Layout

  • Node IPs: 10.1.0.x (previously 10.0.2.x — old addresses are unreachable from current nodes).
  • Any manifest referencing the old registry 10.0.2.119:5000 is stale; use the public image name rg.mariushome.lt/custom-postgres instead.
  • LB pool ranges are RFC1918 and announced via L2 on worker nodes.

Storage

Three StorageClasses exist:

StorageClass Driver Default? Notes
slow SMB CSI Yes PVCs that omit storageClassName land here (SMB share).
hcloud-volumes Hetzner CSI No Block storage; set storageClassName: hcloud-volumes explicitly.
local-storage no-provisioner No Requires a matching manual PersistentVolume with nodeAffinity.

Gotchas:

  • slow (SMB) is the default; hcloud-volumes is not. Omitting storageClassName puts a PVC on SMB. When block storage is wanted, set it explicitly.
  • Only one default StorageClass may exist. If kubectl get sc shows two (default), patch the unwanted one: kubectl patch sc <name> -p '{"metadata":{"annotations":{"storageclass.kubernetes.io/is-default-class":"false"}}}'
  • Examples of both PVC and SMB volume usage live in volume/.

Workloads

Directory Workload(s) Namespace Image / Notes
PostgreSQL/hetzner/ postgres-hetzner Deployment + ClusterIP Service + PVC + ConfigMap database rg.mariushome.lt/custom-postgres (custom image, see Build below). PVC on hcloud-volumes. Creds via postgres-secret. app: postgres-hetzner selector. Recreate strategy.
Gitea/ Gitea Deployment + Service + Ingress + Namespace + PVC gitea docker.io/gitea/gitea:latest. Uses external Postgres at postgres.database.svc.cluster.local:5432, DB gitea, user admin, pwd from gitea-db-secret. Ingress host git.mariushome.lt. PVC gitea-hetzner-pvc.
Immich/ Immich server + machine-learning + redis Deployments/Services + config + secret immich ghcr.io/immich-app/immich-server:v3; ML image separate. Init container waits on postgres.database.svc.cluster.local:5432. Uses immich-env ConfigMap + immich-db-secret. Library PVC immich-lib.
DockerRegistry/ Registry Deployment + Service + PVC + UI (Deployment/Service/Ingress) registry registry:2. htpasswd auth mounted from registry-htpasswd Secret. PVC registry-pvc.
Email/ Mailu (Helm release) mailu Helm chart mailu v2.7.1 (appVersion 2024.06.51). Domain mariushome.lt. Reuses external postgres-hetzner; bundled postgres subchart disabled. Mail LB pinned to 10.4.0.122. TLS terminated upstream by Cloudflare.
Monitoring/Grafana/ Hand-managed Grafana Deployment + Service + Ingress + PVC + datasource + DB/app secrets monitoring docker.io/grafana/grafana:latest. Datasource points at prometheus-operated.monitoring.svc.cluster.local:9090.

Postgres is the shared database backend: Gitea, Immich, and Mailu all connect to the same postgres-hetzner instance via the postgres Service in the database namespace (postgres.database.svc.cluster.local:5432).

Monitoring Stack

  • kube-prometheus-stack Helm release (namespace monitoring), chart version pinned 87.3.0. Values in Monitoring/kube-prometheus-stack.values.yaml.
    • Prometheus: 15d retention, 10Gi PVC on hcloud-volumes, selects all ServiceMonitors/PodMonitors/Rules/Probes ({}SelectorNilUsesHelmValues: false).
    • Alertmanager: disabled.
    • Bundled Grafana: disabled (grafana.enabled: false) — a hand-managed Grafana lives in Monitoring/Grafana/.
    • Node Exporter + kube-state-metrics: enabled via chart subcharts.
  • Monitoring/Prometheus/ is empty — the previous hand-rolled Prometheus manifests were removed when the Helm chart replaced them. Do not recreate.
  • To add a scrape target, create a ServiceMonitor/PodMonitor CR anywhere; the Prometheus CR selects all of them.
  • Install/upgrade commands are in README.md. Do not re-apply Grafana via both kubectl apply and Helm — Grafana is hand-managed, Prometheus is Helm-managed.

Container Image Build

  • Docker/PostgreSQL/ holds the custom PostgreSQL image: base postgres:18.4
    • pgvector v0.8.2 built from source, plus rclone/python helpers.
  • Build/push handled by Docker/PostgreSQL/PostgreSQL_Build.sh, which pushes to rg.mariushome.lt/custom-postgres. Run the script from the Docker/PostgreSQL/ directory so the Docker build context is correct.
  • rg.mariushome.lt is the public-facing name for the registry formerly served from 10.0.2.119:5000; the old path is unreachable from current nodes.

Secrets — handling (values are NOT shared here)

  • Secrets/ and any *secret*.yaml/*secret*.yml are gitignored; secret manifests are created out-of-band and are not committed. Do not git add a secret manifest.
  • Secret objects consumed by workloads (names only, values held out-of-band):
    • database/postgres-secret — PostgreSQL credentials.
    • gitea/gitea-db-secret — Gitea DB password.
    • immich/immich-db-secret — Immich DB credentials.
    • registry/registry-htpasswd — htpasswd file for the private registry.
    • mailu/mailu-secret + mailu/mailu-db-secret — Mailu app + DB secrets.
    • monitoring/grafana-secret + monitoring/grafana-db-secret — Grafana app + DB secrets.
  • registry-creds imagePullSecret (one per namespace pulling from rg.mariushome.lt, e.g. database) is required for workloads referencing the private registry. Created out-of-band via kubectl create secret docker-registry registry-creds ....
  • Read existing secret values from the cluster with kubectl get secret if a migration step needs them.

Conventions

  • Manifests use app label selectors; do not introduce app.kubernetes.io/* labels mid-stream without updating every consumer (Services, ServiceMonitors).
  • Per-resource file naming pattern: <thing>_deployment.yaml, <thing>_service.yaml, <thing>_pvc.yaml.
  • Filenames are kept verbatim, including intentional typos and oddities (move _data_example.txt has a leading space). Other docs reference these names directly.
  • Helm-managed pieces (kube-prometheus-stack, Mailu) are upgraded via helm upgrade ... -f <values.yaml>, not kubectl apply for the values file. Their accompanying Namespace/LBIPPool manifests are still applied with kubectl apply.

Cluster Admin (operational, not manifests)

  • Cluster_admin/nodes_restart_commands.txt — drain/reboot/uncordon sequence per node. Follow that order.
  • Cluster_admin/nodes_update_commands.md — node update procedure.
  • Cluster_admin/move _data_example.txt — kubectl cp example (leading space in the filename is intentional).

Quick Reference — Commands

  • Apply a manifest: kubectl apply -f <path>
  • Apply Mailu non-Helm pieces: kubectl apply -f Email/mailu_namespace.yaml and kubectl apply -f Email/mailu_lbippool.yaml
  • Upgrade Mailu: helm upgrade mailu mailu/mailu -n mailu --version 2.7.1 -f Email/mailu.values.yaml
  • Upgrade monitoring: see README.md (kube-prometheus-stack, version 87.3.0)