This scenario will get you get familiar with syncwaves and hook phases.
Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes.
Using a combination of syncwaves and resource hooks, you can control how your application rolls out.
This is a simple guide that takes you through the following steps:
- Using Syncwaves to order deployment
- Exploring Resource Hooks
- Using Syncwaves and Hooks together
This OpenShift cluster will self-destruct in one hour.
In this scenario, you learned how to order your deployments with syncwaves. Furthermore, you got familiar with how resource hooks work. Finally, you saw how to further refine your deployments by using syncwaves and hooks together.
You can continue learning more about OpenShift and how to develop applications on the platform by completing other tutorials at https://learn.openshift.com.
For developer-related resources about OpenShift, visit https://developers.redhat.com/products/openshift/getting-started.
Run OpenShift Locally with CodeReady Containers
CodeReady Containers allows you to run a minimal, pre-configured OpenShift 4 cluster on your local machine. The project supports Windows 10, macOS, and Linux. To find out more or download CodeReady Containers, visit https://developers.redhat.com/products/codeready-containers/overview
Compare Hosted, Managed, or On Premises OpenShift
Learn more about the different OpenShift platform variants here: https://www.openshift.com/products
Browse the Documentation
If you want to learn about particular OpenShift concepts in more depth, visit the documentation: https://docs.openshift.com/container-platform/latest
Syncwaves and Hooks
Welcome! In this section we will be exploring how to use syncwaves with Argo CD.
A Syncwave is a way to order how Argo CD applies the manifests that are
stored in git. All manifests have a wave of zero by default, but you can
set these by using the
argocd.argoproj.io/sync-wave annotation. Example:
metadata: annotations: argocd.argoproj.io/sync-wave: "2"
The wave can also be negative as well.
metadata: annotations: argocd.argoproj.io/sync-wave: "-5"
When Argo CD starts a sync action, the manifest get placed in the following order:
- The Phase that they're in (we'll cover phases in the next section)
- The wave the resource is annotated in (starting from the lowest value to the highest)
- By kind (Namspaces first, then services, then deployments, etc ...)
- By name (ascending order)
Read more about syncwaves on the official documentation site
The manifests that will be deployed have been annotated with the following values:
- The Namspace with
- The Deployment with
- The Service with
- Finally the Route with
Argo CD will apply the Namespace first (since it's the lowest value), and make sure it returns a "healthy" status before moving on.
Next, the Deployment will be applied. After that reports healthy, Argo CD will apply the Service then the Route.
NOTE Argo CD won't apply the next manifest until the previous reports "healthy".
Deploying The Application
Before we deploy this application, make sure you've opened the Argo CD Web Console.
To get to the Argo CD Web UI; click the Argo CD Web Console tab.
Once you have accepted the self signed certificate, you should be presented with the Argo CD login screen.
You can login with the following
oc extract secret/openshift-gitops-cluster -n openshift-gitops --to=-
Apply the Argo CD
Application manifest to get this application deployed.
oc apply -f ~/resources/openshift-gitops-examples/components/applications/welcome-syncwaves.yaml
This should create the
Clicking on this "card" will take you to the application overview page. Clicking on "show hidden resources" should expand the "tree" view.
If you follow along, you'll note that these manfiests get applied in order of their annotated syncwave!
Keep the Argo CD WebUI tab open for the next exercise.