Skip to content

Commit 55aa5cc

Browse files
authored
teleport-cluster: set automountServiceAccountToken to false on ServiceAccounts when using newer Kubernetes distributions (#47701)
1 parent 2c5f0c0 commit 55aa5cc

File tree

4 files changed

+52
-0
lines changed

4 files changed

+52
-0
lines changed

examples/chart/teleport-cluster/templates/auth/serviceaccount.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{{- $auth := mustMergeOverwrite (mustDeepCopy .Values) .Values.auth -}}
2+
{{- $projectedServiceAccountToken := semverCompare ">=1.20.0-0" .Capabilities.KubeVersion.Version }}
23
{{- if $auth.serviceAccount.create -}}
34
apiVersion: v1
45
kind: ServiceAccount
@@ -19,4 +20,7 @@ metadata:
1920
azure.workload.identity/client-id: "{{ $auth.azure.clientID }}"
2021
{{- end }}
2122
{{- end -}}
23+
{{- if $projectedServiceAccountToken }}
24+
automountServiceAccountToken: false
25+
{{- end }}
2226
{{- end }}

examples/chart/teleport-cluster/templates/proxy/serviceaccount.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{{- $proxy := mustMergeOverwrite (mustDeepCopy .Values) .Values.proxy -}}
2+
{{- $projectedServiceAccountToken := semverCompare ">=1.20.0-0" .Capabilities.KubeVersion.Version }}
23
{{- if $proxy.serviceAccount.create -}}
34
apiVersion: v1
45
kind: ServiceAccount
@@ -13,4 +14,7 @@ metadata:
1314
{{- if $proxy.annotations.serviceAccount }}
1415
annotations: {{- toYaml $proxy.annotations.serviceAccount | nindent 4 }}
1516
{{- end -}}
17+
{{- if $projectedServiceAccountToken }}
18+
automountServiceAccountToken: false
19+
{{- end }}
1620
{{- end }}

examples/chart/teleport-cluster/tests/auth_serviceaccount_test.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,25 @@ tests:
5050
- equal:
5151
path: metadata.labels.baz
5252
value: overridden
53+
54+
- it: does not set automountServiceAccountToken if cluster version is <1.20
55+
set:
56+
clusterName: helm-lint
57+
capabilities:
58+
majorVersion: 1
59+
minorVersion: 18
60+
asserts:
61+
- notEqual:
62+
path: automountServiceAccountToken
63+
value: false
64+
65+
- it: sets automountServiceAccountToken to false if cluster version is >=1.20
66+
set:
67+
clusterName: helm-lint
68+
capabilities:
69+
majorVersion: 1
70+
minorVersion: 20
71+
asserts:
72+
- equal:
73+
path: automountServiceAccountToken
74+
value: false

examples/chart/teleport-cluster/tests/proxy_serviceaccount_test.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,25 @@ tests:
4040
- equal:
4141
path: metadata.labels.baz
4242
value: overridden
43+
44+
- it: does not set automountServiceAccountToken if cluster version is <1.20
45+
set:
46+
clusterName: helm-lint
47+
capabilities:
48+
majorVersion: 1
49+
minorVersion: 18
50+
asserts:
51+
- notEqual:
52+
path: automountServiceAccountToken
53+
value: false
54+
55+
- it: sets automountServiceAccountToken to false if cluster version is >=1.20
56+
set:
57+
clusterName: helm-lint
58+
capabilities:
59+
majorVersion: 1
60+
minorVersion: 20
61+
asserts:
62+
- equal:
63+
path: automountServiceAccountToken
64+
value: false

0 commit comments

Comments
 (0)