mirror of https://github.com/kubernetes/kops.git
Merge pull request #9491 from johngmyers/nodeport-dns
Default ClusterDNS appropriately when NodeLocalDNS is enabled
This commit is contained in:
commit
a97fc42666
|
|
@ -583,7 +583,7 @@ spec:
|
|||
|
||||
## Node local DNS cache
|
||||
|
||||
As of kops 1.18, you can enable NodeLocal DNSCache if you are using CoreDNS. It is used to improve improve the Cluster DNS performance by running a dns caching agent on cluster nodes as a DaemonSet.
|
||||
As of kops 1.18, you can enable NodeLocal DNSCache if you are using CoreDNS. It is used to improve the Cluster DNS performance by running a dns caching agent on cluster nodes as a DaemonSet.
|
||||
|
||||
```yaml
|
||||
spec:
|
||||
|
|
@ -593,16 +593,6 @@ spec:
|
|||
enabled: true
|
||||
```
|
||||
|
||||
If you are using kube-proxy in ipvs mode or Cilium as CNI, you have to set the nodeLocalDNS as ClusterDNS.
|
||||
|
||||
```yaml
|
||||
spec:
|
||||
kubelet:
|
||||
clusterDNS: 169.254.20.10
|
||||
masterKubelet:
|
||||
clusterDNS: 169.254.20.10
|
||||
```
|
||||
|
||||
## kubeControllerManager
|
||||
This block contains configurations for the `controller-manager`.
|
||||
|
||||
|
|
|
|||
|
|
@ -1096,11 +1096,11 @@ func validateNodeLocalDNS(spec *kops.ClusterSpec, fldpath *field.Path) field.Err
|
|||
}
|
||||
|
||||
if (spec.KubeProxy != nil && spec.KubeProxy.ProxyMode == "ipvs") || (spec.Networking != nil && spec.Networking.Cilium != nil) {
|
||||
if spec.Kubelet != nil && spec.Kubelet.ClusterDNS != spec.KubeDNS.NodeLocalDNS.LocalIP {
|
||||
if spec.Kubelet != nil && spec.Kubelet.ClusterDNS != "" && spec.Kubelet.ClusterDNS != spec.KubeDNS.NodeLocalDNS.LocalIP {
|
||||
allErrs = append(allErrs, field.Forbidden(fldpath.Child("kubelet", "clusterDNS"), "Kubelet ClusterDNS must be set to the default IP address for LocalIP"))
|
||||
}
|
||||
|
||||
if spec.MasterKubelet != nil && spec.MasterKubelet.ClusterDNS != spec.KubeDNS.NodeLocalDNS.LocalIP {
|
||||
if spec.MasterKubelet != nil && spec.MasterKubelet.ClusterDNS != "" && spec.MasterKubelet.ClusterDNS != spec.KubeDNS.NodeLocalDNS.LocalIP {
|
||||
allErrs = append(allErrs, field.Forbidden(fldpath.Child("kubelet", "clusterDNS"), "MasterKubelet ClusterDNS must be set to the default IP address for LocalIP"))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,11 +82,16 @@ func (b *KubeletOptionsBuilder) BuildOptions(o interface{}) error {
|
|||
}
|
||||
|
||||
if clusterSpec.Kubelet.ClusterDNS == "" {
|
||||
ip, err := WellKnownServiceIP(clusterSpec, 10)
|
||||
if err != nil {
|
||||
return err
|
||||
if clusterSpec.KubeDNS != nil && clusterSpec.KubeDNS.NodeLocalDNS != nil && fi.BoolValue(clusterSpec.KubeDNS.NodeLocalDNS.Enabled) &&
|
||||
((clusterSpec.KubeProxy != nil && clusterSpec.KubeProxy.ProxyMode == "ipvs") || (clusterSpec.Networking != nil && clusterSpec.Networking.Cilium != nil)) {
|
||||
clusterSpec.Kubelet.ClusterDNS = clusterSpec.KubeDNS.NodeLocalDNS.LocalIP
|
||||
} else {
|
||||
ip, err := WellKnownServiceIP(clusterSpec, 10)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
clusterSpec.Kubelet.ClusterDNS = ip.String()
|
||||
}
|
||||
clusterSpec.Kubelet.ClusterDNS = ip.String()
|
||||
}
|
||||
|
||||
clusterSpec.MasterKubelet.RegisterSchedulable = fi.Bool(false)
|
||||
|
|
|
|||
Loading…
Reference in New Issue