- Python 71.8%
- CSS 10.3%
- Jinja 6.5%
- Makefile 4.6%
- Go Template 4.4%
- 기타 2.4%
| 파일 이름 | 최신 커밋 메시지 | 최근 커밋 날짜 |
|---|---|---|
Garage is gone, so VersityGW takes over its original S3 port (3900) and uses 3903/3909 for the admin API and web UI. |
||
| .github/workflows | ||
| ansible | ||
| apps | ||
| clusters/production | ||
| infrastructure | ||
| .gitignore | ||
| AGENTS.md | ||
| readme.md | ||
| renovate.json5 | ||
| tinyrack-homelab-secret-key.crt | ||
Homelab
A Flux GitOps repository for my personal homelab Kubernetes cluster.
This repository manages the desired state of my personal homelab production cluster.
It runs Flux on K3s and uses the manifests under apps and infrastructure to declaratively manage applications, networking, certificates, storage, and observability.
GitOps
clusters/productionis the Flux bootstrap path.infrastructure/overlays/productioncontains the cluster foundation.apps/overlays/productioncontains homelab application configuration.apps/base/*andinfrastructure/base/*hold the workload manifests.- Secrets are encrypted with Sealed Secrets before they are committed.
ansible/prepares the replacement machine used for cluster migration.
Disaster Recovery
Recovery uses the normal production path. There is no separate recovery Flux installation or recovery overlay.
Before bootstrapping a replacement cluster, temporarily remove the application entry point from Flux and push that change:
mv clusters/production/apps.yaml clusters/production/apps.yaml.bak
git add clusters/production/apps.yaml clusters/production/apps.yaml.bak
git commit -m "chore: pause applications for cluster recovery"
git push
Use ansible/ to install K3s, bootstrap Cilium, and restore the Sealed Secrets
private key before bootstrapping Flux from clusters/production. The bootstrap
uses the same cilium Helm release and values that Flux adopts later. Wait until
the infrastructure and Longhorn backup target are ready. Access Longhorn without
ingress if necessary:
kubectl -n longhorn-system port-forward service/longhorn-frontend 8000:80
In the Longhorn UI, restore the latest Ready system backup created by the same
Longhorn minor version. The system backup restores application volumes from
their latest volume backups.
PostgreSQL is restored by CloudNativePG from Barman S3 backups, not from Longhorn volume backups. Before enabling applications, remove any CNPG data PVCs restored by an old Longhorn backup and confirm their PVs and Longhorn volumes are gone:
kubectl get pvc -A -l cnpg.io/pvcRole=PG_DATA
kubectl delete pvc -A -l cnpg.io/pvcRole=PG_DATA
kubectl get pv
Enable applications again and push the change:
mv clusters/production/apps.yaml.bak clusters/production/apps.yaml
git add clusters/production/apps.yaml clusters/production/apps.yaml.bak
git commit -m "chore: resume applications after cluster recovery"
git push
CNPG manifests that declare bootstrap.recovery (bifrost, bookorbit, davinci-resolve,
devenv, forgejo, issuary, mathesar, n8n, openwebui, personal-data) recreate their databases
from S3 when Flux applies the application manifests; clusters still declared
with bootstrap.initdb come up empty after a rebuild and need a manual
restore. Verify CNPG recovery before allowing external traffic, then check
Flux, certificates, ingress, storage, and core application data.
devenv keeps its state (users, environments, SSH host keys, tokens) in the CNPG
cluster devenv-database-cluster (bootstrap.recovery from
s3://tinyrack-homelab/apps/devenv/database-18), and home volumes
(<env>-home) come back with the Longhorn system backup. No devenv specific
step: environments whose home volume is not restored yet wait
(AwaitingVolume) instead of starting empty, and keep their LAN addresses
and SSH host keys. See devenv's docs/disaster-recovery.md.
Bootstrap
K3s, Cilium, and Sealed Secrets key
Store the become password and every Sealed Secrets key (vault_sealed_secrets_keys)
in the Ansible Vault, then let Ansible prepare everything up to the Flux boundary.
The vault password is the Bitwarden item ansible vault (homelab); vault-pass.sh
reads ANSIBLE_VAULT_PASSWORD or the gitignored .vault_pass:
cd ansible
make vault-edit
make preflight
make check
make apply
make apply
make verify
cd ..
Do not bootstrap Flux until make verify confirms that Cilium is healthy and
that every Sealed Secrets key in the new cluster matches the Vault values. K3s starts
with Flannel, its network-policy controller, and kube-proxy disabled; Cilium must
therefore be running before Flux controllers and workloads can start.
Flux
flux bootstrap github \
--repository=homelab \
--branch=main \
--path=./clusters/production \
--owner=tinyrack-net
Flux reconciles the cilium HelmRelease in kube-system and takes over the
release installed by Ansible. Multus remains the first CNI configuration and
delegates the primary Pod network to Cilium.
Configuration files
- Keep a HelmRelease focused on chart lifecycle and load chart configuration
from a sibling
<component>.values.yamlthroughspec.valuesFrom. - Generate Helm values ConfigMaps with a stable name, the
reconcile.fluxcd.io/watch: Enabledlabel, andvalues.yamlas the data key. - Keep application-native YAML, TOML, JSON, ENV, and Alloy River configuration in files named for the owning component. Use Kustomize's default name hash when a Pod directly mounts or imports a ConfigMap so changes roll the Pod.
- Disable the name hash only when the consumer requires a stable name, such as Helm values and Alloy's externally managed, dynamically reloaded ConfigMap.
- Keep credentials out of values and configuration files. Secrets remain encrypted SealedSecret manifests or references to existing Secrets.
Version sweep
Renovate is running via .github/workflows/renovate.yml and keeps a
Dependency Dashboard issue open. The workflow only supplies the trigger: the
schedule itself lives in renovate.json5 (before 6am on saturday, Asia/Seoul),
so that file is the single owner of when runs happen. Do not add a second
schedule in the workflow.
The workflow needs a RENOVATE_TOKEN repository secret (classic PAT with repo
and workflow scopes). Without it the job fails immediately with
'token' MUST be passed using its input.
Confirm the state before assuming an automatic update:
gh workflow list --repo tinyrack-net/homelab
gh run list --repo tinyrack-net/homelab --workflow renovate.yml --limit 5
gh issue list --repo tinyrack-net/homelab --search "Dependency Dashboard"
gh pr list --repo tinyrack-net/homelab --search renovate
Renovate does not cover everything, so a manual sweep is still needed for the items below. Refresh one layer at a time, commit per layer, and verify before moving on.
Sweep checklist
- Flux controllers —
clusters/production/flux-system/gotk-components.yamlis generated, so compare its# Flux Version:header and image tags with the latest upstream release by exporting that release:flux install --version=<v> --components=source-controller,kustomize-controller,helm-controller,notification-controller,image-reflector-controller,image-automation-controller --export, then checkkubectl kustomize ./clusters/production/flux-system. The localfluxCLI drifts behind the deployed version, so check its version first — the manifest must be regenerated with a CLI of the target version. - K3s — take the version from the K3s release channel
(
curl -s https://update.k3s.io/v1-release/channels) or the upstream GitHub releases, and update bothinfrastructure/base/k3s-upgrade/k3s-server-plan.yaml(theversion:field drives the upgrade;upgrade.imagestays untagged) andansible/roles/setup_k3s_server/defaults/main.yml. - Helm charts —
helm search repo <repo>/<chart> --versionsand bumpspec.chart.spec.versionin the owning*.helm-release.yaml. Render the base withhelm templateandkubectl kustomize ./infrastructure/base/<name>before committing, because a new chart minor can rename values keys and silently drop configuration. Most HelmReleases inline their values, so dedent thevalues:block by 4 spaces into a scratch file to render it. - Remote release manifests —
infrastructure/base/cloudnative-pgandinfrastructure/base/system-upgrade-controllerpull manifests from upstream release URLs. Check their releases and diff the rendered output. - Container images —
docker buildx imagetools inspect <ref>for the newest tag, then re-pin the digest. - Node components — K3s ships its own coredns, metrics-server, local-path-provisioner, and kubectl. They move with the node and are not pinned in this repository.
- Node OS packages —
apt list --upgradableon the node, thenapt-get -y -o Dpkg::Options::=--force-confold upgrade. Check/var/run/reboot-requiredafterwards; a reboot restarts every workload and detaches/reattaches every Longhorn volume, so schedule it as its own step, never in the middle of a sweep. Take an etcd snapshot first:k3s etcd-snapshot save --name pre-reboot-<date>.
What Renovate covers
renovate.json5 has flux and kubernetes managers plus regex
customManagers for the cases the built-in managers miss:
| Manager | Files |
|---|---|
| CloudNativePG operands | apps/base/**/*.database.yaml (imageName:) |
| OT Redis operands | apps/base/**/*.redis.yaml (quay.io/opstree/redis:) |
| K3s Plan version | infrastructure/base/k3s-upgrade/k3s-server-plan.yaml |
| CloudNativePG + Barman manifests | infrastructure/base/cloudnative-pg/kustomization.yaml |
| BrowserOS neo image | apps/base/browseros/*.deployment.yaml |
rancher/system-upgrade-controller is deliberately disabled: its CRD and RBAC
are vendored by hand and must be refreshed manually.
Image digests
Every @sha256: must be refreshed together with its tag. The node is
linux/amd64:
docker buildx imagetools inspect <registry>/<path>:<tag> --format '{{json .Manifest}}' \
| jq -r 'if .manifests then (.manifests[] | select(.platform.os == "linux" and .platform.architecture == "amd64") | .digest) else .digest end'
The repository mixes both conventions, so match the convention already used in the file rather than picking one:
| Convention | Files |
|---|---|
| amd64 platform digest | nginx-unprivileged, nextcloud-mcp-server (postRenderer), multus-cni |
| index (multi-arch) digest | everything else, including eceasy/cli-proxy-api, n8nio/n8n, n8nio/runners, searxng/searxng, cloudflared, open-webui, immich, nextcloud, the CloudNativePG operands and quay.io/opstree/redis |
Getting this backwards pins the wrong image without any error from Kubernetes.
Pitfalls found by hand
- Registry tags drift into pre-release channels:
n8nio/n8npublishes2.43.xwithprerelease: truewhile2.42.5is the promoted stable release. Check the GitHub releaseprereleaseflag and the imagestabletag before bumping. - A new image tag may not exist for every distribution:
eclipse-mosquittopublishes2.1.xonly as-alpine, andtailscale/tailscaletags a release before it publishes an image. Verify the image, not just the release. Mosquitto 2.1 refuses ConfigMap and Secret files that Kubernetes mounts through symlinks unlessMOSQUITTO_UNSAFE_ALLOW_SYMLINKS=trueis set. - Docker Hub throttles anonymous pulls per egress IP, and the workstation and the
node share one, so probing registries during a rollout can break it with
429 Too Many Requests. Pre-seed the node from a pull-through mirror instead of waiting:k3s ctr -n k8s.io images pull mirror.gcr.io/<path>:<tag>and thenk3s ctr -n k8s.io images tag mirror.gcr.io/<path>:<tag> docker.io/<path>:<tag>. kubectl get backup -Aresolves to MariaDB backups. Name the resource explicitly:kubectl get backups.postgresql.cnpg.io -A.- A CNPG
Backupcan sit instartedforever if the controller could not write its status back during an API-server stall, and that blocks every laterScheduledBackuprun with "The system is already taking a backup". Confirm nobarman-cloud-backup/pg_basebackupprocess is running in the instance pod (kubectl exec ... -c postgres -- ps aux), then delete just thatBackupCR — its completed siblings and the S3 objects are untouched. The scheduled backup then runs the next missed slot. - A failed CNPG backup whose log ends in
Read timeout on endpoint URL: "https://storage..."followed byValueError: I/O operation on closed fileis a transient object-store timeout, not corruption. Re-run it with a one-offBackupCR before treating it as a data problem. - The Traefik LoadBalancer IPs are not reachable from the workstation. Verify an
ingress with
kubectl -n <namespace> port-forward service/<service> <local>:<port>. Noteport-forwardto a Service rotates pods on each invoke, so a000there usually means the local forward was not ready yet, not that the route is broken. Public HTTPS is the fastest real check:curl -o /dev/null -w '%{http_code}' https://<host>. - Snapshot stateful volumes before a sweep that touches storage or the node: a
Longhorn
Snapshotper volume, a LonghornSystemBackup, and a manual CNPGBackupin every namespace. Delete those snapshots once the sweep is verified: they are not backed up and keep the old blocks on the node disk. - Longhorn snapshots hold real disk space on the single node, and new volumes
stay
faulted("disks are unavailable") once free space drops belowstorage-minimal-available-percentage(25%). Shrinking PVCs does not help: the space is in snapshots, not in volume sizes. Thelonghorn-snapshot-cleanupDeletingPolicy (backup-cleanup) removes any snapshot whose exact CompletedBackupexists in VersityGW, except the newest backed-up one per volume (the base for the next incremental backup), and thelonghorn-snapshot-cleanupRecurringJob (05:00) purges them. A snapshot only marked removed frees its space after a purge (Longhorn UI → volume → Purge snapshots, or thesnapshotPurgevolume action). Label a snapshottinyrack.net/protected=trueto keep it. - This node can restart k3s under I/O pressure. The node is Proxmox VM 101
on
proxmox-main; its root disk is a thick LVM volume on an NVMe SSD, exposed withssd=1(/sys/block/sda/queue/rotationalis0). Before 2026-11-17 the flag was missing and the guest saw a rotational disk; etcd has loggedslow fdatasyncspikes up to 6s. When a lease renewal exceeds its deadline k3s exits with status 1 instead of retrying, so every controller pod restarts with exit code 255 and in-flight API writes are lost. Symptom to recognise:kubectlreturningconnection refusedorcontext deadline exceededmid-reconcile while everything looked healthy a minute earlier. It is not caused by the version being deployed. Check severity withssh homelab 'systemctl show k3s -p NRestarts'andjournalctl -u k3s | grep -c 'apply request took too long'; recover by waiting for/readyzto returnok, then re-run the interrupted reconcile. - A VM shutdown can stall in the final
systemd-shutdownstage. Longhorn's iSCSI devices disappear before every container process exits, so a process such asmultus-daemoncan block on I/O andqm shutdown --timeout 300fails withVM quit/powerdown failedwhile the guest already sits atpoweroff.target. Check the console (screendumpviaqm monitor 101), sendsendkey alt-sysrq-sthensendkey alt-sysrq-uto sync and remount read-only, and wait for QEMU to exit beforeqm start 101. Take an etcd snapshot first. After the node is back, check two things a cold boot breaks:- A Traefik pod that starts before egress works cannot download the CrowdSec
plugin (
Plugins are disabled), so everywebsecureroute on that pod returns 404 while the other replica serves normally. Look formiddleware does not existin each Traefik pod's log and delete the affected pod. - The
crowdsec-agentDaemonSet pod keeps its name across the reboot and its init container fails withuser already exist. Delete the pod, then remove the stale entry withcscli machines delete <old-pod-name>.
- A Traefik pod that starts before egress works cannot download the CrowdSec
plugin (
CNI migration
The production cluster was migrated from Flannel and kube-proxy to Cilium. The one-time migration and rollback playbooks were removed after verification.
Traefik network policy ownership
- Keep only shared entrypoint, Kubernetes API, and telemetry access in the Traefik infrastructure policies.
- Put route-specific access beside its owning application or proxy in a
<owner>.traefik.cilium-network-policy.yamlfile. - Create the policy in
traefik-systemortraefik-external-system, name itroute-<owner>, and add thenetworking.tinyrack.net/ownerlabel andnetworking.tinyrack.net/hostsannotation. - Use
toServiceswith the backend target port for Kubernetes Services andtoCIDRSetwith acidrGroupRefplus explicit ports for LAN or ExternalName backends. - Group routes that share a backend into one owner policy. Host annotations are documentation and do not enable Cilium L7 HTTP filtering.
Cilium CIDR groups
CIDR literals in network policies are replaced by CiliumCIDRGroup aliases so a
reader can tell which network or host a rule targets.
- Define network groups (
lan,vpn-server,vpn-control,tailscale) and one group per LAN host ininfrastructure/base/network-security. - Reference groups with
fromCIDRSet/toCIDRSetandcidrGroupRef; list several refs when a rule needs several networks. homelab-host-firewalldepends on thenetwork-securityKustomization, so a group always exists before a policy that references it is applied.- Cilium has no alias for ports and
exceptonly accepts literal CIDRs, so those stay explicit and carry a comment describing their purpose.
Sealed Secrets
kubectl create secret generic some-secret \
--namespace some-namespace \
--dry-run=client \
--from-literal=SOME_SECRET_KEY=SOME_SECRET_VALUE \
-o yaml | \
kubeseal --cert ./tinyrack-homelab-secret-key.crt \
> ./some.secret.yaml
Key management:
- The controller runs with
keyrenewperiod: "0"and never creates keys on its own. - Every active key is in the Ansible Vault as
vault_sealed_secrets_keys(oldest first).restore_sealed_secrets_keyrestores all of them before Flux, andmake preflightchecks thattinyrack-homelab-secret-key.crtis the newest one. - To rotate, create a new key in the cluster, append it to
vault_sealed_secrets_keys, replace the committed certificate with itstls.crt, and runmake verify. Keep old keys until every SealedSecret has been resealed.