Skip to content

Commit 3342ad0

Browse files
authored
add support for bearer token read from a file (#1047)
1 parent de772d8 commit 3342ad0

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

helm/charts/surveyor/templates/deployment.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ spec:
7171
- --tlskey=/etc/nats-certs/clients/{{ .key }}
7272
- --tlscert=/etc/nats-certs/clients/{{ .cert }}
7373
{{- end }}
74+
75+
{{- with .tokenFile }}
76+
{{- if .enabled }}
77+
- --token-file={{ .mountPath }}/{{ .filename }}
78+
{{- end }}
79+
{{- end }}
7480
{{- end }}
7581

7682
{{- if .Values.config.jetstream.enabled }}
@@ -129,6 +135,15 @@ spec:
129135
mountPath: /jetstream
130136
{{- end }}
131137
{{- end }}
138+
139+
{{- with .Values.config.tokenFile }}
140+
{{- if .enabled }}
141+
- name: {{ default "nats-token" .volumeName }}
142+
mountPath: {{ .mountPath }}
143+
readOnly: true
144+
{{- end }}
145+
{{- end }}
146+
132147
{{- with .Values.extraVolumeMounts }}
133148
{{- toYaml . | nindent 12}}
134149
{{- end }}
@@ -170,6 +185,23 @@ spec:
170185
name: {{ include "surveyor.fullname" $ }}-accounts
171186
{{- end }}
172187
{{- end }}
188+
189+
{{- with .Values.config.tokenFile }}
190+
{{- if .enabled }}
191+
- name: {{ default "nats-token" .volumeName }}
192+
projected:
193+
sources:
194+
- serviceAccountToken:
195+
path: {{ .filename }}
196+
{{- if .audience }}
197+
audience: {{ .audience }}
198+
{{- end }}
199+
{{- if .expirationSeconds }}
200+
expirationSeconds: {{ .expirationSeconds }}
201+
{{- end }}
202+
{{- end }}
203+
{{- end }}
204+
173205
{{- with .Values.extraVolumes }}
174206
{{- toYaml . | nindent 8 }}
175207
{{- end }}

helm/charts/surveyor/values.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,21 @@ config:
108108
# Enable monitoring account metrics.
109109
accounts: false
110110

111+
# stays as ENV; works with token-file + user
112+
#user: "sys"
113+
114+
# tokenFile:
115+
# enabled: true
116+
# optional: change the volume name
117+
# volumeName: nats-token
118+
# where to mount inside the container
119+
# mountPath: /var/run/secrets/tokens
120+
# filename inside the mount where kubelet writes the token
121+
# filename: nats-token
122+
# optional extras for projected tokens:
123+
# audience: nats-auth
124+
# expirationSeconds: 3600
125+
111126
# Required if NATS auth is enabled
112127
# credentials:
113128
# secret:

0 commit comments

Comments
 (0)