recreate existing control plane node correctly

pull/8095/head
Sharif Elgamal 2020-05-12 12:12:57 -07:00
parent f7febd6abb
commit fc4acc598a
2 changed files with 19 additions and 9 deletions

View File

@ -877,8 +877,11 @@ func validateRegistryMirror() {
}
}
func createNode(cc config.ClusterConfig, kubeNodeName string) (config.ClusterConfig, config.Node, error) {
func createNode(cc config.ClusterConfig, kubeNodeName string, existing *config.ClusterConfig) (config.ClusterConfig, config.Node, error) {
// Create the initial node, which will necessarily be a control plane
var cp config.Node
var err error
if existing == nil {
cp := config.Node{
Port: cc.KubernetesConfig.NodePort,
KubernetesVersion: getKubernetesVersion(&cc),
@ -887,6 +890,13 @@ func createNode(cc config.ClusterConfig, kubeNodeName string) (config.ClusterCon
Worker: true,
}
cc.Nodes = []config.Node{cp}
} else {
cp, err = config.PrimaryControlPlane(existing)
if err != nil {
return cc, config.Node{}, err
}
cc.Nodes = existing.Nodes
}
return cc, cp, nil
}

View File

@ -348,7 +348,7 @@ func generateClusterConfig(cmd *cobra.Command, existing *config.ClusterConfig, k
if driver.BareMetal(cc.Driver) {
kubeNodeName = "m01"
}
return createNode(cc, kubeNodeName)
return createNode(cc, kubeNodeName, existing)
}
// updateExistingConfigFromFlags will update the existing config from the flags - used on a second start