Token Projection — mount short-lived service account tokens.
1apiVersion: v12kind: Pod3metadata:4 name: my-pod5spec:6 serviceAccountName: myapp-sa7 containers:8 - name: app9 image: myapp:latest10 volumeMounts:11 - name: token12 mountPath: /var/run/secrets/tokens13 readOnly: true14 volumes:15 - name: token16 projected:17 sources:18 - serviceAccountToken:19 path: vault-token20 expirationSeconds: 360021 audience: https://vault.example.com22 - serviceAccountToken:23 path: k8s-api-token24 expirationSeconds: 8640025 audience: https://kubernetes.default.svc26 - configMap:27 name: ca-cert28 items:29 - key: ca.crt30 path: ca.crt31 - secret:32 name: my-secret33 items:34 - key: db-password35 path: db-password
1# Commands2kubectl get pod my-pod -o jsonpath='{.spec.volumes}' | jq34# Check projected token5kubectl exec my-pod -- cat /var/run/secrets/tokens/vault-token6kubectl exec my-pod -- cat /var/run/secrets/tokens/k8s-api-token78# Decode token9kubectl exec my-pod -- cat /var/run/secrets/tokens/vault-token | cut -d. -f2 | base64 -d1011# Check token expiration12kubectl exec my-pod -- cat /var/run/secrets/tokens/vault-token | cut -d. -f2 | base64 -d | jq .exp1314# Verify token audience15kubectl exec my-pod -- cat /var/run/secrets/tokens/vault-token | cut -d. -f2 | base64 -d | jq .aud
Benefits: