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 内存释放问题
Apr 25 Javascript
高亮显示web页表格行的javascript代码
Nov 19 Javascript
给js文件传参数(详解)
Jul 13 Javascript
javascript使用正则表达式实现去掉空格之后的字符
Feb 15 Javascript
jQuery 回调函数(callback)的使用和基础
Feb 26 Javascript
jquery简单实现外部链接用新窗口打开的方法
May 30 Javascript
18个非常棒的jQuery代码片段
Nov 02 Javascript
基于原生JS实现图片裁剪
Aug 01 Javascript
Node.js与Sails redis组件的使用教程
Feb 14 Javascript
微信小程序  http请求封装详解及实例代码
Feb 15 Javascript
JS实现颜色的10进制转化成rgba格式的方法
Sep 04 Javascript
vue实现模态框的通用写法推荐
Feb 26 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中数组元素升序、降序以及重新排序的函数
2013/06/20 PHP
浅析PHP中Session可能会引起并发问题
2015/07/23 PHP
PHP简单遍历对象示例
2016/09/28 PHP
ThinkPHP5框架中使用JWT的方法示例
2020/06/03 PHP
JavaScript Event学习第十章 一些可替换的事件对
2010/02/10 Javascript
Js 去掉字符串中的空格(实现代码)
2013/11/19 Javascript
JS中怎样判断undefined(比较不错的方法)
2014/03/27 Javascript
javascript获取当前鼠标坐标的方法
2015/01/10 Javascript
JavaScript返回0-1之间随机数的方法
2015/04/06 Javascript
jQuery表单验证功能实例
2015/08/28 Javascript
jQuery实现的表头固定效果实例【附完整demo源码下载】
2016/08/01 Javascript
Angularjs 动态改变title标题(兼容ios)
2016/12/29 Javascript
jq stop()和:is(:animated)的用法及区别(详解)
2017/02/12 Javascript
js仿微博动态栏功能
2017/02/22 Javascript
Easyui在treegrid添加控件的实现方法
2017/06/23 Javascript
JavaScript 五大常见函数
2018/03/23 Javascript
详细讲解用Python发送SMTP邮件的教程
2015/04/29 Python
Python编程实现数学运算求一元二次方程的实根算法示例
2017/04/02 Python
Python实现Logger打印功能的方法详解
2017/09/01 Python
python3.0 模拟用户登录,三次错误锁定的实例
2017/11/02 Python
使用python 和 lint 删除项目无用资源的方法
2017/12/20 Python
python实现随机梯度下降法
2020/03/24 Python
python的pip安装以及使用教程
2018/09/18 Python
对json字符串与python字符串的不同之处详解
2018/12/19 Python
python读取几个G的csv文件方法
2019/01/07 Python
浅谈pytorch中的BN层的注意事项
2020/06/23 Python
一文带你掌握Pyecharts地理数据可视化的方法
2021/02/06 Python
英国折扣零售连锁店:QD Stores
2018/12/08 全球购物
The Kooples美国官方网站:为情侣提供的法国当代时尚品牌
2019/01/03 全球购物
大学生学习2014全国两会心得体会
2014/03/13 职场文书
服装设计专业毕业生求职信
2014/04/09 职场文书
2015年团支书工作总结
2015/04/03 职场文书
慈善献爱心倡议书
2015/04/27 职场文书
大学生社会实践活动总结报告
2015/05/06 职场文书
原来闭幕词是这样写的呀!
2019/07/01 职场文书
Python使用华为API为图像设置多个锚点标签
2022/04/12 Python