Can you simply summarize what the following two definitions do and when they should be used?
spec: hostNetwork: true dnsPolicy: ClusterFirstWithHostNet
I do not have enough knowledge about networking in Kubernetest and the articles I found are not understandable to me.
hostNetwork: true
When in doubt you can always use
explaincommand: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
podIPset to the host machineIP(which means they can use the host machine'seth0physical 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 k8sservicesandendpoints).Check DNS policy section in k8s docs for further details