From aeeca03baf56d14de3c9a000797b5ff767da7ee8 Mon Sep 17 00:00:00 2001 From: day0hero Date: Tue, 4 Oct 2022 20:08:02 -0500 Subject: [PATCH 1/2] Added counter to application resource To control the flow of application deployments adding a count to the app of apps pattern should help with deployments. Each application's counter will +1 from the previous applications and theoretically should wait for that application to be healthy/synced before deploying. --- clustergroup/templates/plumbing/applications.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/clustergroup/templates/plumbing/applications.yaml b/clustergroup/templates/plumbing/applications.yaml index c9a6667d..4f959379 100644 --- a/clustergroup/templates/plumbing/applications.yaml +++ b/clustergroup/templates/plumbing/applications.yaml @@ -1,3 +1,4 @@ +{{- $c := 1 | int64 }} {{- if not (eq .Values.enabled "core") }} {{- $namespace := print $.Values.global.pattern "-" $.Values.clusterGroup.name }} {{- if (eq .Values.enabled "plumbing") }} @@ -123,6 +124,8 @@ metadata: namespace: {{ $namespace }} finalizers: - resources-finalizer.argocd.argoproj.io/foreground + annotations: + argocd.argoproj.io/sync-wave: {{ quote $c |}} spec: destination: name: {{ $.Values.clusterGroup.targetCluster }} @@ -213,6 +216,7 @@ spec: # selfHeal: true {{- end }} --- +{{ $c = add1 $c }} {{- end }} {{- end }} {{- end }} From 515765ecf39ed5fe5988b5094cfa0bf39cfb07c3 Mon Sep 17 00:00:00 2001 From: day0hero Date: Wed, 5 Oct 2022 20:08:36 -0500 Subject: [PATCH 2/2] updated tests --- tests/clustergroup-normal.expected.yaml | 4 ++++ tests/clustergroup.expected.diff | 12 ++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/clustergroup-normal.expected.yaml b/tests/clustergroup-normal.expected.yaml index 4d740ac8..67e3fd3a 100644 --- a/tests/clustergroup-normal.expected.yaml +++ b/tests/clustergroup-normal.expected.yaml @@ -502,6 +502,8 @@ metadata: namespace: mypattern-example finalizers: - resources-finalizer.argocd.argoproj.io/foreground + annotations: + argocd.argoproj.io/sync-wave: "1" spec: destination: name: in-cluster @@ -553,6 +555,8 @@ metadata: namespace: mypattern-example finalizers: - resources-finalizer.argocd.argoproj.io/foreground + annotations: + argocd.argoproj.io/sync-wave: "2" spec: destination: name: in-cluster diff --git a/tests/clustergroup.expected.diff b/tests/clustergroup.expected.diff index 45fca30b..9408c857 100644 --- a/tests/clustergroup.expected.diff +++ b/tests/clustergroup.expected.diff @@ -241,7 +241,7 @@ roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole -@@ -45,16 +257,583 @@ +@@ -45,16 +257,587 @@ - kind: ServiceAccount # This is the {ArgoCD.name}-argocd-application-controller name: example-gitops-argocd-application-controller @@ -493,6 +493,8 @@ + namespace: mypattern-example + finalizers: + - resources-finalizer.argocd.argoproj.io/foreground ++ annotations: ++ argocd.argoproj.io/sync-wave: "1" +spec: + destination: + name: in-cluster @@ -544,6 +546,8 @@ + namespace: mypattern-example + finalizers: + - resources-finalizer.argocd.argoproj.io/foreground ++ annotations: ++ argocd.argoproj.io/sync-wave: "2" +spec: + destination: + name: in-cluster @@ -828,7 +832,7 @@ --- # Source: pattern-clustergroup/templates/plumbing/argocd.yaml apiVersion: argoproj.io/v1alpha1 -@@ -65,7 +844,7 @@ +@@ -65,7 +848,7 @@ # Changing the name affects the ClusterRoleBinding, the generated secret, # route URL, and argocd.argoproj.io/managed-by annotations name: example-gitops @@ -837,7 +841,7 @@ annotations: argocd.argoproj.io/compare-options: IgnoreExtraneous spec: -@@ -94,10 +873,10 @@ +@@ -94,10 +877,10 @@ --set global.repoURL=$ARGOCD_APP_SOURCE_REPO_URL --set global.targetRevision=$ARGOCD_APP_SOURCE_TARGET_REVISION --set global.namespace=$ARGOCD_APP_NAMESPACE @@ -852,7 +856,7 @@ --set clusterGroup.name=example --post-renderer ./kustomize"] applicationSet: -@@ -174,11 +953,59 @@ +@@ -174,11 +957,59 @@ kind: ConsoleLink metadata: name: example-gitops-link