简体   繁体   中英

Kubernetes - How to set DNS Policy at Cluster Level

I am currently setting the 'dnsPolicy' configuration in the pod spec to 'Default' so that the pod can inherit the node's DNS configuration.

While this is good, it requires a re-build/re-deploy of the Docker container in order for the policy to effect and it is limited at the pod level.

Is there a similar policy that can be applied cluster-wide? Such that deployment of new pods onto the cluster will automatically inherit the nodes DNS configuration because of the cluster-wide policy?

There isn't really a supported way to do this cluster-wide. One reason is that your coredns or kube-dns use dnsPolicy: Default and not the default dnsPolicy: ClusterFirst so changing it cluster-wide might affect your coredns/kube-dns pods.

There is, however a more complicated approach that you can use with Dynamic Admission Controllers . In particular, using a MutatingAdmissionWebhook that you can use to modify the pods with certain annotations to have dnsPolicy: Default . For example, Istio uses this to inject the Envoy sidecar. This is a good document that describes how to build your own MutatingAdmissionWebhook.

Similar question: https://serverfault.com/questions/928257/is-there-a-way-to-change-the-default-dnspolicy-without-modifying-every-podspec

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM