一,报错1

参考文档:
https://blog.csdn.net/qianghaohao/article/details/82624920
https://www.cnblogs.com/wangzy-tongq/p/13130877.html

[root@k8s-node01 gudong]# kubeadm join 192.168.31.232:6443 --token abcdef.0123456789abcdef     --discovery-token-ca-cert-hash sha256:b5bfe6c4e3cef6455e33c5de503035c49c59da41c3cdbc504b8e7f92d3d329ea
[preflight] Running pre-flight checks
	[WARNING SystemVerification]: this Docker version is not on the list of validated versions: 20.10.2. Latest validated version: 18.09
error execution phase preflight: [preflight] Some fatal errors occurred:
	[ERROR FileAvailable--etc-kubernetes-kubelet.conf]: /etc/kubernetes/kubelet.conf already exists
	[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=...`

原因:之前已经加入过一次
解决办法:重置后重新加入

[root@k8s-node01 gudong]# kubeadm reset
[reset] Reading configuration from the cluster...
[reset] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -oyaml'
W0225 20:37:19.258565   11300 reset.go:98] [reset] Unable to fetch the kubeadm-config ConfigMap from cluster: failed to get config map: Get https://192.168.31.233:6443/api/v1/namespaces/kube-system/configmaps/kubeadm-config: dial tcp 192.168.31.233:6443: connect: connection refused
[reset] WARNING: Changes made to this host by 'kubeadm init' or 'kubeadm join' will be reverted.
[reset] Are you sure you want to proceed? [y/N]: y
[preflight] Running pre-flight checks
W0225 20:37:43.329899   11300 removeetcdmember.go:79] [reset] No kubeadm config, using etcd pod spec to get data directory
[reset] No etcd config found. Assuming external etcd
[reset] Please, manually reset etcd to prevent further issues
[reset] Stopping the kubelet service
[reset] Unmounting mounted directories in "/var/lib/kubelet"
[reset] Deleting contents of config directories: [/etc/kubernetes/manifests /etc/kubernetes/pki]
[reset] Deleting files: [/etc/kubernetes/admin.conf /etc/kubernetes/kubelet.conf /etc/kubernetes/bootstrap-kubelet.conf /etc/kubernetes/controller-manager.conf /etc/kubernetes/scheduler.conf]
[reset] Deleting contents of stateful directories: [/var/lib/kubelet /etc/cni/net.d /var/lib/dockershim /var/run/kubernetes]

The reset process does not reset or clean up iptables rules or IPVS tables.
If you wish to reset iptables, you must do so manually.
For example:
iptables -F && iptables -t nat -F && iptables -t mangle -F && iptables -X

If your cluster was setup to utilize IPVS, run ipvsadm --clear (or similar)
to reset your system's IPVS tables.

The reset process does not clean your kubeconfig files and you must remove them manually.
Please, check the contents of the $HOME/.kube/config file.
[root@k8s-node01 gudong]# 

重新加入:

[root@k8s-node01 gudong]# kubeadm join 192.168.31.232:6443 --token abcdef.0123456789abcdef     --discovery-token-ca-cert-hash sha256:b5bfe6c4e3cef6455e33c5de503035c49c59da41c3cdbc504b8e7f92d3d329ea 

二,报错2

参考文档:
https://www.cnblogs.com/winstom/p/11684921.html(主)
https://blog.csdn.net/weixin_44723434/article/details/94583457

[root@k8s-node01 gudong]# kubeadm join 192.168.31.232:6443 --token abcdef.0123456789abcdef \
>     --discovery-token-ca-cert-hash sha256:b5bfe6c4e3cef6455e33c5de503035c49c59da41c3cdbc504b8e7f92d3d329ea
[preflight] Running pre-flight checks
	[WARNING SystemVerification]: this Docker version is not on the list of validated versions: 20.10.2. Latest validated version: 18.09
error execution phase preflight: couldn't validate the identity of the API Server: abort connecting to API servers after timeout of 5m0s

解决:重新生成新token
在master节点重新生成token:

[root@k8s-master01 gudong]#kubeadm token create
ikkd3i.tqggsdafo4qkmyyt
[root@k8s-master01 gudong]#
[root@k8s-master01 gudong]#openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -hex | sed 's/^.* //'
b5bfe6c4e3cef6455e33c5de503035c49c59da41c3cdbc504b8e7f92d3d329ea

node节点重新join:

[root@k8s-node01 gudong]# kubeadm join 192.168.31.232:6443 --token ikkd3i.tqggsdafo4qkmyyt \
>     --discovery-token-ca-cert-hash sha256:b5bfe6c4e3cef6455e33c5de503035c49c59da41c3cdbc504b8e7f92d3d329ea
[preflight] Running pre-flight checks
	[WARNING SystemVerification]: this Docker version is not on the list of validated versions: 20.10.2. Latest validated version: 18.09
[preflight] Reading configuration from the cluster...
[preflight] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -oyaml'
[kubelet-start] Downloading configuration for the kubelet from the "kubelet-config-1.15" ConfigMap in the kube-system namespace
[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
[kubelet-start] Activating the kubelet service
[kubelet-start] Waiting for the kubelet to perform the TLS Bootstrap...

This node has joined the cluster:
* Certificate signing request was sent to apiserver and a response was received.
* The Kubelet was informed of the new secure connection details.

Run 'kubectl get nodes' on the control-plane to see this node join the cluster.
Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐