How to enable ArgoCD sync waves between apps in Kubernetes
This article provides insights on configuring the sync waves function in ArgoCD for optimal performance in an App of Apps framework.
Here you will learn how to configure the sync waves feature in ArgoCD to work in an App of Apps pattern. If you have tried the app of apps pattern, you might have noticed that placing the sync-wave
annotation does not work between individual applications, just between manifests in a singular application. This is because the health assessment of applications has been removed in version 1.8
of ArgoCD.
Sync waves
In short, the sync wave annotation, when added to ArgoCD applications, informs the engine that there is an order of synchronization. For example, if you wanted to generate a certificate by using cert-manager
in Kubernetes for your own application, without the sync waves, the both deployments will run at once, and the synchronization will fail because your application can’t find the Certificate
resource. This can be solved by adding the sync-wave
annotation to both applications.
The priority is calculated from the smallest to the highest number. If you add this to the cert-manager
application metadata:
|
|
you will have to add the following to your own application:
|
|
This should work, but as mentioned above, the disabled health assessment of applications is directly tied to the sync waves. When the cert-manager
app is not healthy yet, your application has to wait for the health assessment to pass. ArgoCD supports adding custom Lua scripts to the main configuration, and this is what we will use to enable the health assessment.
Method One: Editing the argocd-cm
configmap directly
The first method is using the kubectl edit
command to add/remove live manifest configuration. Run the following (replace the editor with your own):
|
|
After that, add the following Lua custom script in data
to enable the health assessment:
|
|
Save the file, and you are done.
Method Two: Using the ArgoCD Helm Chart with custom values
The second method is if you installed, or plan on installing ArgoCD with the official helm chart. Create the custom-values.yaml
file and add the following:
|
|
Now, if you are installing ArgoCD from scratch, run the following:
|
|
This will install ArgoCD in the argocd
namespace and the argocd-cm
configmap will be edited from the start. If you already have ArgoCD installed with Helm in your Kubernetes cluster, run the following after the creation of the custom-values.yaml
file:
|
|
And that is it. Your sync wave annotations should work now in an App of Apps pattern.
If you find this post helpful, please consider supporting the blog. Your contributions help sustain the development and sharing of great content. Your support is greatly appreciated!
Buy Me a Coffee