Interview Prep/DevSecOps/Kubernetes Security

How do service account tokens work now, and what is `automountServiceAccountToken`?

IntermediateConceptKubernetes Security
Answer

Since Kubernetes 1.24 pods get short-lived, audience-bound tokens through a projected volume (TokenRequest API), rotated by the kubelet and invalidated when the pod is deleted. Long-lived Secret-based tokens are no longer created automatically and legacy unused ones are cleaned up.

Most pods never call the API server, so they should not get a token at all:

apiVersion: v1
kind: ServiceAccount
metadata: { name: web, namespace: shop }
automountServiceAccountToken: false

Create one service account per workload, never use default, and bind only the permissions that workload needs.

All DevSecOps questions Roadmap: Supply chain, secrets & identity

More on Kubernetes Security