What does hostNetwork: true do and why is it risky?
IntermediateScenarioKubernetes Networking
Answer
Situation read → The pod shares the node's network namespace.
What I'd do →
- The pod uses the node IP and ports directly, bypassing the pod network
- Used by CNI agents, node exporters and some ingress controllers
- Risks: port conflicts, bypasses NetworkPolicy, can see node traffic
- Check usage with
kubectl get pods -A -o jsonpath='{range .items[?(@.spec.hostNetwork==true)]}{.metadata.name}{"\n"}{end}' - Use admission policy to restrict
Why → It breaks the isolation boundary that namespaces and policies rely on.
Interview tip → Say you allow it only for system components.
More on Kubernetes Networking
Explain the Kubernetes networking model in one minute.BeginnerClusterIP, NodePort and LoadBalancer: when do you use each?BeginnerHow does a pod find another service by name?BeginnerService versus Ingress: what is the difference?BeginnerWhat does a CNI plugin do and which ones do you know?BeginnerHow do you reach a pod from your laptop for debugging without exposing it?Beginner