hostNetwork: true
When in doubt you can always use explain
command:
kubectl explain pod.spec.hostNetwork
KIND: Pod
VERSION: v1
FIELD: hostNetwork <boolean>
DESCRIPTION:
Host networking requested for this pod. Use the host's network namespace. If
this option is set, the ports that will be used must be specified. Default
to false.
This namespace is a network namespace, not the Kubernetes namespace. When pods are scheduled on a node (host machine), they get a new network namespace isolated from the host machine. If your pod specifically needs privileged host machine network access then you need this option. Pods running from the Network plugin in your cluster use this setting. Those pods get their podIP
set to the host machine IP
(which means they can use the host machine's eth0
physical interface) it runs on.
dnsPolicy: ClusterFirstWithHostNet
The above setting for the pod means that you need cluster DNS resolution (via CoreDNS) as a normal pod even though you set hostNetwork: true
(pods that are not running in the host network namespace). If you don't set it, Pod will use the host machine's DNS configuration for DNS resolution (where Pod cannot resolve k8s services
and endpoints
).
Check DNS policy section in k8s docs for further details