1

Can Kubernetes pod that uses the host network send requests directly to a Service resource by using the service name and service port (incl. utilization of CoreDNS)? Or do I have to expose the service via nodePort on the host network?

Richard
  • 25
  • 1
  • 5

1 Answers1

2

If you want a pod to send requests directly to service resource you have to change pod's dnsPolicy to ClusterFirstWithHostNet. It should be used explicitly for pods running with hostNetwork: true. This way it will use cluster DNS and will be in host network.

You can check it in /etc/resolv.conf file. When you are using dnsPolicy: ClusterFirst this file is inherited by pod and uses host's DNS resolver. When you set dnsPolicy: ClusterFirstWithHostNet it will change DNS resolver to cluster's DNS.

Community
  • 1
  • 1
kool
  • 3,214
  • 1
  • 10
  • 26