Interview Prep/DevSecOps/Kubernetes Security

How do you check what a user or service account is allowed to do?

BeginnerConceptKubernetes Security
Answer

Use kubectl auth can-i with impersonation. It asks the API server's authoriser directly, so it reflects RBAC exactly as enforced.

kubectl auth can-i create deployments -n payments --as [email protected]
kubectl auth can-i --list -n payments --as system:serviceaccount:payments:api
kubectl auth can-i get secrets -A --as system:serviceaccount:ci:deployer

For a cluster-wide review, tools like rbac-tool or kubectl-who-can show who can perform a given verb on a given resource.

All DevSecOps questions Roadmap: Supply chain, secrets & identity

More on Kubernetes Security