Interview Prep/DevSecOps/Kubernetes Security

A team mounts `hostPath: /` into a logging agent. How do you evaluate and constrain this?

IntermediateScenarioKubernetes Security
Answer

Situation read → Mounting / gives the pod full node access, including kubelet credentials and other pods' data.

What I'd do →

  1. Ask what it really needs; log agents usually need only /var/log and /var/lib/docker/containers or /var/log/pods.
  2. Narrow the mounts and set readOnly: true.
  3. Run it in a dedicated namespace labelled for an exception, not in app namespaces.
  4. Enforce with Kyverno or Gatekeeper: deny hostPath except allowlisted paths in allowlisted namespaces.

Why → Platform agents sometimes need host access, but each one should get only the paths it uses.

Interview tip → Treat every DaemonSet with host mounts as part of the node's trusted base.

All DevSecOps questions Roadmap: Supply chain, secrets & identity

More on Kubernetes Security