k8s node节点重新加入master集群的实现


Posted in Javascript onFebruary 22, 2021

1、删除node节点

执行kubectl delete node node01

2、这时如果直接执行加入,会报错。如下:

[root@k8s-node02 pki]# kubeadm join 192.168.140.128:6443 --token abcdef.0123456789abcdef   --discovery-token-ca-cert-hash sha256:a3d9827be411208258aea7f3ee9aa396956c0a77c8b570503dd677aa3b6eb6d8 
[preflight] Running pre-flight checks
 [WARNING SystemVerification]: this Docker version is not on the list of validated versions: 19.03.12. 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-bootstrap-kubelet.conf]: /etc/kubernetes/bootstrap-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=...`

 解决方案:

根据报错可以看到端口被占用,配置文件可ca证书已经生成,所以需要删除这些配置文件和证书,并且kill掉占用的端口。建议删除之前先备份。

[root@k8s-node02 pki]# lsof -i:10250
COMMAND PID USER  FD  TYPE DEVICE SIZE/OFF NODE NAME
kubelet 694 root  30u IPv6 26021   0t0 TCP *:10250 (LISTEN)
[root@k8s-node02 pki]# kill -9 694
[root@k8s-node02 pki]# cd /etc/kubernetes/
[root@k8s-node02 kubernetes]# ls
bootstrap-kubelet.conf kubelet.conf manifests pki
[root@k8s-node02 kubernetes]# mv bootstrap-kubelet.conf bootstrap-kubelet.conf_bk
[root@k8s-node02 kubernetes]# mv kubelet.conf kubelet.conf_bk
[root@k8s-node02 kubernetes]# cd pki/
[root@k8s-node02 pki]# ls
ca.crt
[root@k8s-node02 pki]# rm -rf ca.crt

3、再次执行加入,又出现报错。

[root@k8s-node02 ~]# kubeadm join 192.168.140.128:6443 --token abcdef.0123456789abcdef   --discovery-token-ca-cert-hash sha256:a3d9827be411208258aea7f3ee9aa396956c0a77c8b570503dd677aa3b6eb6d8 
[preflight] Running pre-flight checks
 [WARNING SystemVerification]: this Docker version is not on the list of validated versions: 19.03.12. 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...
[kubelet-check] Initial timeout of 40s passed.
error execution phase kubelet-start: error uploading crisocket: timed out waiting for the condition

解决方案:

执行kubeadm reset子节点重置

[root@k8s-node02 ~]# kubeadm reset
[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
W0710 10:22:57.487306  31093 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.

4、最后执行加入,问题解决。

[root@k8s-node02 ~]# kubeadm join 192.168.140.128:6443 --token abcdef.0123456789abcdef   --discovery-token-ca-cert-hash sha256:a3d9827be411208258aea7f3ee9aa396956c0a77c8b570503dd677aa3b6eb6d8 
[preflight] Running pre-flight checks
 [WARNING SystemVerification]: this Docker version is not on the list of validated versions: 19.03.12. 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.

5、查看master节点,加入成功。

[root@k8s-master01 ~]# kubectl get nodes
NAME      STATUS  ROLES  AGE  VERSION
k8s-master01  Ready  master  120m  v1.15.1
k8s-node01   Ready  <none>  100m  v1.15.1
k8s-node02   Ready  <none>  83m  v1.15.1

到此这篇关于k8s node节点重新加入master集群的实现的文章就介绍到这了,更多相关k8s node master集群内容请搜索三水点靠木以前的文章或继续浏览下面的相关文章希望大家以后多多支持三水点靠木!

Javascript 相关文章推荐
js 设置选中行的样式的实现代码
May 24 Javascript
js切换div css注意的细节
Dec 10 Javascript
Jquery Ajax方法传值到action的方法
May 11 Javascript
Jquery-data的三种用法
Apr 18 jQuery
js+html5实现复制文字按钮
Jul 15 Javascript
JS实现的将html转为pdf功能【基于浏览器端插件jsPDF】
Feb 06 Javascript
angularJs-$http实现百度搜索时的动态下拉框示例
Feb 27 Javascript
用ES6写全屏滚动插件的示例代码
May 02 Javascript
函数式编程入门实践(一)
Apr 20 Javascript
解决vuex数据异步造成初始化的时候没值报错问题
Nov 13 Javascript
vue渲染方式render和template的区别
Jun 05 Javascript
解决vant title-active-color与title-inactive-color不生效问题
Nov 03 Javascript
js实现简单图片拖拽效果
Feb 22 #Javascript
用vite搭建vue3应用的实现方法
Feb 22 #Vue.js
详解Vite的新体验
Feb 22 #Javascript
详解Vue3.0 + TypeScript + Vite初体验
Feb 22 #Vue.js
Nest.js 授权验证的方法示例
Feb 22 #Javascript
使用原生javascript开发计算器实例代码
Feb 21 #Javascript
Nest.js环境变量配置与序列化详解
Feb 21 #Javascript
You might like
将时间以距今多久的形式表示,PHP,js双版本
2012/09/25 PHP
symfony表单与页面实现技巧
2015/01/26 PHP
Laravel中使用自己编写类库的3种方法
2015/02/10 PHP
WordPress开发中短代码的实现及相关函数使用技巧
2016/01/05 PHP
php数组指针操作详解
2017/02/14 PHP
CI框架(CodeIgniter)实现的导入、导出数据操作示例
2018/05/24 PHP
php设计模式之适配器模式原理、用法及注意事项详解
2019/09/24 PHP
use jscript Create a SQL Server database
2007/06/16 Javascript
JavaScript 事件的一些重要说明
2009/10/25 Javascript
javascript列表框操作函数集合汇总
2013/11/28 Javascript
node.js中RPC(远程过程调用)的实现原理介绍
2014/12/05 Javascript
jQuery插件实现控制网页元素动态居中显示
2015/03/24 Javascript
jQuery插件kinMaxShow扩展效果用法实例
2015/05/04 Javascript
jQuery实现仿QQ头像闪烁效果的文字闪动提示代码
2015/11/03 Javascript
react高阶组件经典应用之权限控制详解
2017/09/07 Javascript
[原创]js实现保存文本框内容为本地文件兼容IE,chrome,火狐浏览器
2018/02/14 Javascript
vue对storejs获取的数据进行处理时遇到的几种问题小结
2018/03/20 Javascript
js变量值传到php过程详解 将php解析成数据
2019/06/26 Javascript
JavaScript实现好看的跟随彩色气泡效果
2020/02/06 Javascript
Vue使用JSEncrypt实现rsa加密及挂载方法
2020/02/07 Javascript
[42:32]Secret vs Optic 2018国际邀请赛小组赛BO2 第二场 8.18
2018/08/19 DOTA
python pdb调试方法分享
2014/01/21 Python
python实现爬虫下载漫画示例
2014/02/16 Python
Python修改MP3文件的方法
2015/06/15 Python
Python 中的Selenium异常处理实例代码
2018/05/03 Python
Python使用type关键字创建类步骤详解
2019/07/23 Python
python如何保证输入键入数字的方法
2019/08/23 Python
python selenium实现发送带附件的邮件代码实例
2019/12/10 Python
keras 回调函数Callbacks 断点ModelCheckpoint教程
2020/06/18 Python
海外淘书首选:AbeBooks
2017/07/31 全球购物
印度低票价航空公司:GoAir
2017/10/11 全球购物
四种会话跟踪技术
2015/05/20 面试题
母婴店促销方案
2014/03/05 职场文书
巾帼建功标兵事迹材料
2014/05/11 职场文书
2015年公务员工作总结
2015/04/24 职场文书
新闻稿标题
2015/07/18 职场文书