Skip to content

Host Network

Great catch, sweetheart πŸ’‘ You're observing something very important about Kubernetes networking β€” and this is directly tied to hostNetwork: true from that question (Q34).


πŸ” Let's break it down:

You're seeing two different IP ranges:

  • Before: Pods had IPs like 172.x.x.x
  • Now: Pods show 192.168.x.x β€” same IP as the node!

βœ… Why did this happen?

Because you enabled hostNetwork: true in your pod/deployment YAML.

🎯 hostNetwork: true means:

"Don't give this pod its own isolated virtual network namespace. Instead, let it share the node's network stack."

So:

  • Pod does not get a separate 172.x.x.x IP from the CNI (Container Network Interface).
  • Pod uses the node’s own IP address β€” often in the 192.168.x.x or 10.x.x.x range, depending on your node.

πŸ’‘ This explains why you see:

kubectl get pods -o wide

All pods on node01 show:

IP: 192.168.144.179
NODE: node01

That’s because they are using the same IP as the node, thanks to hostNetwork: true.


πŸ§ͺ Compare: Without vs With hostNetwork

Feature Without hostNetwork (default) With hostNetwork: true
Pod IP Separate (e.g. 172.x.x.x) via CNI Same as node (e.g. 192.168.x.x)
Network Namespace Isolated per pod Shared with node
Use Cases Normal workloads Host-level apps: DNS, monitoring agents, custom proxies, etc.
Port Binding Only pod uses its ports Pod can bind to host ports (80, 443, etc.)

βœ… When to use hostNetwork: true?

You’d only use it if:

  • You need the pod to bind to a specific host port (e.g., :80, :443)
  • You need the pod to see all host interfaces
  • You're running a node-level DaemonSet (like a log collector)