GitOps
GitOps is a modern way to manage your infrastructure and applications where a Git repository acts as the single source of truth for your entire system.
Instead of manually typing commands (like kubectl apply -f deployment.yaml) to install or update apps in your cluster, you use GitOps. Here is how it works in practice:
- Declarative State: You write configuration files (YAML) that describe exactly how you want your cluster to look (e.g., "I want Jellyfin running, and I want an NGINX Ingress pointing to it"). You commit these files to a Git repository (like GitHub or a self-hosted Git server).
- The Software Agent: You install a GitOps tool—like Argo CD or Flux inside your Kubernetes cluster.
- Continuous Synchronization: The GitOps agent constantly watches your Git repository. If it notices that the files in Git don't match what is currently running in your cluster, it automatically pulls the changes and updates the cluster to match Git.
Why is it so popular for Homelabs?
- Disaster Recovery (The biggest benefit): If your hardware completely dies and you lose your cluster, you don't have to remember how to rebuild it. You just install a fresh Kubernetes cluster, install your GitOps agent, point it at your Git repo, and go make a coffee. The agent will read the repo and automatically reinstall everything exactly as it was.
- Easy Rollbacks: Did a Nextcloud update break everything? Just use
git revertto undo the commit, and your cluster will automatically downgrade back to the working version. - Audit Trail: You can look at your
git logand see exactly when a setting was changed, what the change was, and why it was changed. - No "Configuration Drift": If someone manually changes a setting in the cluster using the command line, the GitOps agent will notice it doesn't match Git and will immediately overwrite the manual change, forcing everything to stay synchronized with the repository.
In short: GitOps means managing your servers feels exactly like writing code!