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.
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.BeginnerWhich RBAC permissions are effectively cluster-admin in disguise?AdvancedHow do service account tokens work now, and what is `automountServiceAccountToken`?IntermediateWhat are the three Pod Security Standards?Beginner