Using the host network namespace for publishing applications
So far, we have seen different methods for accessing ClusterIP Service resources or Pods (created using different workload types) by either proxying or forwarding their ports to our desktop computers. Sometimes, however, the applications require a direct connection to the host’s interfaces, without the bridge interface created by the container runtime. In this case, the containers in the Pod will use the network namespace of the host, which allows the processes inside to control the host because they will have access to all the host’s interfaces and network traffic. This can be dangerous and must only be used to manage and monitor the host’s interfaces.
Using the hostNetwork key
To use the host’s network namespace, we set the hostNetwork
key to true
. The Pod will now get all the IP addresses associated with the host, including those of all the virtual interfaces associated with the containers...