From 079158fa080a8197a8b0e628b38a2a4f1eda380f Mon Sep 17 00:00:00 2001 From: Pengfei Ni Date: Mon, 20 Mar 2017 14:32:46 +0800 Subject: [PATCH] CRI: add support for dns cluster first policy PR #29378 introduces ClusterFirstWithHostNet policy but only dockertools was updated to support the feature. This PR updates kuberuntime to support it for all runtimes. Also fixes #43352. --- .../kuberuntime/kuberuntime_sandbox.go | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/pkg/kubelet/kuberuntime/kuberuntime_sandbox.go b/pkg/kubelet/kuberuntime/kuberuntime_sandbox.go index 9089d5f9b15..b88be53ad1d 100644 --- a/pkg/kubelet/kuberuntime/kuberuntime_sandbox.go +++ b/pkg/kubelet/kuberuntime/kuberuntime_sandbox.go @@ -74,16 +74,19 @@ func (m *kubeGenericRuntimeManager) generatePodSandboxConfig(pod *v1.Pod, attemp Annotations: newPodAnnotations(pod), } + dnsServers, dnsSearches, useClusterFirstPolicy, err := m.runtimeHelper.GetClusterDNS(pod) + if err != nil { + return nil, err + } + podSandboxConfig.DnsConfig = &runtimeapi.DNSConfig{ + Servers: dnsServers, + Searches: dnsSearches, + } + if useClusterFirstPolicy { + podSandboxConfig.DnsConfig.Options = defaultDNSOptions + } + if !kubecontainer.IsHostNetworkPod(pod) { - dnsServers, dnsSearches, _, err := m.runtimeHelper.GetClusterDNS(pod) - if err != nil { - return nil, err - } - podSandboxConfig.DnsConfig = &runtimeapi.DNSConfig{ - Servers: dnsServers, - Searches: dnsSearches, - Options: defaultDNSOptions, - } // TODO: Add domain support in new runtime interface hostname, _, err := m.runtimeHelper.GeneratePodHostNameAndDomain(pod) if err != nil {