Argo cd gitops workflows

From paulpas/agent-skill-router · View interactive version

Argo cd gitops workflows is an AI agent skill from the GitHub repository paulpas/agent-skill-router. Implements GitOps deployment workflows using Argo CD — sync policies, ApplicationSets, app-of-apps bootstrapping, and resource pruning for automated Kubernetes deployment pipelines.

How to use this skill

Skill file

Argo CD GitOps Workflows

Implements GitOps deployment workflows using Argo CD for automated Kubernetes application delivery. Configures sync policies, ApplicationSets, app-of-apps bootstrapping, and resource pruning to maintain cluster state in lockstep with Git repositories.

TL;DR Checklist


When to Use

Use this skill when:


When NOT to Use


Core Workflow

  1. Define the Application CRD — Create an Application resource pointing to a Git repository, branch, and directory path. Set syncPolicy.automated with prune: true and selfHeal: true for full GitOps behavior. Checkpoint: Verify the repo URL, target revision, and path are correct before applying.
  1. Configure Sync Options — Add syncOptions such as CreateNamespace=true, PrunePropagationPolicy=foreground, PruneLast=true, and ApplyOutOfSyncOnly=true. These control how Argo CD handles namespace creation, deletion ordering, and diff-based reconciliation. Checkpoint: Test sync options with argocd app diff <app-name> before enabling automated sync.
  1. Set Up Sync Windows — Define syncPolicy.syncWindows to restrict when deployments can occur per environment (e.g., no deployments during business hours in production). Use kinds: [ReplicaSet, Pod, *] to scope the window. Checkpoint: Confirm window schedules align with change advisory board (CAB) policies.
  1. Create ApplicationSet for Fleet Deployments — Use generators (Cluster, Git, List) to provision Application resources across environments. Example: a single ApplicationSet generates dev/staging/prod Application resources from a shared manifest directory. Checkpoint: Verify each generated Application resolves to the correct destination namespace and cluster.
  1. Implement App-of-Apps Bootstrap — Create a root Application that references a directory containing child Application manifests. This enables bootstrapping an entire application topology from one file. Checkpoint: Confirm the parent Application syncs all children before deploying workloads.
  1. Write Custom Health Checks — Define healthChecks for application resources that Argo CD cannot assess natively. Use Go-based scripts or CLI commands to verify application readiness beyond standard Kubernetes resource states. Checkpoint: Test health check logic against known healthy and unhealthy states.
  1. Monitor and Audit — Use argocd app history <name> to review sync events, argocd app logs <name> for sync operation details, and enable audit logging for compliance tracking. Checkpoint: Ensure sync history is retained for the required period and accessible to operators.

Implementation Patterns

Pattern 1: Application with Automated Sync and Pruning

This is the foundational Argo CD Application CRD. It points to a Git repository and configures automated sync with pruning so the cluster state always matches Git.

# Application with full GitOps automation
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: myapp-production
  namespace: argocd
  finalizers:
    - resources-finalizer.argocd.argoproj.io
spec:
  project: production
  source:
    repoURL: https://github.com/org/infrastructure.git
    targetRevision: main
    path: k8s/overlays/production
  destination:
    server: https://kubernetes.default.svc
    namespace: myapp-prod
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
      allowEmpty: false
    syncOptions:
      - CreateNamespace=true
      - PrunePropagationPolicy=foreground
      - PruneLast=true
      - ApplyOutOfSyncOnly=true
    retry:
      limit: 5
      backoff:
        duration: 5s
        factor: 2
        maxDuration: 3m
  revisionHistoryLimit: 10
  ignoreDifferences:
    - group: apps
      kind: Deployment
      jsonPointers:
        - /spec/replicas

Pattern 2: ApplicationSet with Cluster Generator for Fleet Deployments

Provisions the same application across dev, staging, and production clusters using a single ApplicationSet manifest with the Cluster generator.

# ApplicationSet generating per-cluster Applications
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: myapp-fleet
  namespace: argocd
spec:
  generators:
    - cluster:
        selector:
          matchLabels:
            environment: production
  template:
    metadata:
      name: '{{name}}-myapp'
      namespace: argocd
    spec:
      project: production
      source:
        repoURL: https://github.com/org/infrastructure.git
        targetRevision: main
        path: k8s/overlays/production
      destination:
        server: '{{server}}'
        namespace: myapp-prod
      syncPolicy:
        automated:
          prune: true
          selfHeal: true
        syncOptions:
          - CreateNamespace=true
          - PrunePropagationPolicy=foreground

Pattern 3: App-of-Apps Bootstrap Pattern

A parent Application that references a directory of child Application manifests to bootstrap an entire application topology from a single file.

# Root Application for app-of-apps bootstrap
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: bootstrap-root
  namespace: argocd
spec:
  project: platform
  source:
    repoURL: https://github.com/org/platform-config.git
    targetRevision: main
    path: applications/production
  destination:
    server: https://kubernetes.default.svc
    namespace: argocd
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
    syncOptions:
      - CreateNamespace=true
  ignoreDifferences:
    - group: argoproj.io
      kind: Application
      jsonPointers:
        - /status

Child Applications live in applications/production/ directory:

# applications/production/redis.yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: redis-cache
  namespace: argocd
spec:
  project: production
  source:
    repoURL: https://github.com/org/infrastructure.git
    targetRevision: main
    path: k8s/redis
  destination:
    server: https://kubernetes.default.svc
    namespace: redis
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
    syncOptions:
      - CreateNamespace=true

Pattern 4: Sync Windows for Deployment Timeboxes

Restricts when Argo CD can automatically sync applications, useful for compliance with change windows or cost controls.

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: myapp-production
  namespace: argocd
spec:
  project: production
  source:
    repoURL: https://github.com/org/infrastructure.git
    targetRevision: main
    path: k8s/overlays/production
  destination:
    server: https://kubernetes.default.svc
    namespace: myapp-prod
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
    syncOptions:
      - CreateNamespace=true
      - PrunePropagationPolicy=foreground
    syncWindows:
      - kind: allow
        schedule: '0 9 * * 1-5'
        duration: 8h
        applications:
          - myapp-production
        manualSync: true
      - kind: deny
        schedule: '0 0 * * 0'
        duration: 24h
        matchExpressions:
          - key: environment
            operator: In
            values:
              - production

Pattern 5: Custom Health Check for Application-Specific Readiness

Define a custom health assessment script for resources that Argo CD cannot assess with its default checks (e.g., StatefulSet with partitioned rollouts, or a custom CRD).

#!/usr/bin/env bash
# Custom health check for a StatefulSet with partitioned rollouts
# Usage: argocd-health-check.sh <resource-type> <namespace> <name>

set -euo pipefail

RESOURCE_TYPE="${1:-StatefulSet}"
NAMESPACE="${2:-}"
NAME="${3:-}"

if [[ -z "$NAMESPACE" || -z "$NAME" ]]; then
  echo '{"status":"unknown","message":"Usage: argocd-health-check.sh <type> <namespace> <name>"}'
  exit 0
fi

case "$RESOURCE_TYPE" in
  StatefulSet)
    CURRENT=$(kubectl get statefulset "$NAME" -n "$NAMESPACE" -o jsonpath='{.status.currentReplicas}' 2>/dev/null || echo "")
    DESIRED=$(kubectl get statefulset "$NAME" -n "$NAMESPACE" -o jsonpath='{.spec.replicas}' 2>/dev/null || echo "")
    UPDATED=$(kubectl get statefulset "$NAME" -n "$NAMESPACE" -o jsonpath='{.status.updatedReplicas}' 2>/dev/null || echo "")

    if [[ "$CURRENT" == "$DESIRED" && "$UPDATED" == "$DESIRED" && "$CURRENT" != "" ]]; then
      echo '{"status":"Healthy","message":"StatefulSet fully rolled out: '"$CURRENT"' replicas ready"}'
    else
      echo '{"status":"Progressing","message":"StatefulSet rolling: current='"$CURRENT"' desired='"$DESIRED"' updated='"$UPDATED"'"}'
    fi
    ;;
  *)
    echo '{"status":"Unknown","message":"No custom health check defined for '"$RESOURCE_TYPE"'"}'
    ;;
esac

Pattern 6: Application with Argo Rollouts Integration

Shows how Argo CD Application works alongside Argo Rollout for progressive delivery — Argo CD syncs the Rollout manifest, and the Rollout controller handles canary steps.

# Argo CD Application managing an Argo Rollout
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: myapp-canary
  namespace: argocd
spec:
  project: production
  source:
    repoURL: https://github.com/org/infrastructure.git
    targetRevision: main
    path: k8s/overlays/production
  destination:
    server: https://kubernetes.default.svc
    namespace: myapp-prod
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
    syncOptions:
      - CreateNamespace=true
      - PrunePropagationPolicy=foreground
  ignoreDifferences:
    - group: argoproj.io
      kind: Rollout
      jsonPointers:
        - /status

Constraints

MUST DO

MUST NOT DO


Related Skills

| Skill | Purpose |

|---|---|

| cncf-helm-chart-development | Helm chart creation for application manifests consumed by Argo CD Application sources |

| cncf-kyverno | Policy enforcement on resources before and after Argo CD sync operations |

| cncf-gitlab-ci-cd-pipelines | CI pipeline that builds artifacts and pushes manifest changes to Git for Argo CD to pick up |

| cncf-kubernetes-deployments-management | Kubernetes Deployment management concepts that Argo CD operates on |

| cncf-argo | Broader Argo ecosystem (Workflows, Events, Rollouts) when beyond pure GitOps |


Live References

Authoritative documentation links for Argo CD GitOps workflows.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.