Skip to content

Commit

Permalink
feat: add nodeEtcHosts property
Browse files Browse the repository at this point in the history
  • Loading branch information
will4j committed Jun 18, 2024
1 parent 6257e71 commit c3c241d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/kk/apis/kubekey/v1alpha2/dns_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1alpha2

type DNS struct {
DNSEtcHosts string `yaml:"dnsEtcHosts" json:"dnsEtcHosts"`
NodeEtcHosts string `yaml:"nodeEtcHosts" json:"nodeEtcHosts,omitempty"`
CoreDNS CoreDNS `yaml:"coredns" json:"coredns"`
NodeLocalDNS NodeLocalDNS `yaml:"nodelocaldns" json:"nodelocaldns"`
}
Expand Down
12 changes: 12 additions & 0 deletions cmd/kk/pkg/bootstrap/os/templates/init_script.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package templates

import (
"fmt"
"strings"
"text/template"

"github.com/kubesphere/kubekey/v3/cmd/kk/pkg/bootstrap/registry"
Expand Down Expand Up @@ -272,6 +273,17 @@ func GenerateHosts(runtime connector.ModuleRuntime, kubeConf *common.KubeConf) [

}

nodeEtcHosts := kubeConf.Cluster.DNS.NodeEtcHosts
if len(nodeEtcHosts) > 0 {
lines := strings.Split(strings.TrimSpace(nodeEtcHosts), "\n")
for i := range lines {
line := strings.TrimSpace(lines[i])
if line != "" {
hostsList = append(hostsList, line)
}
}
}

hostsList = append(hostsList, lbHost)
return hostsList
}

0 comments on commit c3c241d

Please sign in to comment.