kubeadm join时出现错误:[ERROR Port-10250]: Port 10250 is in use;[ERROR FileAvailable--etc-kubernetes-pki-ca.crt]: /etc/kubernetes/pki/ca.crt already exists
初次使用kubeadm构建k8s集群,所以对子节点加入管理节点的过程认识不足,导致我先对子节点进行了kubeadm init
之后,才准备进行kubeadm join
操作。结果出现了如下错误:
[root@k8s-node02 ostrich5yw]# kubeadm join 192.168.139.129:6443 --token abcdef.0123456789abcdef \
> --discovery-token-ca-cert-hash sha256:3ac4ae8b5b3b08f2b8cd8a85be7b37bc5855e749ec9126e3d87bebfb2235af9b
[preflight] Running pre-flight checks[WARNING SystemVerification]: this Docker version is not on the list of validated versions: 20.10.6. Latest validated version: 18.09
error execution phase preflight: [preflight] Some fatal errors occurred:[ERROR DirAvailable--etc-kubernetes-manifests]: /etc/kubernetes/manifests is not empty[ERROR FileAvailable--etc-kubernetes-kubelet.conf]: /etc/kubernetes/kubelet.conf already exists[ERROR Port-10250]: Port 10250 is in use[ERROR FileAvailable--etc-kubernetes-pki-ca.crt]: /etc/kubernetes/pki/ca.crt already exists
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
问题原因:只有父节点需要运行kubeadm init --config=kubeadm-config.yaml --upload-certs | tee kubeadm-init.log
进行初始化;对于子节点来说,无需进行kubeadm init
进行初始化,直接运行kubeadm join加入父节点即可。
解决方法:运行kubeadm reset
重置子节点,之后直接对子节点使用kubeadm join 192.168.139.129:6443 --token abcdef.0123456789abcdef --discovery-token-ca-cert-hash sha256:3ac4ae8b5b3b08f2b8cd8a85be7b37bc5855e749ec9126e3d87bebfb2235af9b
将其加入对应的父节点中。