How do you stop privileged containers and hostPath mounts cluster-wide?
IntermediateScenarioSecurity, RBAC and policy
Answer
Situation read → A team tried to run a privileged pod in prod.
What I'd do →
- Use Pod Security Admission by labelling namespaces:
kubectl label ns prod pod-security.kubernetes.io/enforce=restricted - Roll out with
warnandauditmodes first - For finer rules use Kyverno or OPA Gatekeeper
- Exempt only system namespaces
- Test with a dry run:
kubectl label --dry-run=server --overwrite ns prod pod-security.kubernetes.io/enforce=baseline
Why → PSA gives three profiles (privileged, baseline, restricted) that replace PodSecurityPolicy.
Interview tip → Know that PSP was removed in 1.25.
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