diff --git a/pkg/proxy/iptables/proxier.go b/pkg/proxy/iptables/proxier.go index 50d13c573085d..9bc33ca5a6d72 100644 --- a/pkg/proxy/iptables/proxier.go +++ b/pkg/proxy/iptables/proxier.go @@ -1029,6 +1029,20 @@ func (proxier *Proxier) syncProxyRules() { hasEndpoints = len(allEndpoints) > 0 } + // Prefer local endpoint for the DNS service. + // Fixes . + // TODO: Delete this if-block once internal traffic policy is + // implemented and the DNS operator is updated to use it. + if svcNameString == "openshift-dns/dns-default:dns" { + for _, ep := range allEndpoints { + if ep.GetIsLocal() { + klog.V(4).Infof("Found a local endpoint %q for service %q; preferring the local endpoint and ignoring %d other endpoints", ep.String(), svcNameString, len(allEndpoints) - 1) + allEndpoints = []proxy.Endpoint{ep} + break + } + } + } + svcChain := svcInfo.servicePortChainName if hasEndpoints { // Create the per-service chain, retaining counters if possible.