A team has `edit` rights in their namespace. Can they read Secrets, and how do you limit that?
IntermediateProductionKubernetes Security Posture
Answer
Yes. The built-in edit role includes reading Secrets, and anyone who can create pods can mount any Secret in that namespace anyway. So "edit but cannot see secrets" is not achievable with RBAC alone.
What we do:
- Use a custom developer role without
secretsverbs for humans in production; deployments happen through GitOps service accounts. - Keep real secrets in an external manager and mount them via the Secrets Store CSI driver, with access tied to the workload's service account identity.
- Separate highly sensitive workloads into their own namespaces with tighter bindings.
- Audit
get secretsevents on production namespaces.
More on Kubernetes Security Posture
What is your security baseline for a new production EKS cluster?IntermediateDraw the layered security controls for workloads on Kubernetes.BeginnerHow do you assign Pod Security Admission levels across namespaces in production?BeginnerKyverno, OPA Gatekeeper or ValidatingAdmissionPolicy: how do you choose?IntermediateShow a ValidatingAdmissionPolicy that blocks containers without resource limits.AdvancedHow do you roll out default-deny NetworkPolicies in a running production cluster?Intermediate