/gitops-argo-skills:argocd-applicationset-patternsfrom gitops-argo-skills
Designs Argo CD ApplicationSet resources that template many Application objects from a single source using generators — List, Cluster, Git directory/file, and Matrix. Use when generating Applications per cluster, environment, or directory, avoiding copy-paste, or debugging unexpected results.
Ships in gitops-argo-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Hand-maintaining one Application manifest per service-per-environment or
per-cluster does not scale: N services × M environments quickly becomes
hundreds of near-duplicate YAML files that drift from each other in subtle
ways. ApplicationSet solves this by templating Application objects from
one or more generators — a list, a cluster registry, a Git repo's
directory/file structure, or a combination — so that adding a new
environment, cluster, or service directory automatically produces (and
later, automatically removes) the corresponding Application, with no
manual manifest authored per instance. This matters operationally because
it turns fleet-wide rollout consistency from a copy-paste discipline
problem into a generator-configuration problem, and it's the mechanism
that makes gitops-multi-cluster-management's
hub-and-spoke topology actually maintainable at scale.
Applications exist (same
service, different environment/cluster/region) and are maintained by
hand-copying and editing one field at a time.Applications, not require someone to author new YAML.
See also
argocd-application-configuration
for what goes inside each generated Application.Application without per-service boilerplate.ApplicationSet produced Applications for directories
or clusters that shouldn't have matched, or silently stopped generating
one that should have.ApplicationSet controller enabled (bundled by
default in the standard install manifests since Argo CD 2.x; verify with
kubectl get pods -n argocd -l app.kubernetes.io/name=argocd-applicationset-controller).argocd cluster add <CONTEXT> or a Secret labeled
argocd.argoproj.io/secret-type: cluster in the argocd namespace).{{.field}}) or, for newer
installs, the Fasttemplate/Sprig-enabled template engine
(ApplicationsSyncPolicy and goTemplate: true at the
ApplicationSet spec level) — pick one templating mode per
ApplicationSet and don't mix syntaxes.List generator — smallest building block, an explicit inline set of parameters, most useful for a small fixed set of environments:
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: payments-api-envs
namespace: argocd
spec:
goTemplate: true
goTemplateOptions: ["missingkey=error"]
generators:
- list:
elements:
- env: staging
namespace: payments-staging
replicas: "2"
- env: prod
namespace: payments-prod
replicas: "10"
template:
metadata:
name: "payments-api-{{.env}}"
spec:
project: default
source:
repoURL: https://github.com/example/gitops-config.git
targetRevision: main
path: "apps/payments-api/overlays/{{.env}}"
destination:
server: https://kubernetes.default.svc
namespace: "{{.namespace}}"
syncPolicy:
automated: { prune: true, selfHeal: true }
Cluster generator — one Application per registered cluster,
the core of fleet-wide rollout:
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: platform-agent-fleet
namespace: argocd
spec:
goTemplate: true
generators:
- clusters:
selector:
matchLabels:
tier: production # only clusters registered with this label
template:
metadata:
name: "platform-agent-{{.name}}"
spec:
project: default
source:
repoURL: https://github.com/example/gitops-config.git
targetRevision: main
path: apps/platform-agent/base
destination:
server: "{{.server}}"
namespace: platform-system
syncPolicy:
automated: { prune: true, selfHeal: true }
{{.name}} and {{.server}} come from the cluster Secret's labels
and server field automatically; add custom labels
(argocd.argoproj.io/secret-type: cluster Secrets support arbitrary
labels) to filter which clusters this ApplicationSet targets, and
custom values.* fields in the Secret to pass per-cluster parameters
into the template — this is the mechanism
gitops-multi-cluster-management
builds on for hub-and-spoke fleet rollout.
Git directory generator — one Application per matching directory,
for monorepos with one folder per service or environment:
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: all-services
namespace: argocd
spec:
goTemplate: true
generators:
- git:
repoURL: https://github.com/example/gitops-config.git
revision: main
directories:
- path: "apps/*/overlays/prod"
- path: "apps/legacy-billing/overlays/prod"
exclude: true # explicitly exclude a matched path
template:
metadata:
name: "{{.path.basenameNormalized}}-prod"
spec:
project: default
source:
repoURL: https://github.com/example/gitops-config.git
targetRevision: main
path: "{{.path.path}}"
destination:
server: https://kubernetes.default.svc
namespace: "{{.path.basenameNormalized}}-prod"
syncPolicy:
automated: { prune: true, selfHeal: true }
{{.path.path}} is the full matched path; {{.path.basename}} and
{{.path.basenameNormalized}} (DNS-safe, lowercase) are derived
convenience fields — new service directories under apps/*/overlays/prod
are picked up on the next generator refresh with zero manifest changes.
Git file generator — one Application per JSON/YAML file matching
a glob, useful when parameters (not directory structure) drive
templating:
generators:
- git:
repoURL: https://github.com/example/gitops-config.git
revision: main
files:
- path: "clusters/*/config.yaml"
where each clusters/<name>/config.yaml contains structured fields
(cluster, region, tier) consumed as {{.cluster}}, {{.region}},
etc. in the template — preferred over the directory generator when you
need more structured metadata per instance than a directory path alone
encodes.
Matrix generator — combine two generators so their outputs form a cross-product, the pattern for "every service × every cluster" or "every service × every environment":
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: services-x-clusters
namespace: argocd
spec:
goTemplate: true
generators:
- matrix:
generators:
- git:
repoURL: https://github.com/example/gitops-config.git
revision: main
directories:
- path: "apps/*"
- clusters:
selector:
matchLabels: { tier: production }
template:
metadata:
name: "{{.path.basenameNormalized}}-{{.name}}"
spec:
project: default
source:
repoURL: https://github.com/example/gitops-config.git
targetRevision: main
path: "{{.path.path}}/overlays/{{.metadata.labels.tier}}"
destination:
server: "{{.server}}"
namespace: "{{.path.basenameNormalized}}"
syncPolicy:
automated: { prune: true, selfHeal: true }
Every service directory is crossed with every matching cluster,
producing service × cluster Applications automatically — this is
what makes fleet-wide multi-service rollout tractable, but see the
pitfall below on unbounded cross-products.
Preview before trusting prune at the ApplicationSet level.
ApplicationSet's own syncPolicy.applicationsSync controls whether
removed generator matches actually delete their generated
Application (and, transitively, its managed resources if that
Application's own syncPolicy.automated.prune is also on):
spec:
syncPolicy:
preserveResourcesOnDeletion: true # keep live resources if the
# generated Application is removed
Warning — destructive default: without
preserveResourcesOnDeletion: true, removing a cluster/directory from the generator's matches deletes the generatedApplication, and — if that Application'ssyncPolicy.automated.pruneis enabled — cascades to delete its live workload too. SetpreserveResourcesOnDeletion: truefor any fleet where a generator match briefly disappearing (a flaky cluster Secret, a transient Git API error) must not translate into deleting production workloads.
Verify what a change to a generator will produce before merging:
argocd appset generate applicationset.yaml # dry-run: list what would be generated
kubectl get applicationset payments-api-envs -n argocd -o yaml # inspect .status.conditions
kubectl get applications -n argocd -l argocd.argoproj.io/application-set-name=payments-api-envs
goTemplate: true for any new ApplicationSet (Go template
syntax, dot-notation) rather than the legacy Fasttemplate {{field}}
syntax — mixing the two across an org's ApplicationSets is a
persistent source of copy-paste template bugs.matchLabels/matchExpressions selectors on the Cluster generator
rather than targeting "all clusters" implicitly — an unlabeled or
mislabeled cluster Secret should not silently receive a fleet-wide
rollout it wasn't meant to get.goTemplateOptions: ["missingkey=error"] so a typo'd template field
fails loudly at generation time instead of silently rendering an empty
string into a manifest.Applications with a deterministic, collision-free
pattern ({{.path.basenameNormalized}}-{{.name}}) — two generator
branches producing the same rendered name will overwrite each other's
Application object.preserveResourcesOnDeletion: true for any production fleet
ApplicationSet where generator flakiness (cluster Secret transiently
missing, Git API rate limit) is a real risk relative to the cost of an
accidental fleet-wide deletion.Symptom: A new cluster was registered but no Application was
generated for it.
Fix: Check the cluster Secret's labels against the generator's
selector.matchLabels — the most common cause is the new cluster
Secret missing the label the ApplicationSet filters on. Confirm with
kubectl get secret -n argocd -l argocd.argoproj.io/secret-type=cluster --show-labels.
Symptom: A Matrix generator combining a Git directory generator (50
service directories) with a Cluster generator (20 clusters) suddenly
produced 1,000 Applications and overwhelmed the Argo CD controller /
API server, spiking reconciliation latency across the whole instance.
Fix: This is the cross-product growing exactly as configured but
larger than intended — add tighter selectors on one or both sides
(label-select a subset of clusters, glob a subset of directories) or
split into multiple narrower ApplicationSets rather than one
all-services-by-all-clusters matrix.
Symptom: Removing a directory from the Git generator's match (a
service was deprecated and its overlay folder deleted) also deleted the
live Kubernetes resources for that service immediately, with no
warning, in production.
Fix: This is expected ApplicationSet behavior without
preserveResourcesOnDeletion: true combined with the generated
Application's own prune: true — restore from the last known-good Git
state if this was unintended, then set
syncPolicy.preserveResourcesOnDeletion: true (or move deprecation to a
two-step process: disable automated sync first, delete the directory
second) before it happens again.
Symptom: Two different generator branches (e.g., a List generator
entry and a Git directory match) both render to the same Application
name, and one silently overwrites/interferes with the other's spec on
each reconcile.
Fix: Template names must be unique across everything the
ApplicationSet generates. Include a discriminating field
(environment, cluster name) in the name template, and check
kubectl get applications -n argocd -l argocd.argoproj.io/application-set-name=<name>
for unexpected duplicates or count mismatches versus expected generator
matches.
Symptom: A template field renders as an empty string instead of
failing, producing an Application with a blank namespace or path
that then fails to sync with a confusing downstream error.
Fix: Set goTemplateOptions: ["missingkey=error"] so a
misspelled or missing template variable fails ApplicationSet
generation loudly instead of silently rendering empty — check
kubectl describe applicationset <name> -n argocd for the resulting
condition/error once this is set.
Scenario: Roll platform-agent out to every cluster labeled
tier: production in the cluster registry, and separately generate one
Application per service directory under apps/*/overlays/prod in the
config repo — while ensuring neither an accidental cluster deregistration
nor a deleted directory can silently wipe production workloads.
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: platform-agent-fleet
namespace: argocd
spec:
goTemplate: true
goTemplateOptions: ["missingkey=error"]
generators:
- clusters:
selector:
matchLabels: { tier: production }
template:
metadata:
name: "platform-agent-{{.name}}"
spec:
project: default
source:
repoURL: https://github.com/example/gitops-config.git
targetRevision: main
path: apps/platform-agent/base
destination:
server: "{{.server}}"
namespace: platform-system
syncPolicy:
automated: { prune: true, selfHeal: true }
syncPolicy:
preserveResourcesOnDeletion: true
---
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: all-services-prod
namespace: argocd
spec:
goTemplate: true
goTemplateOptions: ["missingkey=error"]
generators:
- git:
repoURL: https://github.com/example/gitops-config.git
revision: main
directories:
- path: "apps/*/overlays/prod"
template:
metadata:
name: "{{.path.basenameNormalized}}-prod"
spec:
project: default
source:
repoURL: https://github.com/example/gitops-config.git
targetRevision: main
path: "{{.path.path}}"
destination:
server: https://kubernetes.default.svc
namespace: "{{.path.basenameNormalized}}-prod"
syncPolicy:
automated: { prune: true, selfHeal: true }
syncPolicy:
preserveResourcesOnDeletion: true
Verify: argocd appset generate platform-agent-fleet.yaml before
applying shows exactly N Applications for N production-labeled clusters;
after applying, kubectl get applications -n argocd -l argocd.argoproj.io/application-set-name=platform-agent-fleet confirms the
count matches the cluster registry, and a subsequent deregistration of one
cluster leaves that cluster's workload running (rather than deleted)
because of preserveResourcesOnDeletion: true, pending deliberate cleanup.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub selvarajmurugesan90/ops-engineering-skills --plugin gitops-argo-skills11 skills in this plugin
/argocd-application-configurationConfigures Argo CD `Application` custom resources — sync policies (automated vs. manual, prune, self-heal), sync waves and hooks for ordered/multi-phase rollouts, and health checks for custom resource types. Use when the user asks to "write an Argo CD Application manifest," "enable auto-sync / self-heal / prune," "order resources with sync waves," "add a PreSync/PostSync hook," "fix an Application stuck OutOfSync or Progressing," or "define a custom health check for a CRD Argo CD doesn't understand natively."
/argocd-sync-failure-and-drift-investigationTroubleshoots Argo CD `Application`s that are stuck or failing — `OutOfSync`/`Progressing`/`Degraded` states, `PreSync`/`Sync`/`PostSync` hook Jobs that fail or hang, resource-level diffs that are hard to read, and distinguishing drift caused by an out-of-band `kubectl edit`/`kubectl patch` from genuine configuration drift between Git and the live cluster. Use when the user asks to "debug why an Argo CD app is OutOfSync," "figure out what's actually different between Git and the cluster," "a sync hook is failing/stuck," "someone kubectl edited a resource Argo CD manages," or "an Application says Synced but the cluster doesn't match Git."
/argo-events-and-event-driven-automationConfigures Argo Events `EventSource`, `Sensor`, and `EventBus` CRDs to trigger Argo Workflows, Kubernetes resource changes, or other actions from external events — webhooks, message queues (Kafka/NATS/SQS/ RabbitMQ), and cron schedules. Use when the user asks to "trigger an Argo Workflow from a webhook," "wire up an EventSource for S3/Kafka/ GitHub events," "fan events out to multiple triggers with a Sensor," "debug a Sensor that isn't firing," or "build event-driven automation on Kubernetes without a separate message broker to operate."
/argo-rollouts-progressive-deliveryConfigures the Argo Rollouts `Rollout` CRD as a drop-in replacement for a Kubernetes `Deployment`, covering canary and blue-green strategy mechanics, traffic management integration (service mesh/ingress controllers), and `AnalysisTemplate`/`AnalysisRun` for automated metric-based promotion and rollback. Use when the user asks to "convert a Deployment to an Argo Rollout," "configure canary steps with setWeight/pause," "wire up an AnalysisTemplate against Prometheus/ Datadog," "fix a Rollout stuck mid-canary," or "automate rollback on bad metrics with Argo Rollouts."
/argo-workflows-pipeline-designDesigns Argo Workflows pipelines using the `Workflow`/`WorkflowTemplate`/ `CronWorkflow` CRDs — choosing DAG vs. steps templates, passing artifacts and parameters between steps, and structuring Kubernetes-native batch/ML pipelines distinct from a CI system. Use when the user asks to "write an Argo Workflow," "build a DAG pipeline on Kubernetes," "pass an artifact between workflow steps," "reuse a WorkflowTemplate across pipelines," "schedule a recurring Argo CronWorkflow," or "decide whether a batch job belongs in Argo Workflows vs. a CI pipeline."
/complete-gitops-argocd-deployment-on-aks-from-scratchWalks through a complete, end-to-end Argo CD GitOps deployment on an existing Azure AKS cluster — Helm install, Azure AD Workload Identity integration for Argo CD's own components (federated-credential-based cluster access, private ACR pull auth), the first Application, an ApplicationSet for multi-environment rollout, and sync/health policy — sequenced as one coherent runbook. Use when the user asks to "set up Argo CD on AKS from scratch," "deploy GitOps end-to-end on Azure," "wire Azure AD Workload Identity into Argo CD," "stand up GitOps for a new AKS cluster," or "go from a bare AKS cluster to a working multi-env GitOps pipeline."
Other plugins' skills for the same job