bring back explicit hostnames in clusters
* bring back explicit hostnames in clusters
"kubeadm join" ignores hostnames in the init config and even if we wrote the kubeadm-flags.env with the explicit kubeadm alpha phase, the join command would override it again and get rid of it.
* fix formatting
@@ -14,6 +14,7 @@ func joinControlplaneNode(ctx *util.Context) error {
func joinControlplaneNodeInternal(ctx *util.Context, node *config.HostConfig, conn ssh.Connection) error {
_, _, err := ctx.Runner.Run(`
if [[ -f /etc/kubernetes/kubelet.conf ]]; then exit 0; fi
+
if [[ -f /etc/systemd/system/kubelet.service.d/10-kubeadm.conf.disabled ]]; then
sudo mv /etc/systemd/system/kubelet.service.d/10-kubeadm.conf{.disabled,}
sudo systemctl daemon-reload
@@ -22,10 +23,12 @@ fi
sudo systemctl stop kubelet
sudo {{ .JOIN_COMMAND }} \
--experimental-control-plane \
+ --node-name="{{ .NODE_NAME }}" \
--ignore-preflight-errors=DirAvailable--etc-kubernetes-manifests
`, util.TemplateVariables{
"WORK_DIR": ctx.WorkDir,
"JOIN_COMMAND": ctx.JoinCommand,
+ "NODE_NAME": node.Hostname,
})
return err
}
