GitOps with Argo CD: a practical guide to moving beyond kubectl apply
Understand the pull-based deployment model, set up your first Application in Argo CD, and avoid the most common mistakes of teams getting started with GitOps.
Kubernetes$ argocd app sync api-prod▍If your team still deploys by running kubectl apply from someone’s laptop, you already know the problem: nobody is quite sure what is running in the cluster. GitOps solves this with a simple idea — the Git repository becomes the single source of truth, and an agent inside the cluster ensures the actual state converges to the declared state.
Push vs. pull
In the traditional (push) model, the CI pipeline is given cluster credentials and pushes the changes. In the pull model, Argo CD runs inside the cluster, watches the repository, and applies whatever has changed. The result: CI no longer needs admin access to Kubernetes, and every deployment becomes an auditable commit.
Your first Application
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: api-prod
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/your-org/k8s-manifests
targetRevision: main
path: apps/api/overlays/prod
destination:
server: https://kubernetes.default.svc
namespace: api
syncPolicy:
automated:
prune: true
selfHeal: true
With selfHeal: true, any manual change in the cluster is automatically reverted. With prune: true, resources removed from Git are also removed from the cluster.
Common mistakes
- Mixing code and manifests in the same repository. Keep them separate: the application pipeline builds the image and opens a PR in the manifests repository that updates the tag.
- Plain-text secrets in Git. Use Sealed Secrets, SOPS, or the External Secrets Operator.
- Enabling
prunewithout review. Start with manual sync in production until you gain confidence.
Where to start
Install Argo CD on a staging cluster, migrate a low-criticality service, and only then expand. The App of Apps pattern (or ApplicationSet) helps you scale once you have dozens of services.
GitOps is not a tool, it’s a contract: if it’s not in Git, it doesn’t exist.