I spent a considerable amount of time setting up my home lab with a high degree of infrastructure and deployment “as code.” Googling “Infrastructure as Code” or “Declarative GitOps” will highlight the breadth of this topic, and I have no less than 10 different posts on my current setup. So what did all this effort get me?
Effortless Updates
A quick Powershell script lets me update my GitOps repositories with the latest versions of the applications I am running. With the configurability of ArgoCD, however, those updates are not immediately rolled out. My ArgoCD configurations are setup for manual sync, which gives me the ability to compare changes before they are applied.
Could I automatically sync? Well, sure, and 9 times out of 10, it would work just fine. But more than once, I ran into updates which required some additional preparation or conversion, so I still have the ability to hold off on upgrades until I am ready.
Helpful Rollbacks
Even after synchronization, sometimes things do not go according to plan. Recently, as an example, an upgrade to Argo 2.12 broke my application sets because of a templating issue. Had I been manually managing my applications, that would have meant a manual downgrade or a hacky workaround. Now, well, I just rolled back to the previous version that I had deployed and will patiently await a fix.
Disaster Recovery
My impatience caused me to wreck my non-production cluster beyond repair. With my declarative GitOps setup, restoring that cluster was pretty simple:
- Create a new cluster
- Add the new cluster to ArgoCD
- Modify the cluster secret in Argo with labels to install my cluster tools
- Modify the applications to use the new cluster URL
As it was my non-production instance, I did not have any volumes/data that needed transferred over, so I have not yet tested that particular bit. However, since my volumes are mounted with consistent name generation, I believe data transfers should work equally well.
Conclusion
Even in my home lab, a level of “as code” helps keep things running smoothly. You should try it!