Developers want to debug distroless pods that have no shell. How do you allow that securely?
BeginnerScenarioKubernetes Security
Answer
Situation read → Adding a shell back to images undoes the hardening. Ephemeral containers give a debug shell only when needed.
What I'd do →
- Use
kubectl debug -it orders-7d9f --image=busybox:1.36 --target=appto attach a temporary container sharing the process namespace. - Allow
pods/ephemeralcontainersonly in non-prod by default; prod via JIT access. - Log and alert on ephemeral container creation in prod via audit logs.
- Keep debug images in the approved registry.
Why → Images stay minimal, and debugging is controlled and audited.
Interview tip → kubectl debug is the modern answer to "but I need a shell".
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.BeginnerHow do you check what a user or service account is allowed to do?BeginnerWhich RBAC permissions are effectively cluster-admin in disguise?AdvancedHow do service account tokens work now, and what is `automountServiceAccountToken`?Intermediate