ArgoCD is a GitOps-based continuous delivery tool for Kubernetes that keeps applications in sync with their declared state in Git. I wrote about ArgoCD a few days ago, explaining what it is and how to set it up. In a GitOps workflow, Git is the single source of truth for your Kubernetes infrastructure. ArgoCD continually syncs and reconciles what’s defined in your Git repository with your cluster.
Deployments don’t always go according to plan, and changes can break the application. In this post, I’ll discuss how to perform a rollback using ArgoCD.
The GitOps Philosophy
The idea behind GitOps is that your cluster should always reflect what’s defined in Git. Rather than making manual changes to deployed resources, you define the desired state of your application in code, and a tool like ArgoCD applies it to your cluster automatically. This approach has some advantages:
– You can audit changes with Git history
– You always know exactly what’s running
– Rolling back bad deployments is straight forward. You run a git revert
or an ArgoCD rollback command.
Rollback in ArgoCD
A rollback in ArgoCD means ArgoCD syncs a previous version of an application to the cluster using its Git commit. It checks out the last good commit and reapplies it to the cluster.
In some instances, it may be a good idea to disable auto syncing when troubleshooting failed deployments. To do this, run
argocd app set <app-name> --sync-policy none
To inspect the deployment history, run
argocd app history <app_name>
replacing <app_name>
with the name of your application. This command shows a list of numbered revisions. To rollback, take note of the number of the good revision and run
argocd app rollback <app_name> <revision_number>
replacing app_name and revision_number with the correct values for your application.
This will reapply the good version and bring the cluster back up. To clean up the broken state in Git, you can undo the changes using git revert:
git revert <bad-commit-sha> git push
This ensures that your Git history accurately reflects the fix. If you had disabled auto sync, re-enable it:
argocd app set <app-name> --sync-policy automated
Conclusion
ArgoCD makes rollbacks simple — but only if your Git repo is well-maintained. To make rollbacks easy, ensure your Git commits are small and intentional.