GitOps with ArgoCD: Declarative Kubernetes Deployments

Khimananda Oli 7 min read Database
GitOps with ArgoCD: Declarative Kubernetes Deployments

By Khimananda Oli | Last reviewed: August 2026

Managing cluster state through imperative kubectl apply commands or external CI pipelines creates drift, audit gaps, and deployment anxiety at scale. GitOps with ArgoCD: Declarative Kubernetes Deployments solves this by making Git the single source of truth and continuously reconciling live cluster state against versioned manifests. If you have already established a solid foundation with Kubernetes basics, adopting ArgoCD is the definitive next step to eliminate configuration drift and enforce compliance.

What is GitOps with ArgoCD and why use it for declarative Kubernetes deployments?

GitOps extends Infrastructure as Code principles specifically to application delivery on Kubernetes. While tools like Terraform excel at provisioning infrastructure—a topic I cover in my Infrastructure as Code with Terraform guide—ArgoCD handles the continuous delivery of applications onto that infrastructure. The core distinction is the "pull" model: instead of a CI server pushing changes into your cluster (which requires broad credentials), ArgoCD pulls definitions from Git and applies them locally within the cluster boundary.

Git RepositorySource of Truth(Manifests/Helm)ArgoCD ControllerReconciliation Loop(In-Cluster)K8s ClusterLive State(Pods/Svcs/Ingress)PullSyncObserve
GitOps with ArgoCD architecture: The controller pulls from Git and reconciles against live cluster state continuously.

In practice, this means your CI pipeline only builds container images and updates image tags in Git. It never touches the cluster directly. ArgoCD detects the commit, renders the manifests (supporting plain YAML, Helm, Kustomize, or Jsonnet), and applies the diff. This separation of concerns drastically reduces the attack surface and makes every deployment auditable via git history.

How do you install and configure ArgoCD for production clusters?

Avoid clicking through UI wizards for production setups. Use the official Helm chart or Kustomize overlay to manage ArgoCD itself via GitOps. This ensures your delivery tool is as reproducible as your applications.

helm repo add argo https://argoproj.github.io/argo-helm
helm repo update

helm install argocd argo/argo-cd \
  --namespace argocd --create-namespace \
  --set server.extraArgs[0]=--insecure \
  --set configs.params."server\.disable\.auth"=false \
  --version 7.8.0

After installation, retrieve the initial admin password and expose the server securely. Never leave the default password active beyond bootstrap. For teams managing multiple environments, consider the "App of Apps" pattern where a root Application resource manages child Applications for staging, production, and monitoring stacks.

Essential Security Hardening

  • Disable local accounts: Integrate with OIDC (Keycloak/Auth0) immediately after bootstrap.
  • RBAC policies: Restrict sync permissions per team/project; avoid granting cluster-admin to developers.
  • Network policies: Limit egress from the ArgoCD namespace to only required Git hosts and container registries.
  • Secret management: Never store secrets in Git. Use External Secrets Operator or Sealed Secrets alongside ArgoCD.

How do you define an Application CRD for declarative synchronization?

The Application Custom Resource Definition is the heart of GitOps with ArgoCD: Declarative Kubernetes Deployments. It declares what to deploy, where to deploy it, and how to reconcile differences.

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: payment-service-prod
  namespace: argocd
spec:
  project: payments
  source:
    repoURL: 'https://github.com/myorg/payment-service.git'
    targetRevision: HEAD
    path: k8s/overlays/prod
    kustomize:
      patches:
        - target:
            kind: Deployment
            name: payment-api
          patch: |-
            - op: replace
              path: /spec/template/spec/containers/0/image
              value: myregistry/payment-api:v2.4.1
  destination:
    server: 'https://kubernetes.default.svc'
    namespace: payments-prod
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
    syncOptions:
      - CreateNamespace=true
      - RespectIgnoreDifferences=true

Key fields demand attention. selfHeal: true forces the cluster back to Git state if someone manually edits a resource—critical for compliance. prune: true removes resources deleted from Git, preventing orphaned objects. Always set RespectIgnoreDifferences=true when controllers (like cert-manager or HPA) modify fields dynamically; otherwise, ArgoCD will fight them in an endless sync loop.

Git CommitArgoCD DetectDiff & RenderApply SyncSelf-Healing LoopManual edit detected → Revert to GitDrift alert → Auto-sync triggeredHealth check failed → Rollback optionContinuous Watch
ArgoCD reconciliation sequence: Detection, rendering, syncing, and continuous self-healing for declarative Kubernetes deployments.

How do ArgoCD sync waves and hooks prevent deployment failures?

Complex applications require ordered deployments. Database migrations must complete before API pods start; ConfigMaps must exist before Deployments reference them. Sync waves solve this declaratively.

  1. Annotate resources with wave order: Add argocd.argoproj.io/sync-wave: "-1" to prerequisites (namespaces, secrets, CRDs).
  2. Define main app wave: Set Deployments/Services to wave "0" (default).
  3. Post-deploy tasks: Use wave "1" for smoke tests, cache warming, or notification jobs.
  4. Add hooks for lifecycle events: Use PreSync, Sync, PostSync annotations for scripts that run outside normal reconciliation.
# Example: Database migration job running before app deployment
apiVersion: batch/v1
kind: Job
metadata:
  name: payment-db-migrate
  annotations:
    argocd.argoproj.io/sync-wave: "-1"
    argocd.argoproj.io/hook: PreSync
    argocd.argoproj.io/hook-delete-policy: HookSucceeded
spec:
  template:
    spec:
      containers:
        - name: migrate
          image: myregistry/payment-api:v2.4.1
          command: ["./migrate", "--up"]
      restartPolicy: Never
  backoffLimit: 3

A common mistake is forgetting hook-delete-policy. Without it, completed Jobs persist and block future syncs. Always pair PreSync hooks with deletion policies. For zero-downtime requirements, combine sync waves with proper readiness probes—a pattern also essential when you implement zero-downtime deployments in traditional PHP environments.

How does ArgoCD compare to Flux and Jenkins for Kubernetes delivery?

Choosing the right tool depends on team size, compliance needs, and existing ecosystem. Here is a practical comparison based on production usage across multiple clients:

CriteriaArgoCDFlux v2Jenkins + kubectl
Deployment ModelPull-based, in-cluster controllerPull-based, modular controllersPush-based from external agent
UI & VisualizationExcellent real-time topology viewCLI-first, limited UIPipeline-centric, no cluster view
Multi-cluster SupportNative ApplicationSet + Cluster APINative via GitRepository sourcesRequires custom scripting/agents
Learning CurveModerate (CRDs + UI)Steeper (multiple controllers)Low entry, high maintenance
Compliance Audit TrailBuilt-in sync history + RBAC logsGit-native, fewer UI logsPipeline logs only, fragmented
Best ForTeams needing visibility + compliancePlatform engineers building PaaSLegacy shops not ready for GitOps

For most teams adopting GitOps with ArgoCD: Declarative Kubernetes Deployments offers the fastest time-to-value due to its superior UI and straightforward CRD model. Flux excels when building internal developer platforms with deep customization. Jenkins should be retired for Kubernetes delivery unless organizational constraints prevent change.

Push Model (Jenkins/CI)CI Server holds cluster credentialsWide network access requiredAudit trail scattered across pipelinesHigher attack surfacePull Model (ArgoCD)Credentials stay inside clusterOnly outbound Git access neededUnified sync history + RBACCompliance-ready by designWhy Pull Wins for ProductionSOC2/ISO27001 auditors prefer contained blast radiusNo persistent external access to K8s API
Push vs Pull deployment security comparison: Why GitOps with ArgoCD declarative Kubernetes deployments reduce compliance risk.

Getting Started with GitOps with ArgoCD: Declarative Kubernetes Deployments

Start small: pick one non-critical service, define its Application CRD, enable automated sync with self-healing, and observe the reconciliation behavior before expanding. Invest early in proper RBAC, OIDC integration, and secret management—retrofitting these later causes painful migrations. Monitor ArgoCD itself using Prometheus metrics; alert on sync failures and health degradation just as you would for any production workload. If you need guidance integrating observability, review my Prometheus and Grafana setup guide to ensure your GitOps controller remains visible.

GitOps with ArgoCD: Declarative Kubernetes Deployments transforms Kubernetes from a fragile collection of manual commands into a predictable, auditable, self-healing platform. The initial learning curve pays exponential dividends in reduced incidents, faster recovery, and confident compliance posture. Ready to implement this in your environment? Contact me to discuss architecture review, secure ArgoCD rollout, or compliance-aligned GitOps adoption tailored to your team’s maturity level.

Frequently Asked Questions

GitOps with ArgoCD uses Git as the single source of truth for declarative Kubernetes deployments. ArgoCD continuously monitors repositories and automatically synchronizes cluster state to match desired configurations defined in YAML or Helm charts without manual kubectl commands.

ArgoCD implements pull-based GitOps where the cluster pulls desired state from Git, unlike Jenkins which pushes changes via imperative scripts. This provides continuous reconciliation, better audit trails, and eliminates credential storage on CI servers for production cluster access.

Yes, ArgoCD is open-source and free under Apache 2.0 license. Enterprise features like SSO, RBAC policies, and multi-cluster management are available through paid distributions but core GitOps synchronization functionality remains completely free for production use in 2026.

ArgoCD v3.2 supports Kubernetes 1.28 through 1.33. Always check the official compatibility matrix before upgrading clusters, as newer ArgoCD releases may drop support for end-of-life Kubernetes versions to maintain security and API compatibility.

Run kubectl create namespace argocd followed by kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml. Access the UI via port-forward or ingress, then retrieve the initial admin password from the argocd-initial-admin-secret.

Yes, ArgoCD manages external clusters by registering them with argocd cluster add command using service account tokens. Each cluster gets its own application definitions while maintaining centralized GitOps control from a single management plane instance.

ArgoCD natively supports Helm by specifying chart name, version, and values files in Application manifests. It renders templates server-side and applies resulting resources, enabling parameterized deployments while keeping all configuration declarative and version-controlled in Git repositories.

ArgoCD detects drift during sync cycles and can either alert operators or auto-correct based on sync policy settings. Manual changes made via kubectl get overwritten on next reconciliation unless explicitly ignored through annotation exclusions or resource customizations.

Never commit plaintext secrets. Use Sealed Secrets, External Secrets Operator, or SOPS to encrypt sensitive data before committing. ArgoCD decrypts at sync time using cluster-side keys, keeping credentials out of Git history while maintaining declarative workflows.

No, ArgoCD only manages Kubernetes-native resources. For infrastructure like databases or cloud services, pair it with Crossplane or Terraform Controller to extend GitOps patterns beyond cluster boundaries while keeping ArgoCD focused on application deployment orchestration.

Check application status with argocd app get command and review sync logs in UI or CLI. Common issues include invalid YAML syntax, missing CRDs, insufficient RBAC permissions, or network connectivity problems preventing Git repository access or image registry pulls.

Yes, ArgoCD has native Kustomize support. Specify kustomization.yaml path in Application spec and ArgoCD builds overlays automatically. This enables environment-specific configurations without duplicating base manifests, fitting perfectly into declarative GitOps workflows for staging and production environments.

Default polling interval is three minutes. Configure spec.source.repoURL polling frequency per application or globally via argocd-cm ConfigMap. Webhooks provide instant notifications instead of polling, reducing latency between Git commits and cluster synchronization significantly.

Yes, revert the Git commit containing unwanted changes and ArgoCD automatically syncs to previous known-good state. Alternatively, use argocd app rollback command to restore specific revision without modifying Git history, useful for emergency recovery scenarios.

ArgoCD needs cluster-wide read access plus write permissions for managed namespaces. Create dedicated ClusterRole binding with least-privilege principles. Avoid granting full cluster-admin; instead scope permissions to specific resource types and namespaces your applications actually deploy and manage.