Add dnsSearch cluster option

Fixes https://github.com/kubernetes-sigs/kind/issues/3097
This commit is contained in:
John Howard
2023-02-14 13:45:31 -08:00
parent 281d00dc42
commit 33c4eaf560
5 changed files with 30 additions and 0 deletions

View File

@@ -189,6 +189,8 @@ type Networking struct {
// KubeProxyMode defines if kube-proxy should operate in iptables or ipvs mode
// Defaults to 'iptables' mode
KubeProxyMode ProxyMode `yaml:"kubeProxyMode,omitempty" json:"kubeProxyMode,omitempty"`
// DNSSearch defines the DNS search domain to use for nodes. If not set, this will be inherited from the host.
DNSSearch *[]string `yaml:"dnsSearch,omitempty" json:"dnsSearch,omitempty"`
}
// ClusterIPFamily defines cluster network IP family

View File

@@ -199,6 +199,22 @@ func commonArgs(cluster string, cfg *config.Cluster, networkName string, nodeNam
if mountFuse() {
args = append(args, "--device", "/dev/fuse")
}
if cfg.Networking.DNSSearch != nil {
if len(*cfg.Networking.DNSSearch) == 0 {
return nil, errors.New("docker provider requires a non-empty dnsSearch")
}
for _, s := range *cfg.Networking.DNSSearch {
args = append(args, "--dns-search", s)
}
args = append(args, "--dns", "8.8.8.8")
args = append(args, "--dns", "8.8.4.4")
if config.ClusterHasIPv6(cfg) {
args = append(args, "--dns", "2001:4860:4860::8888")
args = append(args, "--dns", "2001:4860:4860::8844")
}
}
return args, nil
}

View File

@@ -164,6 +164,15 @@ func commonArgs(cfg *config.Cluster, networkName string, nodeNames []string) ([]
args = append(args, "--device", "/dev/fuse")
}
if cfg.Networking.DNSSearch != nil {
if len(*cfg.Networking.DNSSearch) == 0 {
args = append(args, "--dns-search", "")
}
for _, s := range *cfg.Networking.DNSSearch {
args = append(args, "--dns-search", s)
}
}
return args, nil
}

View File

@@ -85,6 +85,7 @@ func convertv1alpha4Networking(in *v1alpha4.Networking, out *Networking) {
out.KubeProxyMode = ProxyMode(in.KubeProxyMode)
out.ServiceSubnet = in.ServiceSubnet
out.DisableDefaultCNI = in.DisableDefaultCNI
out.DNSSearch = in.DNSSearch
}
func convertv1alpha4Mount(in *v1alpha4.Mount, out *Mount) {

View File

@@ -150,6 +150,8 @@ type Networking struct {
DisableDefaultCNI bool
// KubeProxyMode defines if kube-proxy should operate in iptables or ipvs mode
KubeProxyMode ProxyMode
// DNSSearch defines the DNS search domain to use for nodes. If not set, this will be inherited from the host.
DNSSearch *[]string
}
// ClusterIPFamily defines cluster network IP family