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 →
- Ask what it really needs; log agents usually need only
/var/logand/var/lib/docker/containersor/var/log/pods. - Narrow the mounts and set
readOnly: true. - Run it in a dedicated namespace labelled for an exception, not in app namespaces.
- Enforce with Kyverno or Gatekeeper: deny
hostPathexcept 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.
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