From 3a1d777bfec57dbd20933999122b89128408165b Mon Sep 17 00:00:00 2001 From: absolutelightning Date: Thu, 17 Aug 2023 10:01:53 +0530 Subject: [PATCH 01/10] enable argocd --- charts/consul/templates/gateway-cleanup-job.yaml | 4 ++++ charts/consul/templates/gateway-resources-job.yaml | 4 ++++ charts/consul/templates/server-acl-init-cleanup-job.yaml | 4 ++++ charts/consul/templates/server-acl-init-job.yaml | 4 ++++ charts/consul/values.yaml | 9 +++++++++ 5 files changed, 25 insertions(+) diff --git a/charts/consul/templates/gateway-cleanup-job.yaml b/charts/consul/templates/gateway-cleanup-job.yaml index a987c3b591..23e3b7d5ae 100644 --- a/charts/consul/templates/gateway-cleanup-job.yaml +++ b/charts/consul/templates/gateway-cleanup-job.yaml @@ -34,6 +34,10 @@ spec: {{- if .Values.global.acls.annotations }} {{- tpl .Values.global.acls.annotations . | nindent 8 }} {{- end }} + {{- if .Values.global.argocd.enabled }} + "argocd.argoproj.io/hook": Sync + "argocd.argoproj.io/hook-delete-policy": HookSucceeded + {{- end}} spec: restartPolicy: Never serviceAccountName: {{ template "consul.fullname" . }}-gateway-cleanup diff --git a/charts/consul/templates/gateway-resources-job.yaml b/charts/consul/templates/gateway-resources-job.yaml index de64e2d70d..29f37fd566 100644 --- a/charts/consul/templates/gateway-resources-job.yaml +++ b/charts/consul/templates/gateway-resources-job.yaml @@ -34,6 +34,10 @@ spec: {{- if .Values.global.acls.annotations }} {{- tpl .Values.global.acls.annotations . | nindent 8 }} {{- end }} + {{- if .Values.global.argocd.enabled }} + "argocd.argoproj.io/hook": Sync + "argocd.argoproj.io/hook-delete-policy": HookSucceeded + {{- end}} spec: restartPolicy: Never serviceAccountName: {{ template "consul.fullname" . }}-gateway-resources diff --git a/charts/consul/templates/server-acl-init-cleanup-job.yaml b/charts/consul/templates/server-acl-init-cleanup-job.yaml index 39754d6c6f..eeec7d5e6e 100644 --- a/charts/consul/templates/server-acl-init-cleanup-job.yaml +++ b/charts/consul/templates/server-acl-init-cleanup-job.yaml @@ -50,6 +50,10 @@ spec: {{- if .Values.global.acls.annotations }} {{- tpl .Values.global.acls.annotations . | nindent 8 }} {{- end }} + {{- if .Values.global.argocd.enabled }} + "argocd.argoproj.io/hook": Sync + "argocd.argoproj.io/hook-delete-policy": HookSucceeded + {{- end}} spec: restartPolicy: Never serviceAccountName: {{ template "consul.fullname" . }}-server-acl-init-cleanup diff --git a/charts/consul/templates/server-acl-init-job.yaml b/charts/consul/templates/server-acl-init-job.yaml index e8a06cf7aa..17b8aa9ea6 100644 --- a/charts/consul/templates/server-acl-init-job.yaml +++ b/charts/consul/templates/server-acl-init-job.yaml @@ -49,6 +49,10 @@ spec: {{- if .Values.global.acls.annotations }} {{- tpl .Values.global.acls.annotations . | nindent 8 }} {{- end }} + {{- if .Values.global.argocd.enabled }} + "argocd.argoproj.io/hook": Sync + "argocd.argoproj.io/hook-delete-policy": HookSucceeded + {{- end}} {{- if .Values.global.secretsBackend.vault.enabled }} {{- /* Run the Vault agent as both an init container and sidecar. diff --git a/charts/consul/values.yaml b/charts/consul/values.yaml index 954680262a..240cb02b68 100644 --- a/charts/consul/values.yaml +++ b/charts/consul/values.yaml @@ -524,6 +524,15 @@ global: # @type: string annotations: null + # If set argocd.enabled is set to true, following annotations are added to + # jobs - server-acl-init-cleanup-job, gateway-cleanup-job, server-acl-init-job, + # gateway-resources-job + # annotations - + # argocd.argoproj.io/hook: Sync + # argocd.argoproj.io/hook-delete-policy: HookSucceeded + argocd: + enabled: false + # [Enterprise Only] This value refers to a Kubernetes or Vault secret that you have created # that contains your enterprise license. It is required if you are using an # enterprise binary. Defining it here applies it to your cluster once a leader From b8e627d849227e7b9cca563e57eb8264167ad4de Mon Sep 17 00:00:00 2001 From: absolutelightning Date: Thu, 17 Aug 2023 11:36:22 +0530 Subject: [PATCH 02/10] adds bats test and setting argo annotations if global.argocd.enabled = true --- .../consul/templates/gateway-cleanup-job.yaml | 3 +-- .../templates/gateway-resources-job.yaml | 3 +-- .../server-acl-init-cleanup-job.yaml | 3 +-- .../consul/templates/server-acl-init-job.yaml | 3 +-- .../consul/test/unit/gateway-cleanup-job.bats | 19 +++++++++++++++++++ .../test/unit/gateway-resources-job.bats | 18 ++++++++++++++++++ .../unit/server-acl-init-cleanup-job.bats | 18 ++++++++++++++++++ .../consul/test/unit/server-acl-init-job.bats | 18 ++++++++++++++++++ charts/consul/values.yaml | 5 ++++- 9 files changed, 81 insertions(+), 9 deletions(-) diff --git a/charts/consul/templates/gateway-cleanup-job.yaml b/charts/consul/templates/gateway-cleanup-job.yaml index 23e3b7d5ae..30c453cbcb 100644 --- a/charts/consul/templates/gateway-cleanup-job.yaml +++ b/charts/consul/templates/gateway-cleanup-job.yaml @@ -35,8 +35,7 @@ spec: {{- tpl .Values.global.acls.annotations . | nindent 8 }} {{- end }} {{- if .Values.global.argocd.enabled }} - "argocd.argoproj.io/hook": Sync - "argocd.argoproj.io/hook-delete-policy": HookSucceeded + {{- tpl .Values.global.argocd.annotations . | nindent 8 }} {{- end}} spec: restartPolicy: Never diff --git a/charts/consul/templates/gateway-resources-job.yaml b/charts/consul/templates/gateway-resources-job.yaml index 29f37fd566..11e8ff5686 100644 --- a/charts/consul/templates/gateway-resources-job.yaml +++ b/charts/consul/templates/gateway-resources-job.yaml @@ -35,8 +35,7 @@ spec: {{- tpl .Values.global.acls.annotations . | nindent 8 }} {{- end }} {{- if .Values.global.argocd.enabled }} - "argocd.argoproj.io/hook": Sync - "argocd.argoproj.io/hook-delete-policy": HookSucceeded + {{- tpl .Values.global.argocd.annotations . | nindent 8 }} {{- end}} spec: restartPolicy: Never diff --git a/charts/consul/templates/server-acl-init-cleanup-job.yaml b/charts/consul/templates/server-acl-init-cleanup-job.yaml index eeec7d5e6e..f06884d62b 100644 --- a/charts/consul/templates/server-acl-init-cleanup-job.yaml +++ b/charts/consul/templates/server-acl-init-cleanup-job.yaml @@ -51,8 +51,7 @@ spec: {{- tpl .Values.global.acls.annotations . | nindent 8 }} {{- end }} {{- if .Values.global.argocd.enabled }} - "argocd.argoproj.io/hook": Sync - "argocd.argoproj.io/hook-delete-policy": HookSucceeded + {{- tpl .Values.global.argocd.annotations . | nindent 8 }} {{- end}} spec: restartPolicy: Never diff --git a/charts/consul/templates/server-acl-init-job.yaml b/charts/consul/templates/server-acl-init-job.yaml index 17b8aa9ea6..5e82b2e9e6 100644 --- a/charts/consul/templates/server-acl-init-job.yaml +++ b/charts/consul/templates/server-acl-init-job.yaml @@ -50,8 +50,7 @@ spec: {{- tpl .Values.global.acls.annotations . | nindent 8 }} {{- end }} {{- if .Values.global.argocd.enabled }} - "argocd.argoproj.io/hook": Sync - "argocd.argoproj.io/hook-delete-policy": HookSucceeded + {{- tpl .Values.global.argocd.annotations . | nindent 8 }} {{- end}} {{- if .Values.global.secretsBackend.vault.enabled }} diff --git a/charts/consul/test/unit/gateway-cleanup-job.bats b/charts/consul/test/unit/gateway-cleanup-job.bats index 657bf4a791..e41b5b0b41 100644 --- a/charts/consul/test/unit/gateway-cleanup-job.bats +++ b/charts/consul/test/unit/gateway-cleanup-job.bats @@ -43,3 +43,22 @@ target=templates/gateway-cleanup-job.yaml yq -r '.spec.template.metadata.annotations.foo' | tee /dev/stderr) [ "${actual}" = "bar" ] } + +@test "gatewaycleanup/Job: argocd annotations are set if global.argocd.enabled is true" { + cd `chart_dir` + local actual=$(helm template \ + -s $target \ + --set 'global.acls.manageSystemACLs=true' \ + --set 'global.argocd.enabled=true' \ + . | tee /dev/stderr | + yq -r '.spec.template.metadata.annotations["argocd.argoproj.io/hook"]' | tee /dev/stderr) + [ "${actual}" = "Sync" ] + local actual=$(helm template \ + -s $target \ + --set 'global.acls.manageSystemACLs=true' \ + --set 'global.argocd.enabled=true' \ + . | tee /dev/stderr | + yq -r '.spec.template.metadata.annotations["argocd.argoproj.io/hook-delete-policy"]' | tee /dev/stderr) + [ "${actual}" = "HookSucceeded" ] +} + diff --git a/charts/consul/test/unit/gateway-resources-job.bats b/charts/consul/test/unit/gateway-resources-job.bats index 09322bd2a7..557ede73e6 100644 --- a/charts/consul/test/unit/gateway-resources-job.bats +++ b/charts/consul/test/unit/gateway-resources-job.bats @@ -162,3 +162,21 @@ target=templates/gateway-resources-job.yaml yq -r '.spec.template.metadata.annotations.foo' | tee /dev/stderr) [ "${actual}" = "bar" ] } + +@test "gatewayresources/Job: argocd annotations are set if global.argocd.enabled is true" { + cd `chart_dir` + local actual=$(helm template \ + -s $target \ + --set 'global.acls.manageSystemACLs=true' \ + --set 'global.argocd.enabled=true' \ + . | tee /dev/stderr | + yq -r '.spec.template.metadata.annotations["argocd.argoproj.io/hook"]' | tee /dev/stderr) + [ "${actual}" = "Sync" ] + local actual=$(helm template \ + -s $target \ + --set 'global.acls.manageSystemACLs=true' \ + --set 'global.argocd.enabled=true' \ + . | tee /dev/stderr | + yq -r '.spec.template.metadata.annotations["argocd.argoproj.io/hook-delete-policy"]' | tee /dev/stderr) + [ "${actual}" = "HookSucceeded" ] +} diff --git a/charts/consul/test/unit/server-acl-init-cleanup-job.bats b/charts/consul/test/unit/server-acl-init-cleanup-job.bats index 8743ea4a8d..bd5ffa026e 100644 --- a/charts/consul/test/unit/server-acl-init-cleanup-job.bats +++ b/charts/consul/test/unit/server-acl-init-cleanup-job.bats @@ -250,3 +250,21 @@ load _helpers yq -r '.spec.template.metadata.annotations.foo' | tee /dev/stderr) [ "${actual}" = "bar" ] } + +@test "serverACLInitCleanup/Job: argocd annotations are set if global.argocd.enabled is true" { + cd `chart_dir` + local actual=$(helm template \ + -s templates/server-acl-init-cleanup-job.yaml \ + --set 'global.acls.manageSystemACLs=true' \ + --set 'global.argocd.enabled=true' \ + . | tee /dev/stderr | + yq -r '.spec.template.metadata.annotations["argocd.argoproj.io/hook"]' | tee /dev/stderr) + [ "${actual}" = "Sync" ] + local actual=$(helm template \ + -s templates/server-acl-init-cleanup-job.yaml \ + --set 'global.acls.manageSystemACLs=true' \ + --set 'global.argocd.enabled=true' \ + . | tee /dev/stderr | + yq -r '.spec.template.metadata.annotations["argocd.argoproj.io/hook-delete-policy"]' | tee /dev/stderr) + [ "${actual}" = "HookSucceeded" ] +} \ No newline at end of file diff --git a/charts/consul/test/unit/server-acl-init-job.bats b/charts/consul/test/unit/server-acl-init-job.bats index 1dc55a9551..0898b59d1f 100644 --- a/charts/consul/test/unit/server-acl-init-job.bats +++ b/charts/consul/test/unit/server-acl-init-job.bats @@ -2296,3 +2296,21 @@ load _helpers yq -r '.spec.template.metadata.annotations.foo' | tee /dev/stderr) [ "${actual}" = "bar" ] } + +@test "serverACLInit/Job: argocd annotations are set if global.argocd.enabled is true" { + cd `chart_dir` + local actual=$(helm template \ + -s templates/server-acl-init-job.yaml \ + --set 'global.acls.manageSystemACLs=true' \ + --set 'global.argocd.enabled=true' \ + . | tee /dev/stderr | + yq -r '.spec.template.metadata.annotations["argocd.argoproj.io/hook"]' | tee /dev/stderr) + [ "${actual}" = "Sync" ] + local actual=$(helm template \ + -s templates/server-acl-init-job.yaml \ + --set 'global.acls.manageSystemACLs=true' \ + --set 'global.argocd.enabled=true' \ + . | tee /dev/stderr | + yq -r '.spec.template.metadata.annotations["argocd.argoproj.io/hook-delete-policy"]' | tee /dev/stderr) + [ "${actual}" = "HookSucceeded" ] +} diff --git a/charts/consul/values.yaml b/charts/consul/values.yaml index 240cb02b68..c9c6282a4b 100644 --- a/charts/consul/values.yaml +++ b/charts/consul/values.yaml @@ -531,7 +531,10 @@ global: # argocd.argoproj.io/hook: Sync # argocd.argoproj.io/hook-delete-policy: HookSucceeded argocd: - enabled: false + enabled: false + annotations: | + argocd.argoproj.io/hook: Sync + argocd.argoproj.io/hook-delete-policy: HookSucceeded # [Enterprise Only] This value refers to a Kubernetes or Vault secret that you have created # that contains your enterprise license. It is required if you are using an From 79a0779fb99db75248a217a00cb75167ba350759 Mon Sep 17 00:00:00 2001 From: absolutelightning Date: Thu, 17 Aug 2023 11:48:14 +0530 Subject: [PATCH 03/10] update comment --- charts/consul/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/consul/values.yaml b/charts/consul/values.yaml index c9c6282a4b..35f9016d94 100644 --- a/charts/consul/values.yaml +++ b/charts/consul/values.yaml @@ -525,7 +525,7 @@ global: annotations: null # If set argocd.enabled is set to true, following annotations are added to - # jobs - server-acl-init-cleanup-job, gateway-cleanup-job, server-acl-init-job, + # jobs - server-acl-init-cleanup-job, gateway-cleanup-job, server-acl-init-job and # gateway-resources-job # annotations - # argocd.argoproj.io/hook: Sync From c4368aa1070ddab7960be3434c689943ee4689af Mon Sep 17 00:00:00 2001 From: absolutelightning Date: Thu, 17 Aug 2023 11:56:28 +0530 Subject: [PATCH 04/10] added change log --- .changelog/2785.txt | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .changelog/2785.txt diff --git a/.changelog/2785.txt b/.changelog/2785.txt new file mode 100644 index 0000000000..115436a08b --- /dev/null +++ b/.changelog/2785.txt @@ -0,0 +1,4 @@ +```release-note:improvement +Add support for global.argocd.enabled flaag in values.yaml which adds the global.argocd.annotations in the jobs - +gateway-cleanup-job, gateway-resources-job, server-acl-init-job and server-acl-init-cleanup-job +``` \ No newline at end of file From 4711a7dbc83512b94780ff0c834b759e8eaccf50 Mon Sep 17 00:00:00 2001 From: Ashesh Vidyut <134911583+absolutelightning@users.noreply.github.com> Date: Fri, 18 Aug 2023 09:49:17 +0530 Subject: [PATCH 05/10] Update charts/consul/templates/gateway-cleanup-job.yaml Co-authored-by: Ganesh S --- charts/consul/templates/gateway-cleanup-job.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/consul/templates/gateway-cleanup-job.yaml b/charts/consul/templates/gateway-cleanup-job.yaml index 30c453cbcb..73b31e537c 100644 --- a/charts/consul/templates/gateway-cleanup-job.yaml +++ b/charts/consul/templates/gateway-cleanup-job.yaml @@ -36,7 +36,7 @@ spec: {{- end }} {{- if .Values.global.argocd.enabled }} {{- tpl .Values.global.argocd.annotations . | nindent 8 }} - {{- end}} + {{- end }} spec: restartPolicy: Never serviceAccountName: {{ template "consul.fullname" . }}-gateway-cleanup From 0128ec4c0e7a92a9e0553228dc6fa9e5ff02e3ab Mon Sep 17 00:00:00 2001 From: absolutelightning Date: Wed, 23 Aug 2023 10:55:46 +0530 Subject: [PATCH 06/10] comments fixes --- .../consul/templates/gateway-cleanup-job.yaml | 3 --- .../templates/gateway-resources-job.yaml | 3 --- .../server-acl-init-cleanup-job.yaml | 3 --- .../consul/templates/server-acl-init-job.yaml | 5 +++-- .../consul/test/unit/gateway-cleanup-job.bats | 19 ------------------ .../test/unit/gateway-resources-job.bats | 20 +------------------ .../unit/server-acl-init-cleanup-job.bats | 18 ----------------- .../consul/test/unit/server-acl-init-job.bats | 18 +++++++++++++++++ charts/consul/values.yaml | 3 --- 9 files changed, 22 insertions(+), 70 deletions(-) diff --git a/charts/consul/templates/gateway-cleanup-job.yaml b/charts/consul/templates/gateway-cleanup-job.yaml index 30c453cbcb..a987c3b591 100644 --- a/charts/consul/templates/gateway-cleanup-job.yaml +++ b/charts/consul/templates/gateway-cleanup-job.yaml @@ -34,9 +34,6 @@ spec: {{- if .Values.global.acls.annotations }} {{- tpl .Values.global.acls.annotations . | nindent 8 }} {{- end }} - {{- if .Values.global.argocd.enabled }} - {{- tpl .Values.global.argocd.annotations . | nindent 8 }} - {{- end}} spec: restartPolicy: Never serviceAccountName: {{ template "consul.fullname" . }}-gateway-cleanup diff --git a/charts/consul/templates/gateway-resources-job.yaml b/charts/consul/templates/gateway-resources-job.yaml index 11e8ff5686..de64e2d70d 100644 --- a/charts/consul/templates/gateway-resources-job.yaml +++ b/charts/consul/templates/gateway-resources-job.yaml @@ -34,9 +34,6 @@ spec: {{- if .Values.global.acls.annotations }} {{- tpl .Values.global.acls.annotations . | nindent 8 }} {{- end }} - {{- if .Values.global.argocd.enabled }} - {{- tpl .Values.global.argocd.annotations . | nindent 8 }} - {{- end}} spec: restartPolicy: Never serviceAccountName: {{ template "consul.fullname" . }}-gateway-resources diff --git a/charts/consul/templates/server-acl-init-cleanup-job.yaml b/charts/consul/templates/server-acl-init-cleanup-job.yaml index f06884d62b..39754d6c6f 100644 --- a/charts/consul/templates/server-acl-init-cleanup-job.yaml +++ b/charts/consul/templates/server-acl-init-cleanup-job.yaml @@ -50,9 +50,6 @@ spec: {{- if .Values.global.acls.annotations }} {{- tpl .Values.global.acls.annotations . | nindent 8 }} {{- end }} - {{- if .Values.global.argocd.enabled }} - {{- tpl .Values.global.argocd.annotations . | nindent 8 }} - {{- end}} spec: restartPolicy: Never serviceAccountName: {{ template "consul.fullname" . }}-server-acl-init-cleanup diff --git a/charts/consul/templates/server-acl-init-job.yaml b/charts/consul/templates/server-acl-init-job.yaml index 5e82b2e9e6..a72d12f80d 100644 --- a/charts/consul/templates/server-acl-init-job.yaml +++ b/charts/consul/templates/server-acl-init-job.yaml @@ -50,8 +50,9 @@ spec: {{- tpl .Values.global.acls.annotations . | nindent 8 }} {{- end }} {{- if .Values.global.argocd.enabled }} - {{- tpl .Values.global.argocd.annotations . | nindent 8 }} - {{- end}} + "argocd.argoproj.io/hook": "Sync" + "argocd.argoproj.io/hook-delete-policy": "HookSucceeded" + {{- end }} {{- if .Values.global.secretsBackend.vault.enabled }} {{- /* Run the Vault agent as both an init container and sidecar. diff --git a/charts/consul/test/unit/gateway-cleanup-job.bats b/charts/consul/test/unit/gateway-cleanup-job.bats index e41b5b0b41..657bf4a791 100644 --- a/charts/consul/test/unit/gateway-cleanup-job.bats +++ b/charts/consul/test/unit/gateway-cleanup-job.bats @@ -43,22 +43,3 @@ target=templates/gateway-cleanup-job.yaml yq -r '.spec.template.metadata.annotations.foo' | tee /dev/stderr) [ "${actual}" = "bar" ] } - -@test "gatewaycleanup/Job: argocd annotations are set if global.argocd.enabled is true" { - cd `chart_dir` - local actual=$(helm template \ - -s $target \ - --set 'global.acls.manageSystemACLs=true' \ - --set 'global.argocd.enabled=true' \ - . | tee /dev/stderr | - yq -r '.spec.template.metadata.annotations["argocd.argoproj.io/hook"]' | tee /dev/stderr) - [ "${actual}" = "Sync" ] - local actual=$(helm template \ - -s $target \ - --set 'global.acls.manageSystemACLs=true' \ - --set 'global.argocd.enabled=true' \ - . | tee /dev/stderr | - yq -r '.spec.template.metadata.annotations["argocd.argoproj.io/hook-delete-policy"]' | tee /dev/stderr) - [ "${actual}" = "HookSucceeded" ] -} - diff --git a/charts/consul/test/unit/gateway-resources-job.bats b/charts/consul/test/unit/gateway-resources-job.bats index 557ede73e6..d97ab24086 100644 --- a/charts/consul/test/unit/gateway-resources-job.bats +++ b/charts/consul/test/unit/gateway-resources-job.bats @@ -161,22 +161,4 @@ target=templates/gateway-resources-job.yaml . | tee /dev/stderr | yq -r '.spec.template.metadata.annotations.foo' | tee /dev/stderr) [ "${actual}" = "bar" ] -} - -@test "gatewayresources/Job: argocd annotations are set if global.argocd.enabled is true" { - cd `chart_dir` - local actual=$(helm template \ - -s $target \ - --set 'global.acls.manageSystemACLs=true' \ - --set 'global.argocd.enabled=true' \ - . | tee /dev/stderr | - yq -r '.spec.template.metadata.annotations["argocd.argoproj.io/hook"]' | tee /dev/stderr) - [ "${actual}" = "Sync" ] - local actual=$(helm template \ - -s $target \ - --set 'global.acls.manageSystemACLs=true' \ - --set 'global.argocd.enabled=true' \ - . | tee /dev/stderr | - yq -r '.spec.template.metadata.annotations["argocd.argoproj.io/hook-delete-policy"]' | tee /dev/stderr) - [ "${actual}" = "HookSucceeded" ] -} +} \ No newline at end of file diff --git a/charts/consul/test/unit/server-acl-init-cleanup-job.bats b/charts/consul/test/unit/server-acl-init-cleanup-job.bats index bd5ffa026e..8c84143796 100644 --- a/charts/consul/test/unit/server-acl-init-cleanup-job.bats +++ b/charts/consul/test/unit/server-acl-init-cleanup-job.bats @@ -249,22 +249,4 @@ load _helpers . | tee /dev/stderr | yq -r '.spec.template.metadata.annotations.foo' | tee /dev/stderr) [ "${actual}" = "bar" ] -} - -@test "serverACLInitCleanup/Job: argocd annotations are set if global.argocd.enabled is true" { - cd `chart_dir` - local actual=$(helm template \ - -s templates/server-acl-init-cleanup-job.yaml \ - --set 'global.acls.manageSystemACLs=true' \ - --set 'global.argocd.enabled=true' \ - . | tee /dev/stderr | - yq -r '.spec.template.metadata.annotations["argocd.argoproj.io/hook"]' | tee /dev/stderr) - [ "${actual}" = "Sync" ] - local actual=$(helm template \ - -s templates/server-acl-init-cleanup-job.yaml \ - --set 'global.acls.manageSystemACLs=true' \ - --set 'global.argocd.enabled=true' \ - . | tee /dev/stderr | - yq -r '.spec.template.metadata.annotations["argocd.argoproj.io/hook-delete-policy"]' | tee /dev/stderr) - [ "${actual}" = "HookSucceeded" ] } \ No newline at end of file diff --git a/charts/consul/test/unit/server-acl-init-job.bats b/charts/consul/test/unit/server-acl-init-job.bats index 0898b59d1f..81022a8e4c 100644 --- a/charts/consul/test/unit/server-acl-init-job.bats +++ b/charts/consul/test/unit/server-acl-init-job.bats @@ -2314,3 +2314,21 @@ load _helpers yq -r '.spec.template.metadata.annotations["argocd.argoproj.io/hook-delete-policy"]' | tee /dev/stderr) [ "${actual}" = "HookSucceeded" ] } + +@test "serverACLInit/Job: argocd annotations are not set if global.argocd.enabled is false" { + cd `chart_dir` + local actual=$(helm template \ + -s templates/server-acl-init-job.yaml \ + --set 'global.acls.manageSystemACLs=true' \ + --set 'global.argocd.enabled=false' \ + . | tee /dev/stderr | + yq -r '.spec.template.metadata.annotations["argocd.argoproj.io/hook"]' | tee /dev/stderr) + [ "${actual}" = null ] + local actual=$(helm template \ + -s templates/server-acl-init-job.yaml \ + --set 'global.acls.manageSystemACLs=true' \ + --set 'global.argocd.enabled=false' \ + . | tee /dev/stderr | + yq -r '.spec.template.metadata.annotations["argocd.argoproj.io/hook-delete-policy"]' | tee /dev/stderr) + [ "${actual}" = null ] +} diff --git a/charts/consul/values.yaml b/charts/consul/values.yaml index 35f9016d94..ead649423f 100644 --- a/charts/consul/values.yaml +++ b/charts/consul/values.yaml @@ -532,9 +532,6 @@ global: # argocd.argoproj.io/hook-delete-policy: HookSucceeded argocd: enabled: false - annotations: | - argocd.argoproj.io/hook: Sync - argocd.argoproj.io/hook-delete-policy: HookSucceeded # [Enterprise Only] This value refers to a Kubernetes or Vault secret that you have created # that contains your enterprise license. It is required if you are using an From c4af09db899624c2ab4c62e963b9d1e75581023e Mon Sep 17 00:00:00 2001 From: absolutelightning Date: Wed, 23 Aug 2023 10:57:37 +0530 Subject: [PATCH 07/10] fix line diff --- charts/consul/test/unit/gateway-resources-job.bats | 2 +- charts/consul/test/unit/server-acl-init-cleanup-job.bats | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/consul/test/unit/gateway-resources-job.bats b/charts/consul/test/unit/gateway-resources-job.bats index d97ab24086..09322bd2a7 100644 --- a/charts/consul/test/unit/gateway-resources-job.bats +++ b/charts/consul/test/unit/gateway-resources-job.bats @@ -161,4 +161,4 @@ target=templates/gateway-resources-job.yaml . | tee /dev/stderr | yq -r '.spec.template.metadata.annotations.foo' | tee /dev/stderr) [ "${actual}" = "bar" ] -} \ No newline at end of file +} diff --git a/charts/consul/test/unit/server-acl-init-cleanup-job.bats b/charts/consul/test/unit/server-acl-init-cleanup-job.bats index 8c84143796..8743ea4a8d 100644 --- a/charts/consul/test/unit/server-acl-init-cleanup-job.bats +++ b/charts/consul/test/unit/server-acl-init-cleanup-job.bats @@ -249,4 +249,4 @@ load _helpers . | tee /dev/stderr | yq -r '.spec.template.metadata.annotations.foo' | tee /dev/stderr) [ "${actual}" = "bar" ] -} \ No newline at end of file +} From 25e7c68e2aeb55b56acdd89c91a6bd3a07610de7 Mon Sep 17 00:00:00 2001 From: absolutelightning Date: Wed, 23 Aug 2023 11:00:05 +0530 Subject: [PATCH 08/10] change log fix --- .changelog/2785.txt | 5 +++-- charts/consul/values.yaml | 5 ++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.changelog/2785.txt b/.changelog/2785.txt index 115436a08b..8c6382dbf8 100644 --- a/.changelog/2785.txt +++ b/.changelog/2785.txt @@ -1,4 +1,5 @@ ```release-note:improvement -Add support for global.argocd.enabled flaag in values.yaml which adds the global.argocd.annotations in the jobs - -gateway-cleanup-job, gateway-resources-job, server-acl-init-job and server-acl-init-cleanup-job +If argocd.enabled is set to true, following annotations are added to job - server-acl-init-job and + argocd.argoproj.io/hook: Sync + argocd.argoproj.io/hook-delete-policy: HookSucceeded ``` \ No newline at end of file diff --git a/charts/consul/values.yaml b/charts/consul/values.yaml index ead649423f..1cabcdc6fd 100644 --- a/charts/consul/values.yaml +++ b/charts/consul/values.yaml @@ -524,9 +524,8 @@ global: # @type: string annotations: null - # If set argocd.enabled is set to true, following annotations are added to - # jobs - server-acl-init-cleanup-job, gateway-cleanup-job, server-acl-init-job and - # gateway-resources-job + # If argocd.enabled is set to true, following annotations are added to + # jobs - server-acl-init-job and # annotations - # argocd.argoproj.io/hook: Sync # argocd.argoproj.io/hook-delete-policy: HookSucceeded From 9c81a52f25e5c9e21faa27e86588f6e1486f825b Mon Sep 17 00:00:00 2001 From: absolutelightning Date: Wed, 23 Aug 2023 12:03:01 +0530 Subject: [PATCH 09/10] fix comment --- .changelog/2785.txt | 2 +- charts/consul/values.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.changelog/2785.txt b/.changelog/2785.txt index 8c6382dbf8..3b639f8a28 100644 --- a/.changelog/2785.txt +++ b/.changelog/2785.txt @@ -1,5 +1,5 @@ ```release-note:improvement -If argocd.enabled is set to true, following annotations are added to job - server-acl-init-job and +If argocd.enabled is set to true, following annotations are added to job - server-acl-init-job argocd.argoproj.io/hook: Sync argocd.argoproj.io/hook-delete-policy: HookSucceeded ``` \ No newline at end of file diff --git a/charts/consul/values.yaml b/charts/consul/values.yaml index 1cabcdc6fd..0cba942948 100644 --- a/charts/consul/values.yaml +++ b/charts/consul/values.yaml @@ -525,7 +525,7 @@ global: annotations: null # If argocd.enabled is set to true, following annotations are added to - # jobs - server-acl-init-job and + # job - server-acl-init-job # annotations - # argocd.argoproj.io/hook: Sync # argocd.argoproj.io/hook-delete-policy: HookSucceeded From b7bf2c2e1987cf0f536b79ed313a511753237628 Mon Sep 17 00:00:00 2001 From: Ashesh Vidyut <134911583+absolutelightning@users.noreply.github.com> Date: Tue, 29 Aug 2023 07:22:34 +0530 Subject: [PATCH 10/10] Update .changelog/2785.txt Co-authored-by: Luke Kysow <1034429+lkysow@users.noreply.github.com> --- .changelog/2785.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.changelog/2785.txt b/.changelog/2785.txt index 3b639f8a28..02a7b3748e 100644 --- a/.changelog/2785.txt +++ b/.changelog/2785.txt @@ -1,5 +1,3 @@ ```release-note:improvement -If argocd.enabled is set to true, following annotations are added to job - server-acl-init-job - argocd.argoproj.io/hook: Sync - argocd.argoproj.io/hook-delete-policy: HookSucceeded +Add new value `global.argocd.enabled`. Set this to `true` when using ArgoCD to deploy this chart. ``` \ No newline at end of file