You find that `kubectl exec` is used in production by many people. How do you control it?
AdvancedScenarioSecurity, RBAC and policy
Answer
Situation read → Auditors flagged uncontrolled shell access to production pods.
What I'd do →
- Restrict
pods/execandpods/attachin RBAC - Offer break-glass roles with approval and time limit
- Enable audit policy at RequestResponse level for exec
- Use ephemeral debug containers (
kubectl debug) under controlled roles - Alert on exec events in prod namespaces
Why → Exec bypasses application controls and leaves little trace without audit logs.
Interview tip → Say exec in prod should be exceptional and logged.
More on Security, RBAC and policy
A developer needs read-only access to one namespace. How do you grant it?BeginnerExplain the difference between Role, ClusterRole, RoleBinding and ClusterRoleBinding.IntermediateA CI pipeline needs to deploy to one namespace. What identity do you give it?IntermediateWhat does a ServiceAccount do and why should you disable the token automount?BeginnerHow do you let pods on EKS access S3 without static keys?IntermediateA pod has access to the node's IAM role through IMDS. How do you prevent credential theft?Advanced