mirror of https://github.com/k3s-io/k3s
SkyDNS is the only NS for Pods with DNSPolicy=ClusterFirst
parent
46eca25d71
commit
015df14a4a
|
@ -241,7 +241,7 @@ func startComponents(firstManifestURL, secondManifestURL string) (string, string
|
|||
3*time.Second, /* NodeStatusUpdateFrequency */
|
||||
10*time.Second, /* SyncFrequency */
|
||||
40, /* MaxPods */
|
||||
cm)
|
||||
cm, net.ParseIP("127.0.0.1"))
|
||||
|
||||
kubeletapp.RunKubelet(kcfg)
|
||||
// Kubelet (machine)
|
||||
|
@ -274,7 +274,8 @@ func startComponents(firstManifestURL, secondManifestURL string) (string, string
|
|||
10*time.Second, /* SyncFrequency */
|
||||
|
||||
40, /* MaxPods */
|
||||
cm)
|
||||
cm,
|
||||
net.ParseIP("127.0.0.1"))
|
||||
|
||||
kubeletapp.RunKubelet(kcfg)
|
||||
return apiServer.URL, configFilePath
|
||||
|
|
|
@ -703,7 +703,7 @@ func SimpleKubelet(client *client.Client,
|
|||
osInterface kubecontainer.OSInterface,
|
||||
fileCheckFrequency, httpCheckFrequency, minimumGCAge, nodeStatusUpdateFrequency, syncFrequency time.Duration,
|
||||
maxPods int,
|
||||
containerManager cm.ContainerManager) *KubeletConfig {
|
||||
containerManager cm.ContainerManager, clusterDNS net.IP) *KubeletConfig {
|
||||
imageGCPolicy := kubelet.ImageGCPolicy{
|
||||
HighThresholdPercent: 90,
|
||||
LowThresholdPercent: 80,
|
||||
|
@ -718,6 +718,7 @@ func SimpleKubelet(client *client.Client,
|
|||
CAdvisorInterface: cadvisorInterface,
|
||||
CgroupRoot: "",
|
||||
Cloud: cloud,
|
||||
ClusterDNS: clusterDNS,
|
||||
ConfigFile: configFilePath,
|
||||
ContainerManager: containerManager,
|
||||
ContainerRuntime: "docker",
|
||||
|
|
|
@ -1465,7 +1465,7 @@ func (kl *Kubelet) podFieldSelectorRuntimeValue(fs *api.ObjectFieldSelector, pod
|
|||
// domains of the cluster.
|
||||
func (kl *Kubelet) getClusterDNS(pod *api.Pod) ([]string, []string, error) {
|
||||
var hostDNS, hostSearch []string
|
||||
// Get host DNS settings and append them to cluster DNS settings.
|
||||
// Get host DNS settings
|
||||
if kl.resolverConfig != "" {
|
||||
f, err := os.Open(kl.resolverConfig)
|
||||
if err != nil {
|
||||
|
@ -1495,9 +1495,17 @@ func (kl *Kubelet) getClusterDNS(pod *api.Pod) ([]string, []string, error) {
|
|||
var dns, dnsSearch []string
|
||||
|
||||
if kl.clusterDNS != nil {
|
||||
dns = append([]string{kl.clusterDNS.String()}, hostDNS...)
|
||||
// for a pod with DNSClusterFirst policy, the cluster DNS server is the only nameserver configured for
|
||||
// the pod. The cluster DNS server itself will forward queries to other nameservers that is configured to use,
|
||||
// in case the cluster DNS server cannot resolve the DNS query itself
|
||||
dns = []string{kl.clusterDNS.String()}
|
||||
} else {
|
||||
dns = hostDNS
|
||||
// clusterDNS is not known.
|
||||
// pod with ClusterDNSFirst Policy cannot be created
|
||||
kl.recorder.Eventf(pod, api.EventTypeWarning, "MissingClusterDNS", "kubelet does not have ClusterDNS IP configured and cannot create Pod using %q policy", pod.Spec.DNSPolicy)
|
||||
log := fmt.Sprintf("kubelet does not have ClusterDNS IP configured and cannot create Pod using %q policy. pod:%q", pod.Spec.DNSPolicy, kubecontainer.GetPodFullName(pod))
|
||||
kl.recorder.Eventf(kl.nodeRef, api.EventTypeWarning, "MissingClusterDNS", log)
|
||||
return nil, nil, fmt.Errorf(log)
|
||||
}
|
||||
if kl.clusterDomain != "" {
|
||||
nsSvcDomain := fmt.Sprintf("%s.svc.%s", pod.Namespace, kl.clusterDomain)
|
||||
|
|
|
@ -1019,8 +1019,8 @@ func TestDNSConfigurationParams(t *testing.T) {
|
|||
}
|
||||
}
|
||||
t.Logf("nameservers %+v", options[1].DNS)
|
||||
if len(options[0].DNS) != len(options[1].DNS)+1 {
|
||||
t.Errorf("expected prepend of cluster nameserver, got %+v", options[0].DNS)
|
||||
if len(options[0].DNS) != 1 {
|
||||
t.Errorf("expected cluster nameserver only, got %+v", options[0].DNS)
|
||||
} else if options[0].DNS[0] != clusterNS {
|
||||
t.Errorf("expected nameserver %s, got %v", clusterNS, options[0].DNS[0])
|
||||
}
|
||||
|
|
|
@ -72,6 +72,7 @@ func NewHollowKubelet(
|
|||
10*time.Second, /* SyncFrequency */
|
||||
40, /* MaxPods */
|
||||
containerManager,
|
||||
nil,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue