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.
More on Kubernetes Security
What are the 4Cs of cloud native security?BeginnerWhat happens to a request between `kubectl apply` and etcd from a security point of view?IntermediateExplain Role, ClusterRole, RoleBinding and ClusterRoleBinding.BeginnerHow do you check what a user or service account is allowed to do?BeginnerWhich RBAC permissions are effectively cluster-admin in disguise?AdvancedWhat are the three Pod Security Standards?Beginner