The kubeadm join generated by running kubeadm init on the node service reports an error

Install a kubernetes cluster

Run the command on the master server (ip: 192.168.56.101):

kubeadm init \
--image-repository registry.cn-hangzhou.aliyuncs.com/google_containers \
--pod-network-cidr=10.244.0.0/16

After running, a kubeadm join command will be generated at the bottom

Copy, running these two lines on the node node server (ip: 192.168.56.102) will report an error:


error execution phase preflight: couldn't validate the identity of the API Server:
Get "https://10.0.2.15:6443/api/v1/namespaces/kube-public/configmaps/cluster-info?timeout=10s": dial tcp 10.0.2.15:6443: connect: connection refused
To see the stack trace of this error execute with --v=5 or higher

The ip address generated by https in the error report after running is 10.0.2.15

Ping this ip on the node server can also be pinged, but your server ip is different from its automatically generated ip

It is because there are two network cards in the master server, we can turn off that network card

Use ifconfig to turn off the network card

ifconfig enp0s3 down    //关闭enp0s3网卡

ifconfig     //查看ip

ifconfig enp0s3 up     //开启enp0s3网卡

 After closing the unnecessary network card, restart the server, and then restore the changes made by kubeadm init to the host

Execute the command on the master server:

kubeadm reset     //重置kubeamd init 和kubeadm join 对服务器所做的更改

kubeadm init --image-repository registry.cn-hangzhou.aliyuncs.com/google_containers --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=192.168.56.101
//此处的192.168.56.101是我master服务器ip,把这个ip改成你自己服务器上的ip

After executing the kubeadm init command, a new kubeadm join command will be automatically generated, and then copied to the node node for execution

After executing on the node node, you can go back to the master server to check whether it is successful

kubectl get nodes //View node status

If there is node information, it means that the cluster is created successfully 

Guess you like

Origin blog.csdn.net/qq_62242833/article/details/124757455