@@ -41,9 +41,9 @@ func CreateMultinodeCluster(stockContainerd string, rawHaReplicaCount string) er
4141 return err
4242 }
4343
44- if err := CreateMasterKubeletService (); err != nil {
44+ /* if err := CreateMasterKubeletService(); err != nil {
4545 return err
46- }
46+ }*/
4747
4848 if err := DeployKubernetes (haReplicaCount ); err != nil {
4949 return err
@@ -103,16 +103,11 @@ EOF'`
103103// Deploy Kubernetes
104104func DeployKubernetes (haReplicaCount int ) error {
105105 utils .WaitPrintf ("Deploying Kubernetes(version %s)" , configs .Kube .K8sVersion )
106- masterNodeIp , iperr := utils .ExecShellCmd (`ip route | awk '{print $(NF)}' | awk '/^10\..*/'` )
107- if iperr != nil {
108- return iperr
109- }
110106
111107 command := fmt .Sprintf (`sudo kubeadm init --v=%d \
112- --apiserver-advertise-address=%s \
113108--cri-socket /run/containerd/containerd.sock \
114109--kubernetes-version %s \
115- --pod-network-cidr="%s" ` , configs .System .LogVerbosity , masterNodeIp , configs .Kube .K8sVersion , configs .Kube .PodNetworkCidr )
110+ --pod-network-cidr="%s" ` , configs .System .LogVerbosity , configs .Kube .K8sVersion , configs .Kube .PodNetworkCidr )
116111
117112 if haReplicaCount > 0 {
118113 command += fmt .Sprintf (`\
@@ -198,17 +193,29 @@ func ExtractMasterNodeInfo() error {
198193 configs .Kube .ApiserverAdvertiseAddress ,
199194 configs .Kube .ApiserverPort ,
200195 configs .Kube .ApiserverToken ,
201- configs .Kube .ApiserverDiscoveryToken )
196+ configs .Kube .ApiserverDiscoveryToken ,
197+ configs .Kube .ApiserverCertificateKey )
202198 _ , err = masterKeyYamlFile .WriteString (masterKeyYaml )
203199 if ! utils .CheckErrorWithTagAndMsg (err , "Failed to create masterKey.yaml with master node information!\n " ) {
204200 return err
205201 }
206202
207- utils .SuccessPrintf ("Join cluster from worker nodes as a new control plane node with command: sudo kubeadm join %s:%s --token %s --discovery-token-ca-cert-hash %s --control-plane --certificate-key %s\n " ,
208- configs .Kube .ApiserverAdvertiseAddress , configs .Kube .ApiserverPort , configs .Kube .ApiserverToken , configs .Kube .ApiserverDiscoveryToken , configs .Kube .ApiserverCertificateKey )
203+ utils .SuccessPrintf ("Join cluster from worker nodes as a new control plane node with command: " +
204+ "sudo kubeadm join %s:%s --token %s --discovery-token-ca-cert-hash %s --control-plane --certificate-key %s\n " ,
205+ configs .Kube .ApiserverAdvertiseAddress ,
206+ configs .Kube .ApiserverPort ,
207+ configs .Kube .ApiserverToken ,
208+ configs .Kube .ApiserverDiscoveryToken ,
209+ configs .Kube .ApiserverCertificateKey ,
210+ )
209211
210- utils .SuccessPrintf ("Join cluster from worker nodes with command: sudo kubeadm join %s:%s --token %s --discovery-token-ca-cert-hash %s\n " ,
211- configs .Kube .ApiserverAdvertiseAddress , configs .Kube .ApiserverPort , configs .Kube .ApiserverToken , configs .Kube .ApiserverDiscoveryToken )
212+ utils .SuccessPrintf ("Join cluster from worker nodes with command: " +
213+ "sudo kubeadm join %s:%s --token %s --discovery-token-ca-cert-hash %s\n " ,
214+ configs .Kube .ApiserverAdvertiseAddress ,
215+ configs .Kube .ApiserverPort ,
216+ configs .Kube .ApiserverToken ,
217+ configs .Kube .ApiserverDiscoveryToken ,
218+ )
212219
213220 return nil
214221}
0 commit comments