From 1ce8ab4034c08e36a77647f77ba182e91e44d3e5 Mon Sep 17 00:00:00 2001 From: sjeyaraman Date: Thu, 11 Aug 2022 16:47:04 -0700 Subject: [PATCH 1/3] make-SA-labels-customizable --- CHANGELOG.md | 1 + templates/service-account.yaml | 3 +++ tests/unit/labels_test.yaml | 18 ++++++++++++++++++ values.yaml | 5 ++++- 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ebf8c9c6..d05d30f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ * Fix mounts for `jobs.preRegisterContentCommand` container to use the same mounts as the primary register-content container. (#322) (by @cognifloyd) * Add support for providing custom st2actionrunner-specific docker repository, image name, pull policy, and pull secret via `values.yaml`. (#141) (by @Sheshagiri) * Fix bug that hung an init container when `st2.packs.volumes.enabled` without `st2.packs.volumes.configs`. (#324) (by @rebrowning) +* Add ability to create custom labels for service account.(#)(by @SuganJoe) ## v0.100.0 * Switch st2 to `v3.7` as a new default stable version (#274) diff --git a/templates/service-account.yaml b/templates/service-account.yaml index 4d1d3380..d1e77850 100644 --- a/templates/service-account.yaml +++ b/templates/service-account.yaml @@ -9,6 +9,9 @@ metadata: {{- toYaml .Values.serviceAccount.serviceAccountAnnotations | nindent 4 }} {{- end }} labels: {{- include "stackstorm-ha.labels" (list $ (include "stackstorm-ha.name" $)) | nindent 4 }} + {{- if .Values.serviceAccount.serviceAccountLabels }} + {{- toYaml .Values.serviceAccount.serviceAccountLabels | nindent 4 }} + {{- end }} {{- if .Values.serviceAccount.pullSecret }} imagePullSecrets: - name: "{{ .Values.serviceAccount.pullSecret }}" diff --git a/tests/unit/labels_test.yaml b/tests/unit/labels_test.yaml index 5584f89b..a4ad77d5 100644 --- a/tests/unit/labels_test.yaml +++ b/tests/unit/labels_test.yaml @@ -214,6 +214,24 @@ tests: path: metadata.labels.heritage value: Helm + - it: ServiceAccount accepts custom labels + template: service-account.yaml + set: + serviceAccount: + create: true + serviceAccountLabels: &labels + foo: bar + answer: "42" + asserts: &labels_asserts + - isNotNull: + path: metadata.labels + - equal: + path: metadata.labels.foo + value: bar + - equal: + path: metadata.labels.answer + value: "42" + - it: st2web Ingress has required labels template: ingress.yaml set: diff --git a/values.yaml b/values.yaml index 77a206fb..38e22e7f 100644 --- a/values.yaml +++ b/values.yaml @@ -32,6 +32,9 @@ serviceAccount: serviceAccountAnnotations: {} # Used to override service account name serviceAccountName: + # Used to define any custom labels required + #serviceAccountLabels: {} + # Fallback image pull secret. # If a pod does not have pull secrets, k8s will use the service account's pull secrets. # See: https://kubernetes.io/docs/reference/access-authn-authz/service-accounts-admin/#serviceaccount-admission-controller @@ -67,7 +70,7 @@ st2: config: | [api] allow_origin = '*' - + #Override Definitions can be added here. #https://docs.stackstorm.com/latest/packs.html#overriding-pack-defaults overrides: {} From f93a19bab4d5a95392cd55aaf09a52156cfd8703 Mon Sep 17 00:00:00 2001 From: sjeyaraman Date: Thu, 11 Aug 2022 17:13:59 -0700 Subject: [PATCH 2/3] update-changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d05d30f4..b07f7761 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ * Fix mounts for `jobs.preRegisterContentCommand` container to use the same mounts as the primary register-content container. (#322) (by @cognifloyd) * Add support for providing custom st2actionrunner-specific docker repository, image name, pull policy, and pull secret via `values.yaml`. (#141) (by @Sheshagiri) * Fix bug that hung an init container when `st2.packs.volumes.enabled` without `st2.packs.volumes.configs`. (#324) (by @rebrowning) -* Add ability to create custom labels for service account.(#)(by @SuganJoe) +* Add ability to create custom labels for service account.(#327)(by @SuganJoe) ## v0.100.0 * Switch st2 to `v3.7` as a new default stable version (#274) From 178c74e63f151f5304999970e8ad70a4a84da9e7 Mon Sep 17 00:00:00 2001 From: sjeyaraman Date: Thu, 11 Aug 2022 17:31:48 -0700 Subject: [PATCH 3/3] clean-up-unit-test --- tests/unit/labels_test.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/labels_test.yaml b/tests/unit/labels_test.yaml index a4ad77d5..f66f7452 100644 --- a/tests/unit/labels_test.yaml +++ b/tests/unit/labels_test.yaml @@ -219,10 +219,10 @@ tests: set: serviceAccount: create: true - serviceAccountLabels: &labels + serviceAccountLabels: foo: bar answer: "42" - asserts: &labels_asserts + asserts: - isNotNull: path: metadata.labels - equal: