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 相关文章推荐
[原创]IE view-source 无法查看看源码 JavaScript看网页源码
Jul 19 Javascript
JQuery toggle使用分析
Nov 16 Javascript
jquery让返回的内容显示在特定div里(代码少而精悍)
Jun 23 Javascript
关于vue.js弹窗组件的知识点总结
Sep 11 Javascript
浅谈jquery之on()绑定事件和off()解除绑定事件
Oct 26 Javascript
微信小程序 地图map详解及简单实例
Jan 10 Javascript
JS实现动态修改table及合并单元格的方法示例
Feb 20 Javascript
mescroll.js上拉加载下拉刷新组件使用详解
Nov 13 Javascript
vue 实现 ios 原生picker 效果及实现思路解析
Dec 06 Javascript
浅谈使用mpvue开发小程序需要注意和了解的知识点
May 23 Javascript
vue项目中使用scss的方法步骤
May 16 Javascript
小程序实现列表展开收起效果
Jul 29 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中使用mysqli扩展库对mysql的操作
2013/07/03 PHP
php采集自中央气象台范围覆盖全国的天气预报代码实例
2015/01/04 PHP
使用JavaScript库还是自己写代码?
2010/01/28 Javascript
Javascript中的window.event.keyCode使用介绍
2011/04/26 Javascript
JS+CSS实现仿触屏手机拨号盘界面及功能模拟完整实例
2015/05/16 Javascript
jQuery插件制作之参数用法实例分析
2015/06/01 Javascript
如何通过js实现图片预览功能【附实例代码】
2016/03/30 Javascript
Javascript 6里的4个新语法
2016/08/25 Javascript
基于JS实现的随机数字抽签实例
2016/12/08 Javascript
Bootstrap面板(Panels)的简单实现代码
2017/03/17 Javascript
JavaScript时间戳与时间日期间相互转换
2017/12/11 Javascript
js实现点击按钮复制文本功能
2020/07/20 Javascript
js异步上传多张图片插件的使用方法
2018/10/22 Javascript
详解webpack+ES6+Sass搭建多页面应用
2018/11/05 Javascript
关于微信公众号开发无法支付的问题解决
2018/12/28 Javascript
jsonp格式前端发送和后台接受写法的代码详解
2019/11/07 Javascript
es6中使用map简化复杂条件判断操作实例详解
2020/02/19 Javascript
JavaScript 空间坐标的使用
2020/08/19 Javascript
[03:48]显微镜下的DOTA2第四期——TP动作
2014/06/20 DOTA
[02:36]DOTA2上海特锦赛 回忆电竞生涯的重要瞬间
2016/03/25 DOTA
python实现机械分词之逆向最大匹配算法代码示例
2017/12/13 Python
pandas 实现将重复表格去重,并重新转换为表格的方法
2018/04/18 Python
使用TensorFlow实现二分类的方法示例
2019/02/05 Python
Python解析json代码实例解析
2019/11/25 Python
Python实现Kerberos用户的增删改查操作
2020/12/14 Python
详解pycharm的python包opencv(cv2)无代码提示问题的解决
2021/01/29 Python
2分钟教你实现环形/扇形菜单(基础版)
2020/01/15 HTML / CSS
美国领先的汽车轮胎和轮毂供应商:TireBuyer
2016/07/21 全球购物
财务会计专业个人求职信范本
2014/01/08 职场文书
倡议书格式范文
2014/04/14 职场文书
洗手间标语
2014/06/23 职场文书
平遥古城导游词
2015/02/03 职场文书
工作态度怎么写
2015/06/25 职场文书
《乙女游戏世界对路人角色很不友好》OP主题曲无字幕动画MV公开
2022/04/05 日漫
SQL Server Agent 服务无法启动
2022/04/20 SQL Server
win10此电脑打不开怎么办 win10双击此电脑无响应的解决办法
2022/07/23 数码科技