Using Argo CD Sync Waves to Order ConfigMap Before Deployment
Learn how to enforce a deterministic sync order in Argo CD by annotating Kubernetes resources with argocd.argoproj.io/sync-wave so that ConfigMaps are applied before dependent Pods start.
05 Oct 2025, 17:04 UTC

Desired outcome
Ensure that a ConfigMap (or Secret) is fully applied to the cluster before any Pod that depends on it starts, preventing race conditions during application rollout.
Prerequisites
- Argo CD v2.0 or later installed and accessible via
argocdCLI or UI. kubectlconfigured to target the same cluster.- Permission to create or update an Argo CD Application and to apply Kubernetes manifests in the target namespace.
- A Git repository (or local directory) containing the manifests you want to manage.
Procedure
- Prepare the manifests
Add the
argocd.argoproj.io/sync-waveannotation to each resource. Lower numbers sync first.# configmap.yaml apiVersion: v1 kind: ConfigMap metadata: name: app-config annotations: argocd.argoproj.io/sync-wave: "-5" data: key: value --- # deployment.yaml apiVersion: apps/v1 kind: Deployment metadata: name: app annotations: argocd.argoproj.io/sync-wave: "10" spec: replicas: 1 selector: matchLabels: app: myapp template: metadata: labels: app: myapp spec: containers: - name: app image: myapp:latest envFrom: - configMapRef: name: app-config - Create or update the Argo CD Application
If the Application does not exist, create it pointing to the directory containing the manifests.
argocd app create ordering-demo \ --repo https://github.com/example/repo.git \ --path manifests \ --dest-server https://kubernetes.default.svc \ --dest-namespace default \ --sync-policy automatedTo apply a global wave shift without editing manifests, edit the Application’s
syncPolicy.syncOptions:argocd app patch ordering-demo --patch '{"spec":{"syncPolicy":{"syncOptions":["SyncWave=-10"]}}}' --type mergeThis subtracts 10 from every wave value, useful for testing.
- Trigger a sync
Run a manual sync or rely on the automated policy.
argocd app sync ordering-demo - Verify the ordering
- In the Argo CD UI, open the Application → Resources tab. Each resource shows its wave number; confirm the ConfigMap appears with a lower number than the Deployment.
- Check the sync log for the sequence:
argocd app get ordering-demo -o yamlunderstatus.operationState.phaseandhistoryentries. - Observe the Pod logs: the container should start only after the ConfigMap is present. You can add a temporary
sleep orecho command to the container to verify that it does not start until the ConfigMap is mounted.
Expected checks
- ConfigMap wave < Deployment wave (e.g., -5 vs 10).
- UI timeline shows ConfigMap synced before Deployment.
- Pod’s
READYcondition becomes true only after the ConfigMap is present.
Recovery options (if ordering causes disruption)
Because sync waves only influence Argo CD’s sequencing, you can revert changes without touching the cluster state:
- Remove or adjust the
sync-waveannotations in the manifests and re‑sync. - If you used a global
syncPolicy.syncOptionsshift, set it back to an empty list or remove the patch: - If a sync has already applied resources in an undesired order, you can manually delete and recreate the offending resource (e.g., the Deployment) to force a re‑apply with the corrected order.
argocd app patch ordering-demo --patch '{"spec":{"syncPolicy":{"syncOptions":[]}}}' --type merge
Limitations and cautions
- Missing
sync-wavedefaults to wave 0; mixing annotated and unannotated resources can produce unexpected ordering. - Extremely large values (outside -100 … 100) may cause overflow in Argo CD versions < v2.0; stay within this range.
- Sync waves do not override Kubernetes native ordering such as
ownerReferencesor controller‑driven creation; they only affect Argo CD’s internal sequencing. - Changing wave values after an application is already synced may cause Argo CD to attempt re‑ordering on the next sync, potentially leading to disruptive updates. Test changes in a staging environment first.
- The feature relies on the Argo CD controller correctly parsing annotations; a malfunctioning controller (e.g., due to a custom plugin bug) could ignore wave ordering.
Practical way to confirm the result
After a successful sync, run:
kubectl get configmap app-config -o yaml
kubectl get deployment app -o yaml
kubectl describe pod -l app=myapp
Verify that the ConfigMap’s data section is present and that the Pod’s containers have the environment variables sourced from it before they report Ready.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.