From 2a4ed5782234d62f7c3e74b13eadf3ad91c735cb Mon Sep 17 00:00:00 2001 From: Aline Abler Date: Fri, 13 Sep 2024 11:51:10 +0200 Subject: [PATCH 1/2] Turn the presync service account into a PreSync hook --- component/cleanup.libsonnet | 7 ++++++- .../olm-opensource/cilium/cilium/olm/99_cleanup.yaml | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/component/cleanup.libsonnet b/component/cleanup.libsonnet index 3502ed79..311fba91 100644 --- a/component/cleanup.libsonnet +++ b/component/cleanup.libsonnet @@ -18,7 +18,12 @@ local role = kube.Role(name) { }; local serviceAccount = kube.ServiceAccount(name) { - metadata+: { namespace: namespace }, + metadata+: { + namespace: namespace, + annotations+: { + 'argocd.argoproj.io/hook': 'PreSync', + }, + }, }; local roleBinding = kube.RoleBinding(name) { diff --git a/tests/golden/olm-opensource/cilium/cilium/olm/99_cleanup.yaml b/tests/golden/olm-opensource/cilium/cilium/olm/99_cleanup.yaml index d84459ad..274f0011 100644 --- a/tests/golden/olm-opensource/cilium/cilium/olm/99_cleanup.yaml +++ b/tests/golden/olm-opensource/cilium/cilium/olm/99_cleanup.yaml @@ -19,7 +19,8 @@ rules: apiVersion: v1 kind: ServiceAccount metadata: - annotations: {} + annotations: + argocd.argoproj.io/hook: PreSync labels: name: cleanup-old-clusterserviceversions name: cleanup-old-clusterserviceversions From 9ac5c805e3d94d4882b2e59ce73d087a6fc23f3e Mon Sep 17 00:00:00 2001 From: Aline Abler Date: Mon, 16 Sep 2024 10:23:16 +0200 Subject: [PATCH 2/2] Add PreSync hook to cleanup role and rolebinding --- component/cleanup.libsonnet | 14 ++++++++++++-- .../cilium/cilium/olm/99_cleanup.yaml | 6 ++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/component/cleanup.libsonnet b/component/cleanup.libsonnet index 311fba91..9723d451 100644 --- a/component/cleanup.libsonnet +++ b/component/cleanup.libsonnet @@ -7,7 +7,12 @@ local name = 'cleanup-old-clusterserviceversions'; local namespace = params._namespace; local role = kube.Role(name) { - metadata+: { namespace: namespace }, + metadata+: { + namespace: namespace, + annotations+: { + 'argocd.argoproj.io/hook': 'PreSync', + }, + }, rules: [ { apiGroups: [ 'operators.coreos.com' ], @@ -27,7 +32,12 @@ local serviceAccount = kube.ServiceAccount(name) { }; local roleBinding = kube.RoleBinding(name) { - metadata+: { namespace: namespace }, + metadata+: { + namespace: namespace, + annotations+: { + 'argocd.argoproj.io/hook': 'PreSync', + }, + }, subjects_: [ serviceAccount ], roleRef_: role, }; diff --git a/tests/golden/olm-opensource/cilium/cilium/olm/99_cleanup.yaml b/tests/golden/olm-opensource/cilium/cilium/olm/99_cleanup.yaml index 274f0011..586ea56a 100644 --- a/tests/golden/olm-opensource/cilium/cilium/olm/99_cleanup.yaml +++ b/tests/golden/olm-opensource/cilium/cilium/olm/99_cleanup.yaml @@ -1,7 +1,8 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: - annotations: {} + annotations: + argocd.argoproj.io/hook: PreSync labels: name: cleanup-old-clusterserviceversions name: cleanup-old-clusterserviceversions @@ -29,7 +30,8 @@ metadata: apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: - annotations: {} + annotations: + argocd.argoproj.io/hook: PreSync labels: name: cleanup-old-clusterserviceversions name: cleanup-old-clusterserviceversions