This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
devopscritical PriorityID: argocd-applicationset-progressive-rollout-ephemeral-cleanup

ArgoCD ApplicationSet Progressive Rollouts and Dynamic Ephemeral Cluster Cleanup Invariant

Standardizes immutable GitOps convergence loops across dynamic and ephemeral target clusters using ArgoCD ApplicationSets. Enforces rolling update progressive sync gates, cascading resource finalizers, and automated garbage collection triggers to prevent resource orphaning, zombie application states, and simultaneous failure domain propagation during dynamic cluster lifecycle events.

Prohibited Anti-Pattern: Unbounded concurrent cluster syncs without rolling update stages, missing cascade finalizers, and unpruned ephemeral cluster secrets leading to cluster resource orphaning and cascade blast radius.

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: ArgoCD ApplicationSet Progressive Rollouts and Dynamic Ephemeral Cluster Cleanup Invariant - Standardizes immutable GitOps convergence loops across dynamic and ephemeral target clusters using ArgoCD ApplicationSets. Enforces rolling update progressive sync gates, cascading resource finalizers, and automated garbage collection triggers to prevent resource orphaning, zombie application states, and simultaneous failure domain propagation during dynamic cluster lifecycle events.
globs: **/applicationset*.{yaml,yml}, **/applicationsets/**/*.{yaml,yml}, **/argocd/**/*.{yaml,yml}, infra/gitops/**/*.{yaml,yml}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/argocd-applicationset-progressive-rollout-ephemeral-cleanup"
---

# ArgoCD ApplicationSet Progressive Rollouts and Dynamic Ephemeral Cluster Cleanup Invariant

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Unbounded concurrent cluster syncs without rolling update stages, missing cascade finalizers, and unpruned ephemeral cluster secrets leading to cluster resource orphaning and cascade blast radius.

## System Constraints
You are a Principal Software Architect enforcing immutable GitOps workflows, dynamic cluster lifecycles, and progressive delivery invariants in ArgoCD ApplicationSets. You must strictly require rolling sync strategies, resource cascading finalizers, strict label selectors for ephemeral target clusters, and automated orphan resource cleanup.

## Strict Guidelines
- Engineers MUST ALWAYS attach the 'resources-finalizer.argocd.argoproj.io' finalizer to both the ApplicationSet template and generated Application metadata to guarantee cascade deletion when dynamic clusters are decommissioned.
- Engineers MUST NEVER use the default 'AllAtOnce' rollout strategy when provisioning across multiple dynamic clusters; an explicit 'RollingUpdate' progressive strategy with partitioned maxUpdate steps MUST be defined.
- ApplicationSet syncPolicy MUST enable 'prune: true' and 'selfHeal: true', while explicitly setting 'allowEmpty: false' to prevent catastrophic mass resource wipeouts during transient Git or manifest generation failures.
- Generated Applications targeting ephemeral or preview clusters MUST specify dynamic cluster label matching criteria coupled with TTL or SCM status generators, ensuring cluster deregistration automatically cascades to child manifests.
- Engineers MUST configure SyncWindows or metric verification pre-sync/post-sync health hooks in progressive delivery steps to halt rollout advancement upon cluster or workload degradation.

## Bad vs Good Implementations
### Progressive Rolling ApplicationSet with Ephemeral Cluster Garbage Collection

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Targets all clusters indiscriminately with no progressive rollout policy, causing simultaneous cluster-wide blast radius. Lacks finalizers so deleting an ephemeral cluster leaves zombie manifests, disables self-healing, and disables automated pruning.
```yaml
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: core-services
  namespace: argocd
spec:
  generators:
    - clusters: {} # Anti-pattern: Targets all clusters unconditionally
  template:
    metadata:
      name: '{{name}}-core-services'
      # Missing resources-finalizer causes orphaned resources on cluster teardown
    spec:
      project: default
      source:
        repoURL: https://github.com/example/monorepo.git
        targetRevision: HEAD
        path: services/core
      destination:
        server: '{{server}}'
        namespace: default
      syncPolicy:
        automated:
          prune: false # Anti-pattern: Drifted and deleted resources are never cleaned up
          selfHeal: false
```

#### Production Standard (Correct)
> **Standard**: Defines a structured progressive RollingUpdate strategy gating ephemeral/staging clusters before production. Enforces the resources-finalizer for automatic garbage collection upon cluster destruction, activates pruning with self-healing, and guards against catastrophic empty-state syncs.
```yaml
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: core-services-progressive
  namespace: argocd
spec:
  strategy:
    type: RollingUpdate
    rollingUpdate:
      steps:
        - matchExpressions:
            - key: environment
              operator: In
              values: [ephemeral, staging]
          maxUpdate: 50%
        - matchExpressions:
            - key: environment
              operator: In
              values: [production]
          maxUpdate: 1
  generators:
    - clusters:
        selector:
          matchLabels:
            managed-by: gitops-ephemeral-controller
            cluster-lifecycle: active
  template:
    metadata:
      name: '{{name}}-core-services'
      finalizers:
        - resources-finalizer.argocd.argoproj.io
      labels:
        environment: '{{metadata.labels.environment}}'
        cluster-id: '{{name}}'
    spec:
      project: default
      source:
        repoURL: https://github.com/example/monorepo.git
        targetRevision: HEAD
        path: services/core
      destination:
        server: '{{server}}'
        namespace: core-system
      syncPolicy:
        automated:
          prune: true
          selfHeal: true
          allowEmpty: false
        syncOptions:
          - CreateNamespace=true
          - PruneLast=true
          - ApplyOutOfSyncOnly=true
```

Architectural Specification & Invariant Rationale

Architectural Invariant Design: ArgoCD ApplicationSet Progressive Rollouts and Dynamic Ephemeral Cluster Cleanup Invariant

ArgoCD ApplicationSet Progressive Rollouts and Dynamic Ephemeral Cluster Cleanup Invariant defines an industrial-grade behavioral standard for devops engineering. Standardizes immutable GitOps convergence loops across dynamic and ephemeral target clusters using ArgoCD ApplicationSets. Enforces rolling update progressive sync gates, cascading resource finalizers, and automated garbage collection triggers to prevent resource orphaning, zombie application states, and simultaneous failure domain propagation during dynamic cluster lifecycle events. Modern software architectures require strict adherence to deterministic patterns to guarantee high availability, maintainability, and zero security vulnerabilities.

Framework Paradigm Shift & Drift MechanicsLLMs are trained on millions of open-source repositories containing outdated code, legacy idioms, and unpatched antipatterns. When coding assistants generate implementations for this stack, they default to common statistical tokens: Unbounded concurrent cluster syncs without rolling update stages, missing cascade finalizers, and unpruned ephemeral cluster secrets leading to cluster resource orphaning and cascade blast radius. Without an explicit system instruction file, developers spend hours debugging silent failures.
Failure Modes & Production Blast Radius

Hazard Analysis: What Breaks Without This Rule

The following failure modes have been cataloged from hundreds of hours of production code reviews where AI assistants produced non-compliant implementations:

Failure ModeAI Symptom (The Anti-Pattern)SeverityProduction Impact & Remedy
AI Hallucination & Deprecation DriftUnbounded concurrent cluster syncs without rolling update stages, missing cascade finalizers, and unpruned ephemeral cluster secrets leading to cluster resource orphaning and cascade blast radius.Critical
Violating this industrial standard introduces regression bugs, security risks, and unexpected runtime failures in production.
Enforce explicit behavioral system directives across all AI coding assistants in your repository.
Silent Architecture InconsistencyAI assistants produce mixed paradigms across files, creating fragmented codebase conventions.Medium
Increases cognitive load during code reviews and leads to maintenance debt across engineering teams.
Pin project conventions in .cursor/rules, CLAUDE.md, and AGENTS.md so all team agents follow identical guardrails.
Architectural Directives in Detail

Step-by-Step Production Directives

Each rule constraint below is injected into the AI agent's system prompt to establish deterministic boundaries:

1

Engineers MUST ALWAYS attach the 'resources-finalizer.argocd.argoproj.io' finalizer to both the ApplicationSet template and generated Application metadata to guarantee cascade deletion when dynamic clusters are decommissioned.

Engineers MUST ALWAYS attach the 'resources-finalizer.argocd.argoproj.io' finalizer to both the ApplicationSet template and generated Application metadata to guarantee cascade deletion when dynamic clusters are decommissioned.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
2

Engineers MUST NEVER use the default 'AllAtOnce' rollout strategy when provisioning across multiple dynamic clusters

Engineers MUST NEVER use the default 'AllAtOnce' rollout strategy when provisioning across multiple dynamic clusters; an explicit 'RollingUpdate' progressive strategy with partitioned maxUpdate steps MUST be defined.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
3

ApplicationSet syncPolicy MUST enable 'prune

ApplicationSet syncPolicy MUST enable 'prune: true' and 'selfHeal: true', while explicitly setting 'allowEmpty: false' to prevent catastrophic mass resource wipeouts during transient Git or manifest generation failures.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
4

Generated Applications targeting ephemeral or preview clusters MUST specify dynamic cluster label matching criteria coupled with TTL or SCM status generators, ensuring cluster deregistration automatically cascades to child manifests.

Generated Applications targeting ephemeral or preview clusters MUST specify dynamic cluster label matching criteria coupled with TTL or SCM status generators, ensuring cluster deregistration automatically cascades to child manifests.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
5

Engineers MUST configure SyncWindows or metric verification pre-sync/post-sync health hooks in progressive delivery steps to halt rollout advancement upon cluster or workload degradation.

Engineers MUST configure SyncWindows or metric verification pre-sync/post-sync health hooks in progressive delivery steps to halt rollout advancement upon cluster or workload degradation.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
Technical Questions & Answers

Frequently Asked Technical Questions

Common questions developers face when configuring AI coding assistants for this stack:

Q:Why is ArgoCD ApplicationSet Progressive Rollouts and Dynamic Ephemeral Cluster Cleanup Invariant critical for AI coding assistants?

Standardizes immutable GitOps convergence loops across dynamic and ephemeral target clusters using ArgoCD ApplicationSets. Enforces rolling update progressive sync gates, cascading resource finalizers, and automated garbage collection triggers to prevent resource orphaning, zombie application states, and simultaneous failure domain propagation during dynamic cluster lifecycle events. Without explicit behavioral boundaries, AI coding assistants (Cursor, Claude Code, Windsurf, Codex) rely on training data averages, which frequently produce deprecated, inefficient, or vulnerable code patterns.

Q:How does adopting this rule prevent AI hallucinations?

This rule explicitly declares what the AI must avoid (Unbounded concurrent cluster syncs without rolling update stages, missing cascade finalizers, and unpruned ephemeral cluster secrets leading to cluster resource orphaning and cascade blast radius.) and prescribes verified positive examples. Grounding the LLM with negative and positive pairs eliminates guesswork.

Q:Which AI coding environments are supported?

This specification is multi-platform compatible: Cursor (.cursor/rules/*.mdc & .cursorrules), Anthropic Claude Code (CLAUDE.md), Windsurf (.windsurfrules), Codex / Cline (AGENTS.md), and GitHub Copilot (.github/copilot-instructions.md).

Q:Can I combine this rule with other technology stacks?

Yes. Use the Interactive Stack Builder or download an Agent Pack to merge this rule with other frontend, backend, database, security, and DevOps rules without syntax collision.

Open Specification · CC BY 4.0·Free for Personal, Team & Commercial In-Repo Use

Citation & Open Source Attribution Guidelines

This specification is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0). You are completely free to adapt and share this rule in your workspace. If citing, including in public AI benchmark datasets, or redistributing, attribution to AgentRules.org is required.

1 Rule in Stack

ArgoCD