Skip to content

Commit

Permalink
fix(security): πŸ› πŸ”’οΈ mount service account token on pod level
Browse files Browse the repository at this point in the history
  • Loading branch information
mloiseleur committed Jun 6, 2024
1 parent f8f2da2 commit db4f43f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
1 change: 1 addition & 0 deletions traefik/templates/_podtemplate.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "traefik.serviceAccountName" . }}
automountServiceAccountToken: true
terminationGracePeriodSeconds: {{ default 60 .Values.deployment.terminationGracePeriodSeconds }}
hostNetwork: {{ .Values.hostNetwork }}
{{- with .Values.deployment.dnsPolicy }}
Expand Down
1 change: 1 addition & 0 deletions traefik/templates/rbac/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ metadata:
{{- with .Values.serviceAccountAnnotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
automountServiceAccountToken: false
{{- end -}}
33 changes: 16 additions & 17 deletions traefik/tests/deployment-config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,26 @@ suite: Deployment configuration
templates:
- deployment.yaml
tests:
- it: should have 1 replica by default
- it: should provide expected defaults
asserts:
- equal:
path: spec.replicas
value: 1
- equal:
path: spec.template.spec.automountServiceAccountToken
value: true
- equal:
path: spec.strategy.type
value: RollingUpdate
- equal:
path: spec.strategy.rollingUpdate.maxUnavailable
value: 0
- equal:
path: spec.strategy.rollingUpdate.maxSurge
value: 1
- equal:
path: metadata.namespace
value: NAMESPACE
- it: should have the specified amount of replicas when specified via values
set:
deployment:
Expand All @@ -23,17 +38,6 @@ tests:
- equal:
path: spec.revisionHistoryLimit
value: 1
- it: should have a rollingUpdate strategy with default values
asserts:
- equal:
path: spec.strategy.type
value: RollingUpdate
- equal:
path: spec.strategy.rollingUpdate.maxUnavailable
value: 0
- equal:
path: spec.strategy.rollingUpdate.maxSurge
value: 1
- it: should have a custom merged rollingUpdate strategy with specified values
set:
updateStrategy:
Expand Down Expand Up @@ -160,11 +164,6 @@ tests:
- equal:
path: spec.strategy.type
value: OnDelete
- it: should use helm managed namespace as default behavior
asserts:
- equal:
path: metadata.namespace
value: NAMESPACE
- it: should accept overridden namespace
set:
namespaceOverride: "traefik-ns-override"
Expand Down
4 changes: 4 additions & 0 deletions traefik/tests/rbac-config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ tests:
path: metadata.name
value: RELEASE-NAME-traefik
template: rbac/serviceaccount.yaml
- equal:
path: automountServiceAccountToken
value: false
template: rbac/serviceaccount.yaml
- equal:
path: spec.template.spec.serviceAccountName
value: RELEASE-NAME-traefik
Expand Down

0 comments on commit db4f43f

Please sign in to comment.