11 KiB
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-policyinCilium/L2AnnouncementPolicy.yaml— announcesexternalIPsandloadBalancerIPson nodes that are not control-plane (node-role.kubernetes.io/control-planeDoesNotExist). -
LoadBalancer IP Pools (
CiliumLoadBalancerIPPool):Pool Range File Purpose lan-pool10.1.0.101–10.1.0.199Cilium/LoadBalancerIPPool.yamlGeneral Cilium ingresses / services mailu-pool10.4.0.0–10.4.0.255Email/mailu_lbippool.yamlMailu mail LB (SMTP/IMAP/Submission) -
LB IP pinning: Annotation
lbipam.cilium.io/ips: <ip>on aService, backed by a matching pool. Example: Mailu front service pins10.4.0.122(seeEmail/mailu.values.yaml). -
Ingress class:
cilium. Ingresses useingress.cilium.io/loadbalancer-mode: "dedicated".
Network / IP Layout
- Node IPs:
10.1.0.x(previously10.0.2.x— old addresses are unreachable from current nodes). - Any manifest referencing the old registry
10.0.2.119:5000is stale; use the public image namerg.mariushome.lt/custom-postgresinstead. - 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-volumesis not. OmittingstorageClassNameputs a PVC on SMB. When block storage is wanted, set it explicitly.- Only one default StorageClass may exist. If
kubectl get scshows 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 pinned87.3.0. Values inMonitoring/kube-prometheus-stack.values.yaml.- Prometheus: 15d retention,
10GiPVC onhcloud-volumes, selects all ServiceMonitors/PodMonitors/Rules/Probes ({}SelectorNilUsesHelmValues: false). - Alertmanager: disabled.
- Bundled Grafana: disabled (
grafana.enabled: false) — a hand-managed Grafana lives inMonitoring/Grafana/. - Node Exporter + kube-state-metrics: enabled via chart subcharts.
- Prometheus: 15d retention,
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/PodMonitorCR anywhere; the Prometheus CR selects all of them. - Install/upgrade commands are in
README.md. Do not re-apply Grafana via bothkubectl applyand Helm — Grafana is hand-managed, Prometheus is Helm-managed.
Container Image Build
Docker/PostgreSQL/holds the custom PostgreSQL image: basepostgres:18.4pgvectorv0.8.2 built from source, plus rclone/python helpers.
- Build/push handled by
Docker/PostgreSQL/PostgreSQL_Build.sh, which pushes torg.mariushome.lt/custom-postgres. Run the script from theDocker/PostgreSQL/directory so the Docker build context is correct. rg.mariushome.ltis the public-facing name for the registry formerly served from10.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*.ymlare gitignored; secret manifests are created out-of-band and are not committed. Do notgit adda 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-credsimagePullSecret (one per namespace pulling fromrg.mariushome.lt, e.g.database) is required for workloads referencing the private registry. Created out-of-band viakubectl create secret docker-registry registry-creds ....- Read existing secret values from the cluster with
kubectl get secretif a migration step needs them.
Conventions
- Manifests use
applabel selectors; do not introduceapp.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.txthas a leading space). Other docs reference these names directly. - Helm-managed pieces (kube-prometheus-stack, Mailu) are upgraded via
helm upgrade ... -f <values.yaml>, notkubectl applyfor the values file. Their accompanying Namespace/LBIPPool manifests are still applied withkubectl 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 cpexample (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.yamlandkubectl 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, version87.3.0)