k8s hostNetwork涉及到dns问题

  • A+
所属分类:k8s

问题说明

如果在k8s部署相关微服务应用时,如果将hostNetwork: true

会出现Nameserver limits were exceeded, some nameservers have been omitted, the applied nameserver line is: 223.5.5.5 223.6.6.6

显然不影响使用,pod默认使用所在宿主主机使用的DNS,这样也会导致容器内不能通过service name 访问k8s集群中其他POD

请在yaml文件写入:

  1. dnsPolicy: ClusterFirstWithHostNet

验证pod使用了coredns

  1. kubectl exec pod_name -n namespace cat /etc/resolv.conf

更多参考:https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/

avatar

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: