GitOps with ArgoCD: Automating Kubernetes Deployments

View profile for Lendy Pradhana Hartono

AIOps | DevOps Engineer | Helps companies managing infra with AI Solution

We all heard people using GitOps with ArgoCD or FluxCD but most don't fully understand the problem it solves. Earlier, people ran deployments from Jenkins pipelines via kubectl commands. You authenticate to Kubernetes, push the image to ECR, then run kubectl commands to update the deployment. That's it. But see, you can only trigger the deployment. You cannot monitor it. You cannot ensure what has happened. If something fails, you have to manually undo it. And when you do lot of things manually, lot of things can go bad. Also think about the security part. You need to store AWS credentials in Jenkins. You need to store Kubernetes credentials. Developers need access to the cluster so you create roles and permissions at Kubernetes level. Extra work and not that flexible. The major issue in this approach was the drift. Suppose you deployed a new image with commit ID xyz. Stakeholders are thinking this commit is running in production because they see it in Git. But what if someone went to kubectl and manually changed the deployment? Now a different version is running. Nobody knows. There's no way to ensure what's actually there. That's where GitOps concept came. The idea is simple - Git should become the single source of truth. Not Kubernetes. Not the production environment. Git. Whatever you see in the main branch, that has to be running in Kubernetes. By default. Without any exception. Nobody can override that. ArgoCD does this job. You install ArgoCD in your Kubernetes cluster. It automatically keeps watching GitHub. When it sees a change in the image tag, it pulls that change and deploys the new image. Keeps trying until it goes through. If deployment fails, it creates alerts. If someone manually changes the deployment, ArgoCD sees the drift and puts it back automatically. That's called self-healing. Now developers don't need Kubernetes credentials. They just need access to ArgoCD UI. They can see the deployment status, check the logs. That's all they need to see. And here's the good part - one ArgoCD instance can manage multiple clusters. You don't have to run ArgoCD in all 10 environments. Just one is enough. The whole concept is to trust Git only. Make Git the single source of truth. Everything else should align with that. #devops #gitops

To view or add a comment, sign in

Explore content categories