k8s node节点重新加入master集群的实现
1、删除node节点
执行kubectldeletenodenode01
2、这时如果直接执行加入,会报错。如下:
[root@k8s-node02pki]#kubeadmjoin192.168.140.128:6443--tokenabcdef.0123456789abcdef--discovery-token-ca-cert-hashsha256:a3d9827be411208258aea7f3ee9aa396956c0a77c8b570503dd677aa3b6eb6d8 [preflight]Runningpre-flightchecks [WARNINGSystemVerification]:thisDockerversionisnotonthelistofvalidatedversions:19.03.12.Latestvalidatedversion:18.09 errorexecutionphasepreflight:[preflight]Somefatalerrorsoccurred: [ERRORFileAvailable--etc-kubernetes-kubelet.conf]:/etc/kubernetes/kubelet.confalreadyexists [ERRORFileAvailable--etc-kubernetes-bootstrap-kubelet.conf]:/etc/kubernetes/bootstrap-kubelet.confalreadyexists [ERRORPort-10250]:Port10250isinuse [ERRORFileAvailable--etc-kubernetes-pki-ca.crt]:/etc/kubernetes/pki/ca.crtalreadyexists [preflight]Ifyouknowwhatyouaredoing,youcanmakeachecknon-fatalwith`--ignore-preflight-errors=...`
解决方案:
根据报错可以看到端口被占用,配置文件可ca证书已经生成,所以需要删除这些配置文件和证书,并且kill掉占用的端口。建议删除之前先备份。
[root@k8s-node02pki]#lsof-i:10250 COMMANDPIDUSERFDTYPEDEVICESIZE/OFFNODENAME kubelet694root30uIPv6260210t0TCP*:10250(LISTEN) [root@k8s-node02pki]#kill-9694 [root@k8s-node02pki]#cd/etc/kubernetes/ [root@k8s-node02kubernetes]#ls bootstrap-kubelet.confkubelet.confmanifestspki [root@k8s-node02kubernetes]#mvbootstrap-kubelet.confbootstrap-kubelet.conf_bk [root@k8s-node02kubernetes]#mvkubelet.confkubelet.conf_bk [root@k8s-node02kubernetes]#cdpki/ [root@k8s-node02pki]#ls ca.crt [root@k8s-node02pki]#rm-rfca.crt
3、再次执行加入,又出现报错。
[root@k8s-node02~]#kubeadmjoin192.168.140.128:6443--tokenabcdef.0123456789abcdef--discovery-token-ca-cert-hashsha256:a3d9827be411208258aea7f3ee9aa396956c0a77c8b570503dd677aa3b6eb6d8 [preflight]Runningpre-flightchecks [WARNINGSystemVerification]:thisDockerversionisnotonthelistofvalidatedversions:19.03.12.Latestvalidatedversion:18.09 [preflight]Readingconfigurationfromthecluster... [preflight]FYI:Youcanlookatthisconfigfilewith'kubectl-nkube-systemgetcmkubeadm-config-oyaml' [kubelet-start]Downloadingconfigurationforthekubeletfromthe"kubelet-config-1.15"ConfigMapinthekube-systemnamespace [kubelet-start]Writingkubeletconfigurationtofile"/var/lib/kubelet/config.yaml" [kubelet-start]Writingkubeletenvironmentfilewithflagstofile"/var/lib/kubelet/kubeadm-flags.env" [kubelet-start]Activatingthekubeletservice [kubelet-start]WaitingforthekubelettoperformtheTLSBootstrap... [kubelet-check]Initialtimeoutof40spassed. errorexecutionphasekubelet-start:erroruploadingcrisocket:timedoutwaitingforthecondition
解决方案:
执行kubeadmreset子节点重置
[root@k8s-node02~]#kubeadmreset [reset]WARNING:Changesmadetothishostby'kubeadminit'or'kubeadmjoin'willbereverted. [reset]Areyousureyouwanttoproceed?[y/N]:y [preflight]Runningpre-flightchecks W071010:22:57.48730631093removeetcdmember.go:79][reset]Nokubeadmconfig,usingetcdpodspectogetdatadirectory [reset]Noetcdconfigfound.Assumingexternaletcd [reset]Please,manuallyresetetcdtopreventfurtherissues [reset]Stoppingthekubeletservice [reset]Unmountingmounteddirectoriesin"/var/lib/kubelet" [reset]Deletingcontentsofconfigdirectories:[/etc/kubernetes/manifests/etc/kubernetes/pki] [reset]Deletingfiles:[/etc/kubernetes/admin.conf/etc/kubernetes/kubelet.conf/etc/kubernetes/bootstrap-kubelet.conf/etc/kubernetes/controller-manager.conf/etc/kubernetes/scheduler.conf] [reset]Deletingcontentsofstatefuldirectories:[/var/lib/kubelet/etc/cni/net.d/var/lib/dockershim/var/run/kubernetes] TheresetprocessdoesnotresetorcleanupiptablesrulesorIPVStables. Ifyouwishtoresetiptables,youmustdosomanually. Forexample: iptables-F&&iptables-tnat-F&&iptables-tmangle-F&&iptables-X IfyourclusterwassetuptoutilizeIPVS,runipvsadm--clear(orsimilar) toresetyoursystem'sIPVStables. Theresetprocessdoesnotcleanyourkubeconfigfilesandyoumustremovethemmanually. Please,checkthecontentsofthe$HOME/.kube/configfile.
4、最后执行加入,问题解决。
[root@k8s-node02~]#kubeadmjoin192.168.140.128:6443--tokenabcdef.0123456789abcdef--discovery-token-ca-cert-hashsha256:a3d9827be411208258aea7f3ee9aa396956c0a77c8b570503dd677aa3b6eb6d8 [preflight]Runningpre-flightchecks [WARNINGSystemVerification]:thisDockerversionisnotonthelistofvalidatedversions:19.03.12.Latestvalidatedversion:18.09 [preflight]Readingconfigurationfromthecluster... [preflight]FYI:Youcanlookatthisconfigfilewith'kubectl-nkube-systemgetcmkubeadm-config-oyaml' [kubelet-start]Downloadingconfigurationforthekubeletfromthe"kubelet-config-1.15"ConfigMapinthekube-systemnamespace [kubelet-start]Writingkubeletconfigurationtofile"/var/lib/kubelet/config.yaml" [kubelet-start]Writingkubeletenvironmentfilewithflagstofile"/var/lib/kubelet/kubeadm-flags.env" [kubelet-start]Activatingthekubeletservice [kubelet-start]WaitingforthekubelettoperformtheTLSBootstrap... Thisnodehasjoinedthecluster: *Certificatesigningrequestwassenttoapiserverandaresponsewasreceived. *TheKubeletwasinformedofthenewsecureconnectiondetails. Run'kubectlgetnodes'onthecontrol-planetoseethisnodejointhecluster.
5、查看master节点,加入成功。
[root@k8s-master01~]#kubectlgetnodes NAMESTATUSROLESAGEVERSION k8s-master01Readymaster120mv1.15.1 k8s-node01Ready100mv1.15.1 k8s-node02Ready 83mv1.15.1
到此这篇关于k8snode节点重新加入master集群的实现的文章就介绍到这了,更多相关k8snodemaster集群内容请搜索毛票票以前的文章或继续浏览下面的相关文章希望大家以后多多支持毛票票!
声明:本文内容来源于网络,版权归原作者所有,内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现有涉嫌版权的内容,欢迎发送邮件至:czq8825#qq.com(发邮件时,请将#更换为@)进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。