CertGrid CertGrid
Hands-on Lab·Certified Kubernetes Application Developer

ServiceAccounts, Roles and RoleBindings

Every Pod runs as a ServiceAccount whether you choose one or not, and by default it can do nothing. Granting it one permission takes three objects and three commands, and `kubectl auth can-i --as=` answers whether it worked without deploying anything. This does that, then calls the API from inside the Pod to show the allowed request succeeding and the forbidden one returning 403.

Configuration and Security Guide 29 of 44 Intermediate

Written against the versions above. The token in a Pod is a projected, time-bound token - `expirationSeconds` reads 3607 here, so it is rotated roughly hourly by the kubelet. Kubernetes no longer creates a permanent Secret per ServiceAccount, which is why `kubectl get secrets` in a namespace with ServiceAccounts is usually empty.

Two Pods calling the API server from inside the cluster over the `kubernetes.default.svc` Service.
Server NameIP AddressOSRolesCPURAMHDD
CKA1001192.168.0.175Ubuntu 26.04 LTSControl Plane Node2 Core4 GB50 GB
CKA1001-NODE01192.168.0.176Ubuntu 26.04 LTSWorker Node2 Core4 GB50 GB
CKA1001-NODE02192.168.0.177Ubuntu 26.04 LTSWorker Node2 Core4 GB50 GB
CKA1001-NODE03192.168.0.178Ubuntu 26.04 LTSWorker Node2 Core4 GB50 GB

Before you start

  1. A ServiceAccount, and what it cannot do

  2. One Role, one RoleBinding

  3. Proving it from inside a Pod

  4. Turning the token off

Official sources