-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WS-3148] Service Accounts configuration for cms and proxy
- Loading branch information
1 parent
5d4b9fa
commit 6615319
Showing
10 changed files
with
287 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{{- if .Values.cms.serviceAccount.create }} | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: {{ .Values.cms.serviceAccount.name | default (include "websight-cms.component.fullname" (dict "componentName" "cms" "context" $)) }} | ||
labels: | ||
{{- include "websight-cms.component.labels" (dict "componentName" "cms" "context" $) | nindent 4 }} | ||
automountServiceAccountToken: {{ .Values.cms.serviceAccount.automountServiceAccountToken }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{{- if .Values.proxy.enabled -}} | ||
{{- if .Values.proxy.serviceAccount.create }} | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: {{ .Values.proxy.serviceAccount.name | default (include "websight-cms.component.fullname" (dict "componentName" "proxy" "context" $)) }} | ||
labels: | ||
{{- include "websight-cms.component.labels" (dict "componentName" "proxy" "context" $) | nindent 4 }} | ||
automountServiceAccountToken: {{ .Values.proxy.serviceAccount.automountServiceAccountToken }} | ||
{{- end }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json | ||
|
||
suite: test cms service account configuration | ||
release: | ||
name: test | ||
tests: | ||
# @Test | ||
- it: create service account with default name and default values and bind it to the statefulset pod | ||
asserts: | ||
- hasDocuments: | ||
count: 1 | ||
template: templates/cms/cms-serviceaccount.yaml | ||
- isKind: | ||
of: ServiceAccount | ||
template: templates/cms/cms-serviceaccount.yaml | ||
- equal: | ||
path: metadata.name | ||
value: test-websight-cms-cms | ||
template: templates/cms/cms-serviceaccount.yaml | ||
- equal: | ||
path: spec.template.spec.serviceAccountName | ||
value: test-websight-cms-cms | ||
template: templates/cms/cms-statefulset.yaml | ||
# @Test | ||
- it: create service account with default name and default values and bind it to the deployment pod | ||
set: | ||
cms: | ||
persistence: | ||
mode: mongo | ||
asserts: | ||
- hasDocuments: | ||
count: 1 | ||
template: templates/cms/cms-serviceaccount.yaml | ||
- isKind: | ||
of: ServiceAccount | ||
template: templates/cms/cms-serviceaccount.yaml | ||
- equal: | ||
path: metadata.name | ||
value: test-websight-cms-cms | ||
template: templates/cms/cms-serviceaccount.yaml | ||
- equal: | ||
path: spec.template.spec.serviceAccountName | ||
value: test-websight-cms-cms | ||
template: templates/cms/cms-deployment.yaml | ||
# @Test | ||
- it: create service account with custom name and default values and bind it to the statefulset pod | ||
set: | ||
cms: | ||
serviceAccount: | ||
name: custom-name | ||
asserts: | ||
- hasDocuments: | ||
count: 1 | ||
template: templates/cms/cms-serviceaccount.yaml | ||
- isKind: | ||
of: ServiceAccount | ||
template: templates/cms/cms-serviceaccount.yaml | ||
- equal: | ||
path: metadata.name | ||
value: custom-name | ||
template: templates/cms/cms-serviceaccount.yaml | ||
- equal: | ||
path: spec.template.spec.serviceAccountName | ||
value: custom-name | ||
template: templates/cms/cms-statefulset.yaml | ||
# @Test | ||
- it: create service account with custom name and default values and bind it to the deployment pod | ||
set: | ||
cms: | ||
serviceAccount: | ||
name: custom-name | ||
persistence: | ||
mode: mongo | ||
asserts: | ||
- hasDocuments: | ||
count: 1 | ||
template: templates/cms/cms-serviceaccount.yaml | ||
- isKind: | ||
of: ServiceAccount | ||
template: templates/cms/cms-serviceaccount.yaml | ||
- equal: | ||
path: metadata.name | ||
value: custom-name | ||
template: templates/cms/cms-serviceaccount.yaml | ||
- equal: | ||
path: spec.template.spec.serviceAccountName | ||
value: custom-name | ||
template: templates/cms/cms-deployment.yaml | ||
# @Test | ||
- it: when create is disabled and service account name not set, service account should not be created and default binding should be present on the statefulset pod | ||
set: | ||
cms: | ||
serviceAccount: | ||
create: false | ||
asserts: | ||
- hasDocuments: | ||
count: 0 | ||
template: templates/cms/cms-serviceaccount.yaml | ||
- equal: | ||
path: spec.template.spec.serviceAccountName | ||
value: default | ||
template: templates/cms/cms-statefulset.yaml | ||
# @Test | ||
- it: when create is disabled and service account name not set, service account should not be created and default binding should be present on the deployment pod | ||
set: | ||
cms: | ||
serviceAccount: | ||
create: false | ||
persistence: | ||
mode: mongo | ||
asserts: | ||
- hasDocuments: | ||
count: 0 | ||
template: templates/cms/cms-serviceaccount.yaml | ||
- equal: | ||
path: spec.template.spec.serviceAccountName | ||
value: default | ||
template: templates/cms/cms-deployment.yaml | ||
# @Test | ||
- it: when create is disabled and service account name is set, service account should not be created and custom binding should be present on the statefulset pod | ||
set: | ||
cms: | ||
serviceAccount: | ||
create: false | ||
name: custom-name | ||
asserts: | ||
- hasDocuments: | ||
count: 0 | ||
template: templates/cms/cms-serviceaccount.yaml | ||
- equal: | ||
path: spec.template.spec.serviceAccountName | ||
value: custom-name | ||
template: templates/cms/cms-statefulset.yaml | ||
# @Test | ||
- it: when create is disabled and service account name is set, service account should not be created and custom binding should be present on the deployment pod | ||
set: | ||
cms: | ||
serviceAccount: | ||
create: false | ||
name: custom-name | ||
persistence: | ||
mode: mongo | ||
asserts: | ||
- hasDocuments: | ||
count: 0 | ||
template: templates/cms/cms-serviceaccount.yaml | ||
- equal: | ||
path: spec.template.spec.serviceAccountName | ||
value: custom-name | ||
template: templates/cms/cms-deployment.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json | ||
|
||
suite: test proxy service account configuration | ||
release: | ||
name: test | ||
tests: | ||
# @Test | ||
- it: create service account with default name and default values and bind it to the pod | ||
set: | ||
proxy: | ||
enabled: true | ||
asserts: | ||
- hasDocuments: | ||
count: 1 | ||
template: templates/proxy/proxy-serviceaccount.yaml | ||
- isKind: | ||
of: ServiceAccount | ||
template: templates/proxy/proxy-serviceaccount.yaml | ||
- equal: | ||
path: metadata.name | ||
value: test-websight-cms-proxy | ||
template: templates/proxy/proxy-serviceaccount.yaml | ||
- equal: | ||
path: spec.template.spec.serviceAccountName | ||
value: test-websight-cms-proxy | ||
template: templates/proxy/proxy-deployment.yaml | ||
# @Test | ||
- it: create service account with custom name and default values and bind it to the pod | ||
set: | ||
proxy: | ||
enabled: true | ||
serviceAccount: | ||
name: custom-name | ||
asserts: | ||
- hasDocuments: | ||
count: 1 | ||
template: templates/proxy/proxy-serviceaccount.yaml | ||
- isKind: | ||
of: ServiceAccount | ||
template: templates/proxy/proxy-serviceaccount.yaml | ||
- equal: | ||
path: metadata.name | ||
value: custom-name | ||
template: templates/proxy/proxy-serviceaccount.yaml | ||
- equal: | ||
path: spec.template.spec.serviceAccountName | ||
value: custom-name | ||
template: templates/proxy/proxy-deployment.yaml | ||
# @Test | ||
- it: when create is disabled and service account name not set, service account should not be created and default binding should be present on the pod | ||
set: | ||
proxy: | ||
enabled: true | ||
serviceAccount: | ||
create: false | ||
asserts: | ||
- hasDocuments: | ||
count: 0 | ||
template: templates/proxy/proxy-serviceaccount.yaml | ||
- equal: | ||
path: spec.template.spec.serviceAccountName | ||
value: default | ||
template: templates/proxy/proxy-deployment.yaml | ||
|
||
# @Test | ||
- it: when create is disabled and service account name is set, service account should not be created and custom binding should be present on the pod | ||
set: | ||
proxy: | ||
enabled: true | ||
serviceAccount: | ||
create: false | ||
name: custom-name | ||
asserts: | ||
- hasDocuments: | ||
count: 0 | ||
template: templates/proxy/proxy-serviceaccount.yaml | ||
- equal: | ||
path: spec.template.spec.serviceAccountName | ||
value: custom-name | ||
template: templates/proxy/proxy-deployment.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters