Skip to content

Commit

Permalink
Fix hostname-override kubelet parameter passing (#313)
Browse files Browse the repository at this point in the history
Node may not have privateAddress in k0sctl.yaml but hostname field
specified. These fields should be processed independently here.
  • Loading branch information
abubyr committed Feb 1, 2022
1 parent 4069658 commit d5f7d66
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pkg/apis/k0sctl.k0sproject.io/v1beta1/cluster/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,17 +241,21 @@ func (h *Host) K0sInstallCommand() string {
flags.AddUnlessExist(fmt.Sprintf(`--config "%s"`, h.K0sConfigPath()))
}

if strings.HasSuffix(h.Role, "worker") && h.PrivateAddress != "" {
// set worker's private address to --node-ip in --extra-kubelet-args
if strings.HasSuffix(h.Role, "worker") {
var extra Flags
if old := flags.GetValue("--kubelet-extra-args"); old != "" {
extra = Flags{unQE(old)}
}
extra.AddUnlessExist(fmt.Sprintf("--node-ip=%s", h.PrivateAddress))
// set worker's private address to --node-ip in --extra-kubelet-args
if h.PrivateAddress != "" {
extra.AddUnlessExist(fmt.Sprintf("--node-ip=%s", h.PrivateAddress))
}
if h.HostnameOverride != "" {
extra.AddOrReplace(fmt.Sprintf("--hostname-override=%s", h.HostnameOverride))
}
flags.AddOrReplace(fmt.Sprintf("--kubelet-extra-args=%s", strconv.Quote(extra.Join())))
if extra != nil {
flags.AddOrReplace(fmt.Sprintf("--kubelet-extra-args=%s", strconv.Quote(extra.Join())))
}
}

cmd := h.Configurer.K0sCmdf("install %s %s", role, flags.Join())
Expand Down

0 comments on commit d5f7d66

Please sign in to comment.