- Python 50.7%
- HCL 25%
- Shell 16.1%
- Just 2.8%
- JavaScript 2.3%
- Other 3.1%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
All checks were successful
ci/crow/push/lint Pipeline was successful
Run arbinel-announce 0.4.0 (arbinel/announce#16). - With the forum key from #221, the bot posts the release topic with the pictures of the `release/showcase` pull requests itself. - It says in the approval thread when a reply or reaction comes from its own account. Reviewed-on: #222 |
||
| .crow | ||
| argocd-apps | ||
| cluster-access | ||
| config | ||
| custom-yaml | ||
| docs | ||
| object-storage | ||
| openbao/policies | ||
| scripts | ||
| .commitlintrc.json | ||
| .editorconfig | ||
| .envrc | ||
| .gitignore | ||
| .markdownlint.yaml | ||
| .pre-commit-config.yaml | ||
| .prettierrc.json | ||
| .terraform.lock.hcl | ||
| .yamllint | ||
| backend.tf | ||
| floating-ips.tf | ||
| Justfile | ||
| kubernetes.tf | ||
| provider.tf | ||
| proxy-cache-allowlist.tf | ||
| README.md | ||
| renovate.json | ||
| s3.tf | ||
| variables.tf | ||
kubernetes
Bootstrap ArgoCD
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
# login to argocd via port-fowarding
kubectl port-forward svc/argocd-server -n argocd 8080:443
argocd login localhost:8080
# deploy apps
# 1. envoy-gateway controller, then its Gateway API resources
# 2. cert-manager
# 2.1 Configure dns cluster issuers: create acme subdomain entry
# 2. argocd
# 3.1 deploy dns api key for dns challenge
Deploying changes
Merging to main deploys.
The argocd-apps ApplicationSet (argocd-apps/argocd/applicationset.yaml) creates one Argo CD Application per directory under argocd-apps/, named manifests-<dir>, and syncs it from main.
It covers the raw manifests and the child Application objects, so a Renovate bump in an Application's valuesObject or above an image: line reaches the cluster within a few minutes of being merged.
The child Applications still sync their own charts as before.
Each manifests-<dir> app syncs automatically with self-heal on and prune off:
- Self-heal reverts any live change that is not on
main, including a hand edit and ajust applyfrom a branch. - Removing a manifest from git does not delete the object.
The app turns OutOfSync and the object keeps running until someone deletes it by hand.
Pruning stays off because pruning a child
Applicationruns its delete hooks: longhorn and vso carry pre-delete hooks, k8up and zitadel post-delete hooks. - PVC sizes are ignored, because pvc-autoresizer grows volumes past the size in git.
- Argo applies client-side, like
kubectl apply, sojust applyand Argo update the same last-applied annotation.
To test a branch on the cluster, or to hand-edit during an incident, pause the directory's app first and resume it once the change is merged:
just pause <dir>
just apply <dir>
# after merging, or to discard the experiment
just resume <dir>
The ApplicationSet ignores this one field, so a paused app stays paused until it is resumed.
argocd-apps/argocd/ is excluded from the ApplicationSet and is still applied by hand with just apply argocd.
It holds the ApplicationSet itself and the argocd Application, which upgrades Argo CD from its chart on its own.
Removing a directory leaves its manifests-<dir> app and resources in place (applicationsSync: create-update).
Deleting the ApplicationSet deletes the generated apps but orphans their resources (preserveResourcesOnDeletion).
Argo CD drops fields that hold their default value, such as passCredentials: false, skipCrds: false or group: '', when it writes an Application back.
Leave them out of the Application manifests, or the manifests-<dir> app never settles on Synced.
Pull request checks
.crow/lint.yaml runs on every pull request without secrets: the prek hooks from .pre-commit-config.yaml, gitleaks, tofu fmt/validate (with -backend=false), tflint, kubeconform against the Kubernetes and CRD schemas, the script unit tests, and commitlint on the PR title.
Run the hooks locally before pushing with prek install once, or prek run --all-files on demand.
Applying tofu from CI
Pushes to main that touch tofu files run .crow/tofu-plan.yaml on cf-iac-deploy-2, the deploy host, whose agent accepts only allowlisted repositories.
To apply, deploy a main pipeline from Crow, which runs .crow/tofu-apply.yaml with a fresh plan:
crow pipeline deploy codefloe/kubernetes <pipeline> production
A deploy runs the whole plan, like a local tofu apply, including control-plane config, Talos and Kubernetes upgrades, and real deletes.
The plan pipeline lists every change by address, so read it before deploying.
Talos applies control-plane config to all nodes in parallel, so run control-plane-check first when the plan changes it.
CI holds a viewer kubeconfig, so a deploy refuses the whole plan if it changes a kubernetes_* resource.
Apply those from a workstation.
Control-plane protection
For user login through Zitadel and namespace-scoped RBAC, see cluster access.
API concurrency is capped at 300, Patroni coordination has reserved priority, and VSO/Cilium request rates are bounded.
Cilium operator and CSI controllers run on workers; relaxed Cilium leases make ingress failover take roughly 10–20 seconds.
A small Prometheus collects control-plane metrics for the existing devxy Grafana over the private tailnet.
See control-plane memory protection for the shared memory budget, guarded one-node trial, and external monitoring.
Apply API configuration changes one control plane at a time, checking health with python3 -B scripts/control_plane.py check between nodes; the same utility provides diagnostic capture and guarded follower recovery.
Backups
K8up for encrypted PVC backups to the Scaleway backups project (codefloe-k8s-backup-nl-ams bucket), 3x daily.
# Add backup to a namespace
just add-backup <namespace>
k8up runs in opt-in mode (BACKUP_SKIP_WITHOUT_ANNOTATION=true), so only PVCs annotated k8up.io/backup=true are backed up.
Keep that setting in sync with the cluster: in opt-out mode k8up snapshots every PVC in the namespace, including ones already covered by pgBackRest and ones whose RWO volume is held by a running pod.
Those backup pods then block the workload's own pod from attaching its volume.
Annotate PVCs from a CronJob rather than by hand or from a one-shot Job (see argocd-apps/weblate/pvc-annotations.yaml).
A Job's pod template is immutable, so just apply cannot update it and it never runs a second time, which leaves PVCs created later by an operator unannotated.
The k8up-backup-credentials and backup-repo secrets a schedule needs are managed by VSO through each app's secrets.yaml.
Never create them with kubectl create secret: VSO refuses to write to a Secret it does not own and reports SecretSyncError ... invalid owner label.
Postgres
The Crunchy clusters (zitadel, harbor, weblate, zendrite) back up with pgBackRest into codefloe-k8s-pgbackrest-nl-ams.
The scheduled backups go to repo2 under /pgbackrest-encrypted/<app>, encrypted client-side with aes-256-cbc.
The passphrase lives in OpenBao at k8s/prod/<app>/pgbackrest (field cipher_pass) and reaches the cluster through the <app>-pgbackrest-cipher secret.
Without it repo2 cannot be restored, and changing it in place makes every existing backup unreadable, so never rotate it.
Longhorn
Longhorn backs up to codefloe-k8s-longhorn-backup-nl-ams daily, and a backup is only encrypted when its volume is.
Every volume from the longhorn-retain and longhorn-encrypted StorageClasses joins the backup job, so volumes that need no Longhorn backup have the label removed by hand:
kubectl --context codefloe -n longhorn-system label volumes.longhorn.io <pvc-...> recurring-job.longhorn.io/backup-
Keep Longhorn backups only for volumes nothing else covers and whose contents are encrypted:
openbao/data-openbao-*: the Raft store is sealed by the barrier key, so the backup is ciphertext.- Volumes on the
longhorn-encryptedStorageClass (serelane/serelane-data): LUKS2 inside Longhorn, key atk8s/prod/longhorn/crypto, so the backup is ciphertext.
Everything else is excluded:
- Crunchy
*-pgdatavolumes, covered by the encrypted pgBackRestrepo2. - Volumes K8up already backs up (
openstatus/data-openstatus-libsql-0,weblate/weblate-rwx). - Caches and rebuildable state: every Valkey, Harbor Trivy and jobservice, Typesense (rebuilt from Forgejo), the OpenStatus Tinybird ClickHouse and Redis, and the OpenBao audit logs.
- Unencrypted volumes kept only as a rollback path (
serelane/serelane).
Check new volumes against this list after deploying an app.
Volume auto-resizing
pvc-autoresizer (argocd-apps/pvc-autoresizer) grows PVCs before they fill up.
Once a minute it reads kubelet_volume_stats_* from the control-plane-metrics Prometheus, which scrapes them from every kubelet (job kubelet-volume-stats).
It resizes a PVC only when both of these hold:
- its StorageClass carries
resize.topolvm.io/enabled: "true". That coverslonghorn-retain,longhorn-encrypted,longhorn-retain-r1,hcloud,hcloud-retain-nbg1andhcloud-retain-fsn1, plus app-owned classes such aszendrite-media. - the PVC carries
resize.topolvm.io/storage_limit, the hard cap.
A PVC without the limit annotation is never resized, so existing volumes keep their size until someone gives them a cap. To opt a volume in, annotate the PVC, or set the annotation in the chart's PVC template so it survives a recreate:
metadata:
annotations:
resize.topolvm.io/storage_limit: 20Gi
# Optional; the defaults are 10% and 10%.
resize.topolvm.io/threshold: 15% # grow when less than this is free
resize.topolvm.io/increase: 20% # grow by this much
A volume that no pod has mounted reports no stats and is not resized.
Longhorn expands RWX volumes online since v1.8 (the share-manager grows the NFS export), and kubelet reports stats for them from every node that mounts them.
longhorn-encrypted expands online too, because the class passes node-expand-secret-* to the CSI node plugin.
The shared StorageClass annotations live in argocd-apps/longhorn/storageClass.yaml (just apply longhorn) and custom-yaml/storageClasses.yaml (kubectl apply -f).
The module-owned hcloud class gets its annotation from an annotation-only entry at the end of the latter.
Crunchy Postgres volumes
Never put storage_limit on a Crunchy *-pgdata PVC.
PGO force-applies the PVC size from the PostgresCluster on every reconcile, so a resize from outside makes it try to shrink the volume, which fails and leaves a "cannot be resized" condition for good.
pgdata volumes grow through PGO's own AutoGrowVolumes feature gate instead, enabled in argocd-apps/cdpg/cdpg.yaml.
PGO grows an instance set's volume by 50% once it passes 75% full, but only when the PostgresCluster sets a limit, which is also the cap:
dataVolumeClaimSpec:
resources:
requests:
storage: 3Gi
limits:
storage: 10Gi
zendrite is the only cluster with a limit (3Gi → 10Gi).
zitadel, harbor and weblate set none, so for them the gate changes nothing until someone adds one.
zendrite also keeps WAL on its own fixed-size walVolumeClaimSpec, so a failing archive fills that volume and stops Postgres instead of growing the data volume to its cap; copy that when adding a limit elsewhere.
Caps and capacity
The caps are what stops runaway growth, for example pg_wal piling up while WAL archiving fails, or a log volume that is never rotated.
Without them a volume would grow until Longhorn or the Hetzner bill stopped it.
Size the Longhorn caps so that they fit the cluster without over-provisioning. Each worker has 72–74 GiB of Longhorn disk minus the 25% reservation, about 54–56 GiB, which makes about 385 GiB across the seven workers. A volume takes its size once per replica, so the budget is:
sum over Longhorn volumes of (cap, or current size if uncapped) × numberOfReplicas ≤ 385 GiB
On 2026-11-12, 205 GiB of that was scheduled, which includes the detached 10 GiB × 3 ClickHouse volume left behind by the move to hcloud-retain-nbg1.
zendrite adds up to 87 GiB at its caps, which leaves roughly 40 GiB for caps on the volumes that have none yet.
pgdata limits count once per instance, since longhorn-retain-r1 (and the hand-set zitadel volumes) keep a single replica.
Longhorn's over-provisioning setting is 100%, so it refuses to grow a replica past the room left on its node, and the expansion then stays pending.
Hetzner volumes draw from no shared pool, so their caps only bound the cost.
Watching it
The control-plane-metrics Prometheus also scrapes pvc-autoresizer itself (job pvc-autoresizer).
There is no Alertmanager in this cluster, so nothing pages on these; check them from Grafana:
# PVCs sitting at their cap (the counter rises on every loop that finds one there).
increase(pvcautoresizer_limit_reached_total[10m]) > 0
# Resizes the API server or the CSI driver rejected.
increase(pvcautoresizer_failed_resize_total[1h]) > 0
# Any volume, capped or not, with less than 10% free.
kubelet_volume_stats_available_bytes / kubelet_volume_stats_capacity_bytes < 0.1
Networking
Envoy Gateway
Envoy Gateway is the cluster ingress controller and exposes every public service through the codefloe-edge Gateway.
The Gateway terminates wildcard certificates for *.codefloe.com and *.renovate.codefloe.com, and application charts create HTTPRoute or GRPCRoute resources in their own namespaces.
The Gateway API resources depend on CRDs installed by the Envoy Gateway chart, so install the controller without the Gateway first:
# Create only the Argo CD Application and let it install the CRDs.
kubectl --context codefloe apply -f argocd-apps/envoy-gateway/envoy-gateway.yaml
# Wait for the chart and its CRDs.
kubectl --context codefloe wait --for=condition=Established --timeout=5m crd/gateways.gateway.networking.k8s.io
# Enable cert-manager's Gateway integration before creating the listeners.
just apply cert-manager
Floatilla and the public IPv4 address
Public ingress runs on a Hetzner floating IP (codefloe-ingress-v4, 49.13.38.102), not a managed Load Balancer.
Cilium LB-IPAM assigns the floating IP as the frontend of the codefloe-edge Envoy Service, Cilium L2 announcements elect which node advertises it, and the floatilla controller attaches the Hetzner floating IP to that same node.
The Envoy data plane is a DaemonSet on the worker-x86-cx-small nodepool rather than a Deployment: the Service sets externalTrafficPolicy: Local, so the announcing node must always have a local Envoy backend, and a Deployment with a fixed replica count cannot guarantee that.
The Service also sets loadBalancerClass: io.cilium/l2-announcer so the hcloud CCM does not claim it and provision a second paid Load Balancer.
Ingress is IPv4-only: the cluster is single-stack, and the AAAA records for codefloe.com and its subdomains were withdrawn when traffic cut over to the floating IP.
See argocd-apps/floatilla/floatilla.yaml for the LB-IPAM pool and L2 announcement policy, and argocd-apps/envoy-gateway/gateway-floatilla.yaml for the codefloe-edge EnvoyProxy, GatewayClass, and Gateway definitions.
Harbor Proxy Cache Access Control
The Harbor registry (cr.codefloe.com) proxy cache paths (/v2/docker.io/, /v2/ghcr.io/ and /v2/data.forgejo.org/) are restricted to CI nodes only.
Allowed IPs: hades, artemis, cf-iac-deploy (the deployment host), ci-arm1, the devxy-local PVE hosts (zeus, hera, apollo, poseidon) that run the codefloe-ci-1/2 runners, every node of this cluster on both its public and its private address, and the pod CIDR.
A node needs both because kubelet pulls over the hcloud private network and so arrives as its private address.
The pod CIDR covers both in-cluster clients that reach the Gateway directly, such as Renovate, and the tailnet path described below.
The authoritative list is proxy-cache-allowlist.tf, which renders an Envoy Gateway SecurityPolicy against the dedicated proxy-cache HTTPRoute.
Demeter and minerva were dropped from it when they were sold.
Tailnet Access to Cluster Services
Tailnet peers reach in-cluster ClusterIPs through a Tailscale subnet router running as a pod in the tailscale namespace.
It advertises the Kubernetes service CIDR 10.30.96.0/19 to Headscale (https://headscale.devxy.io), so a host such as git can talk to a ClusterIP directly, with no ingress, certificate or IP allowlist involved.
The first consumer is Forgejo reaching Typesense.
Full setup, the pre-auth key and route-approval requirements, and why this is a pod rather than the siderolabs/tailscale Talos extension: argocd-apps/tailscale/README.md.
Peers that need these routes must run tailscaled with --accept-routes.
Dynamic-IP Clients (gaia)
A host whose public address is dynamic cannot be named in the proxy-cache allowlist, and pinning one anyway is how a third party briefly inherited a rate-limit exemption when Hetzner reassigned demeter's IP.
gaia, the arm64 Crow agent, is such a host: a Mac mini on a domestic line.
It reaches the registry over the tailnet instead of from a static public IP. The predecessor of this setup routed gaia's traffic through demeter so it would egress from an allowlisted address; demeter was sold on 2026-07-27 and nothing replaced it. This path does not need a static egress anywhere, because it never leaves the mesh:
- The subnet router above advertises
10.30.96.0/19, so the whole service CIDR is reachable from the tailnet. codefloe-edge-tailnet(argocd-apps/envoy-gateway/service-tailnet.yaml) publishes the Envoy edge on a fixed ClusterIP,10.30.96.20, that survives the Gateway being recreated.- gaia runs with
--accept-routesand pinscr.codefloe.comto that address in/etc/hosts. TLS is untouched: the name, the SNI and the certificate are the same ones the public listener serves. - The subnet router SNATs what it forwards, so Envoy sees its pod IP, and the pod CIDR is allowlisted in
proxy-cache-allowlist.tf.
The trade is that gaia now depends on the mesh for the registry: pinning in /etc/hosts removes the public address as a fallback.
Two router replicas with hard anti-affinity cover a node drain; losing both means gaia cannot pull until one returns.
Any other dynamic-IP client can join the same path by repeating steps 3 and 4's client half -- --accept-routes plus the /etc/hosts pin.
On macOS, check the routes it accepts before enabling it: gaia-lifeline advertises 192.168.1.87/32 and 192.168.139.3/32, which are gaia's own LAN and OrbStack bridge addresses, so accepting routes sends part of gaia's local traffic out to the lifeline box and back.
When gaia's pulls fail
A pull that fails on gaia with a bare Bad Gateway, without a status code, such as failed to do request: Head "https://cr.codefloe.com/v2/...": Bad Gateway, never reached the cluster.
OrbStack's Docker sends registry traffic through OrbStack's own proxy on the Mac (proxy.orb.internal:8305), and that proxy answers 502 when the Mac cannot open the connection to 10.30.96.20.
A 502 from Envoy or Harbor reads unexpected status ... 502 Bad Gateway instead.
The usual cause is gaia being off the tailnet: check with tailscale status from a subnet router pod, where gaia is 100.64.0.5.
From 2026-11-07 to 2026-11-11 gaia's Tailscale was switched off while still logged in, and its Crow agent kept taking jobs and failing uncached pulls.
gaia-lifeline still reaches gaia when it is off the tailnet: ssh [email protected] lands on the Mac through the lifeline's OrbStack-bridge route.
The macmini-host role in ansible/internal now runs a tailnet guard that turns Tailscale back on and alerts through ntfy.
kubectl logs is a poor witness for public pulls: all public traffic lands on the one Envoy pod on the node that holds the Cilium L2 lease (kubectl -n kube-system get lease | grep l2announce), and crawler traffic there rotates its container log within minutes.
The other two Envoy pods keep hours of logs and show the tailnet path, arriving from the subnet router pod IPs.
A run of about ten HEAD .../blobs/<digest> 404s from harbor-core in the registry log, about 21 seconds apart, followed by a blob PUT 201, is not a fault either.
It is Harbor's proxy cache waiting for a layer the client already had locally and so never fetched through Harbor, then fetching it from upstream itself.