Skip to content
~/supporterino

One moved YAML file pruned my whole cluster

4 min read

kubernetes · gitops · homelab

← all posts

At 13:53 I merged a commit that moved one catalog file. By 14:05 the cluster had no CNI, no ingress, no Argo CD and no GitLab.

What the commit did

The Helm release ApplicationSet reads its chart catalog through a git file generator:

generators:
  - matrix:
      generators:
        - git:
            repoURL: ssh://git@git.example.internal/ops/cluster.git
            files:
              - path: argocd/generators/charts.yml
        - list:
            elements: []
            elementsYaml: "{{ .charts | toJson }}"

The commit moved charts.yml from argocd/apps/ to argocd/generators/ and changed that path in the same commit, because it looked atomic. It is not. The ApplicationSet object is updated through the Kubernetes API, while the repo-server resolves the generator path against a git checkout it fetched on its own. For a window, the new spec ran against a tree that no longer had the new file at that path.

A git file generator that matches nothing returns zero parameters instead of an error. Zero parameters produce zero Applications, and Argo CD deletes the Applications a generator no longer produces. No sync failed. The resources were gone.

Why the blast radius was total

Cilium, Argo CD, Traefik, GitLab and the observability stack sat in the same catalog as Jellyfin and Immich. Killing the catalog killed the CNI that lets the controller talk to the nodes, and Argo CD deleted itself mid-cascade.

None of the Applications had preserveResourcesOnDeletion, which exists on the ApplicationSet and not on a plain Application, and none carried a preserving finalizer policy. Deleting an Application cascaded into every resource it owned. Both storage classes still said reclaimPolicy: Delete.

Kustomize-managed apps survived. Their generator scans directories, and a directory scan of a repo snapshot does not go empty because one file moved.

The volumes survived by accident

51 PVCs and 51 PVs came through, and not because of a backup. With every DaemonSet deleted, the CSI node plugin was gone, so no volume could unmount. The pods stuck in Terminating held their pvc-protection finalizers. The CSI controller was gone too, so PVC finalisation never completed. A dead cluster froze storage that a healthy one would have deleted.

One database did not make it: a 1 GiB dev dataset was deleted before I patched the PVs. Everything else I could account for.

The recovery order

  1. Every PV to Retain, 51 of 51. This was the only action that mattered.
  2. Every PV compared against its ZFS dataset by name and used size. One PV had no dataset; the rest matched.
  3. Cilium first, as helm template piped into server-side apply. helm upgrade would have hit a stale release record from chart 1.17.2 while the catalog pointed at 1.20.5.
  4. Storage and controllers next. Restoring the CSI controller and the snapshot controller let 16 Terminating PVCs finalise and their PVs go Released, data intact.
  5. 8 CNPG clusters rebuilt with bootstrap.recovery.volumeSnapshots from CSI snapshots, then workloads in batches: plumbing, observability, identity and data.

Git had the cluster back at 17:00, about 3 hours after the merge.

What changed in the repo

preserveResourcesOnDeletion: true on every ApplicationSet, and reclaimPolicy: Retain on both storage classes, which is immutable and had to be recreated. The old validator ran find at a depth the kustomization files never reach, so its kustomize build and duplicate-name checks iterated over zero apps and passed. It now asserts a non-zero Application count. And one review rule: a generator input never moves in the same commit as the path pointing at it. Copy, switch, verify, delete.

What is still open

Splitting cluster-critical releases into their own ApplicationSet with prune: false was deferred the same day, so preserveResourcesOnDeletion is the only guard in place. It has not been proven under a real sync: a deny sync window exists on the live AppProject and not in the repo, permanently active, blocking manual syncs too. The guard and the thing that would test it cannot run at the same time.