Moving the cluster onto GitOps

Where it started

The cluster’s applications were first installed by hand with helm install, one command at a time, with the settings kept in files in a Git repository. Git had the intended state, but nothing made the cluster actually match it. Anything changed by hand drifted silently, and rebuilding the cluster would mean a manual rebuild.

The goal

I wanted Git to be the single source of truth for what runs in the cluster. A change should only take editing a file and pushing it, undoing it should be a revert, and rebuilding from scratch should just mean pointing a fresh cluster at the repository.

How it works now

I used Argo CD with the app of apps pattern. One root application watches a folder in the repository; every file in that folder defines another application, such as Immich, Gitea, the monitoring stack or Loki. Adding an application to the cluster = new file

Each application syncs automatically, removes resources that were deleted from Git, and corrects anything changed by hand. The homelab page shows which components are deployed this way, and the live count of applications in sync with Git.

What went wrong

The migration itself caused an outage, because I moved seven applications to Argo CD at once. Argo CD rendered each Helm chart, found small differences from what was already running (labels, annotations, ordering) and redeployed all seven at the same moment. On a cluster with little spare memory, that redeploy storm exhausted every node: load averages above 50, with less than 200 MB of memory free. I had to restart k3s on the server node to stop it.

Three more problems surfaced while the cluster recovered:

Takeaways for a prod environment