Skip to content

Commit e07f0f6

Browse files
AranshGacko
andauthored
Chart: Set automountServiceAccountToken in workloads. (#12247)
Signed-off-by: Aran Shavit <[email protected]> Co-authored-by: Marco Ebert <[email protected]>
1 parent bd76cf8 commit e07f0f6

10 files changed

+55
-0
lines changed

charts/ingress-nginx/templates/admission-webhooks/job-patch/job-createSecret.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ spec:
6767
{{- end }}
6868
restartPolicy: OnFailure
6969
serviceAccountName: {{ include "ingress-nginx.admissionWebhooks.patch.serviceAccountName" . }}
70+
automountServiceAccountToken: {{ .Values.controller.admissionWebhooks.patch.serviceAccount.automountServiceAccountToken }}
7071
{{- if .Values.controller.admissionWebhooks.patch.nodeSelector }}
7172
nodeSelector: {{ toYaml .Values.controller.admissionWebhooks.patch.nodeSelector | nindent 8 }}
7273
{{- end }}

charts/ingress-nginx/templates/admission-webhooks/job-patch/job-patchWebhook.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ spec:
6969
{{- end }}
7070
restartPolicy: OnFailure
7171
serviceAccountName: {{ include "ingress-nginx.admissionWebhooks.patch.serviceAccountName" . }}
72+
automountServiceAccountToken: {{ .Values.controller.admissionWebhooks.patch.serviceAccount.automountServiceAccountToken }}
7273
{{- if .Values.controller.admissionWebhooks.patch.nodeSelector }}
7374
nodeSelector: {{ toYaml .Values.controller.admissionWebhooks.patch.nodeSelector | nindent 8 }}
7475
{{- end }}

charts/ingress-nginx/templates/controller-daemonset.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ spec:
202202
topologySpreadConstraints: {{ tpl (toYaml .Values.controller.topologySpreadConstraints) $ | nindent 8 }}
203203
{{- end }}
204204
serviceAccountName: {{ template "ingress-nginx.serviceAccountName" . }}
205+
automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }}
205206
terminationGracePeriodSeconds: {{ .Values.controller.terminationGracePeriodSeconds }}
206207
{{- if (or .Values.controller.customTemplate.configMapName .Values.controller.extraVolumeMounts .Values.controller.admissionWebhooks.enabled .Values.controller.extraVolumes .Values.controller.extraModules) }}
207208
volumes:

charts/ingress-nginx/templates/controller-deployment.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ spec:
208208
topologySpreadConstraints: {{ tpl (toYaml .Values.controller.topologySpreadConstraints) $ | nindent 8 }}
209209
{{- end }}
210210
serviceAccountName: {{ template "ingress-nginx.serviceAccountName" . }}
211+
automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }}
211212
terminationGracePeriodSeconds: {{ .Values.controller.terminationGracePeriodSeconds }}
212213
{{- if (or .Values.controller.customTemplate.configMapName .Values.controller.extraVolumeMounts .Values.controller.admissionWebhooks.enabled .Values.controller.extraVolumes .Values.controller.extraModules) }}
213214
volumes:

charts/ingress-nginx/templates/default-backend-deployment.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ spec:
103103
nodeSelector: {{ toYaml .Values.defaultBackend.nodeSelector | nindent 8 }}
104104
{{- end }}
105105
serviceAccountName: {{ include "ingress-nginx.defaultBackend.serviceAccountName" . }}
106+
automountServiceAccountToken: {{ .Values.defaultBackend.serviceAccount.automountServiceAccountToken }}
106107
{{- if .Values.defaultBackend.tolerations }}
107108
tolerations: {{ toYaml .Values.defaultBackend.tolerations | nindent 8 }}
108109
{{- end }}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
suite: Admission Webhooks > Patch Job > Create Secret Job
2+
templates:
3+
- admission-webhooks/job-patch/job-createSecret.yaml
4+
5+
tests:
6+
- it: should create a Job with token auto-mounting disabled if `controller.admissionWebhooks.patch.serviceAccount.automountServiceAccountToken` is false
7+
set:
8+
controller.admissionWebhooks.patch.serviceAccount.automountServiceAccountToken: false
9+
asserts:
10+
- equal:
11+
path: spec.template.spec.automountServiceAccountToken
12+
value: false
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
suite: Admission Webhooks > Patch Job > Patch Webhook Job
2+
templates:
3+
- admission-webhooks/job-patch/job-patchWebhook.yaml
4+
5+
tests:
6+
- it: should create a Job with token auto-mounting disabled if `controller.admissionWebhooks.patch.serviceAccount.automountServiceAccountToken` is false
7+
set:
8+
controller.admissionWebhooks.patch.serviceAccount.automountServiceAccountToken: false
9+
asserts:
10+
- equal:
11+
path: spec.template.spec.automountServiceAccountToken
12+
value: false

charts/ingress-nginx/tests/controller-daemonset_test.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,12 @@ tests:
190190
- equal:
191191
path: spec.template.spec.containers[0].image
192192
value: registry.k8s.io/ingress-nginx/controller:custom-tag@sha256:faa2d18687f734994b6bd9e309e7a73852a81c30e1b8f63165fcd4f0a087e3cd
193+
194+
- it: should create a DaemonSet with token auto-mounting disabled if `serviceAccount.automountServiceAccountToken` is false
195+
set:
196+
controller.kind: DaemonSet
197+
serviceAccount.automountServiceAccountToken: false
198+
asserts:
199+
- equal:
200+
path: spec.template.spec.automountServiceAccountToken
201+
value: false

charts/ingress-nginx/tests/controller-deployment_test.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,3 +215,11 @@ tests:
215215
- equal:
216216
path: spec.progressDeadlineSeconds
217217
value: 111
218+
219+
- it: should create a Deployment with token auto-mounting disabled if `serviceAccount.automountServiceAccountToken` is false
220+
set:
221+
serviceAccount.automountServiceAccountToken: false
222+
asserts:
223+
- equal:
224+
path: spec.template.spec.automountServiceAccountToken
225+
value: false

charts/ingress-nginx/tests/default-backend-deployment_test.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,3 +187,12 @@ tests:
187187
- equal:
188188
path: spec.template.spec.containers[0].image
189189
value: registry.k8s.io/defaultbackend-amd64:custom-tag@sha256:faa2d18687f734994b6bd9e309e7a73852a81c30e1b8f63165fcd4f0a087e3cd
190+
191+
- it: should create a Deployment with token auto-mounting disabled if `defaultBackend.serviceAccount.automountServiceAccountToken` is false
192+
set:
193+
defaultBackend.enabled: true
194+
defaultBackend.serviceAccount.automountServiceAccountToken: false
195+
asserts:
196+
- equal:
197+
path: spec.template.spec.automountServiceAccountToken
198+
value: false

0 commit comments

Comments
 (0)