I have a service account token secret:
Version: v1
kind: Secret
type: kubernetes.io/service-account-token
metadata:
labels:
app: {{ .Release.Name }}-{{ .Values.appName }}-secret
name: {{ .Release.Name }}-api-secret
annonations:
kubernetes.io/service-account.name: ...
Once applied, a token will be generated and available under data.token
.
How can I use data.token
in another helm generated yaml?
When you have the name (i.e. {{ .Release.Name }}-api-secret
) of the secret, you can refer it from other k8s objects. Most of the time, these are local (same namespace) object references.
env
env:
- name: TOKEN
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-api-secret
key: token
volumes:
- name: secret-volume
secret:
secretName: {{ .Release.Name }}-api-secret
containers:
- name: test-container
image: demoImage
volumeMounts:
- name: secret-volume
readOnly: true
mountPath: "/etc/credentials"