Skip to content

Commit

Permalink
Merge pull request #3098 from howardjohn/dns/dns-search
Browse files Browse the repository at this point in the history
Add `dnsSearch` cluster option
  • Loading branch information
k8s-ci-robot committed Feb 22, 2023
2 parents 9dc982c + 1964100 commit 6b58c9d
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 1 deletion.
15 changes: 14 additions & 1 deletion images/base/files/usr/local/bin/entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,20 @@ enable_network_magic(){

# now we can ensure that DNS is configured to use our IP
cp /etc/resolv.conf /etc/resolv.conf.original
sed -e "s/${docker_embedded_dns_ip}/${docker_host_ip}/g" /etc/resolv.conf.original >/etc/resolv.conf
replaced="$(sed -e "s/${docker_embedded_dns_ip}/${docker_host_ip}/g" /etc/resolv.conf.original)"
if [[ "${KIND_DNS_SEARCH+x}" == "" ]]; then
# No DNS search set, just pass through as is
echo "$replaced" >/etc/resolv.conf
elif [[ -z "$KIND_DNS_SEARCH" ]]; then
# Empty search - remove all current search clauses
echo "$replaced" | grep -v "^search" >/etc/resolv.conf
else
# Search set - remove all current search clauses, and add the configured search
{
echo "search $KIND_DNS_SEARCH";
echo "$replaced" | grep -v "^search";
} >/etc/resolv.conf
fi

local files_to_update=(
/etc/kubernetes/manifests/etcd.yaml
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/config/v1alpha4/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions pkg/cluster/internal/providers/docker/provision.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ func commonArgs(cluster string, cfg *config.Cluster, networkName string, nodeNam
if mountFuse() {
args = append(args, "--device", "/dev/fuse")
}

if cfg.Networking.DNSSearch != nil {
args = append(args, "-e", "KIND_DNS_SEARCH="+strings.Join(*cfg.Networking.DNSSearch, " "))
}

return args, nil
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/cluster/internal/providers/podman/provision.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ func commonArgs(cfg *config.Cluster, networkName string, nodeNames []string) ([]
args = append(args, "--device", "/dev/fuse")
}

if cfg.Networking.DNSSearch != nil {
args = append(args, "-e", "KIND_DNS_SEARCH="+strings.Join(*cfg.Networking.DNSSearch, " "))
}

return args, nil
}

Expand Down
1 change: 1 addition & 0 deletions pkg/internal/apis/config/convert_v1alpha4.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/internal/apis/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6b58c9d

Please sign in to comment.