In this lesson, you will learn how to orchestrate uniform application state across heterogeneous Kubernetes clusters using ArgoCD as your GitOps controller.
When managing fleet-wide deployments for a distributed .NET architecture, manually applying kubectl commands to individual clusters leads to "configuration drift," where clusters inevitably diverge in state. GitOps solves this by treating your Git repository as the single source of truth. ArgoCD runs inside your cluster, constantly observing the state defined in your repository and reconciling it with the actual state of your cluster.
The ApplicationSet Controller
To manage multiple clusters efficiently, ArgoCD uses the ApplicationSet custom resource. Instead of defining one Argo Application object per cluster, you define a single template that dynamically generates applications based on your target environment, cluster labels, or Git directory structure.
For example, you can target clusters with specific metadata using a generator in your ApplicationSet manifest:
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: dotnet-microservices
spec:
generators:
- clusters:
selector:
matchLabels:
environment: production
template:
metadata:
name: '{{cluster}}-app'
spec:
project: default
source:
repoURL: 'https://github.com/my-org/dotnet-infrastructure.git'
targetRevision: HEAD
path: deployments/helm-chart
destination:
server: '{{server}}'
namespace: dotnet-web-api
Synchronizing State
When you push a new Helm chart version or update a values.yaml file in your repository, the ArgoCD controller detects the commit hash difference. It then executes a "sync" operation, pulling the updated manifests into each targeted cluster. Because the controller is cluster-scoped, it ensures that if a cluster is manually tampered with via kubectl edit, ArgoCD will automatically overwrite those unauthorized changes to match your Git configuration (Self-Healing).
This approach allows you to deploy a .NET service to ten different regions simultaneously, ensuring that environment-specific secrets (injected via Vault integration) and resource configurations remain consistent without human intervention.
Key Takeaway: By using ArgoCD ApplicationSets, you shift from "pushing" updates to individual clusters toward a "pull-based" model where clusters self-synchronize with a central Git repository, guaranteeing global consistency across your infrastructure.