在已建立好的k8s集群中删除节点后,进行添加新的节点,可参考用于添加全新node节点,若新的node需要安装docker和k8s基础组件。

建立集群可以参考曾经的文章:CentOS8 搭建Kubernetes

1. 在master中,查看节点数和要删除的节点数,因集群ip进行了修改,节点出现了异常。

[root@k8s-master ~]# kubectl  get nodes

NAME         STATUS     ROLES    AGE   VERSION

k8s-master   Ready      master   13d   v1.19.3

k8s-node1    NotReady   <none>   13d   v1.19.3

k8s-node2    NotReady   <none>   13d   v1.19.3

2. 进行删除节点操作。

[root@k8s-master ~]# kubectl  delete nodes k8s-node1

node "k8s-node1" deleted

[root@k8s-master ~]# kubectl  delete nodes k8s-node2

node "k8s-node2" deleted

3. 在被删除的node节点中清空集群数据信息。

[root@k8s-node1 ~]# 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
W1121 05:40:44.876393 9649 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 /var/lib/dockershim /var/run/kubernetes /var/lib/cni] The reset process does not clean CNI configuration. To do so, you must remove /etc/cni/net.d 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 by using the "iptables" command. 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. 在集群中查看集群的token值

[root@k8s-master ~]# kubeadm token create --print-join-command
W1121 05:38:27.405833 12512 configset.go:348] WARNING: kubeadm cannot validate component configs for API groups [kubelet.config.k8s.io kubeproxy.config.k8s.io]
kubeadm join 10.0.1.48:6443 --token 8xwcaq.qxekio9xd02ed936     --discovery-token-ca-cert-hash sha256:d988ba566675095ae25255d63b21cc4d5a9a69bee9905dc638f58b217c651c14 

5. 将node节点重新添加到k8s集群中

[root@k8s-node1 ~]# kubeadm join 10.0.1.48:6443 --token 8xwcaq.qxekio9xd02ed936     --discovery-token-ca-cert-hash sha256:d988ba566675095ae25255d63b21cc4d5a9a69bee9905dc638f58b217c651c14
[preflight] Running pre-flight checks
[WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd". Please follow the guide at https://kubernetes.io/docs/setup/cri/
[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] 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] Starting the kubelet
[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.

6. 查看pod情况

[root@k8s-master ~]# kubectl get pods -n kube-system -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
coredns-f9fd979d6-c6qrl 0/1 ContainerCreating 1 13d <none> k8s-node1 <none> <none>
coredns-f9fd979d6-hmpbj 1/1 Running 0 13d 10.244.2.2 k8s-node2 <none> <none>
etcd-k8s-master 1/1 Running 5 13d 10.0.1.48 k8s-master <none> <none>
kube-apiserver-k8s-master 1/1 Running 6 13d 10.0.1.48 k8s-master <none> <none>
kube-controller-manager-k8s-master 1/1 Running 5 13d 10.0.1.48 k8s-master <none> <none>
kube-flannel-ds-5ftj9 1/1 Running 4 13d 10.0.1.48 k8s-master <none> <none>
kube-flannel-ds-bwh28 1/1 Running 0 23m 10.0.1.50 k8s-node2 <none> <none>
kube-flannel-ds-ttx7c 0/1 Init:0/1 0 23m 10.0.1.49 k8s-node1 <none> <none>
kube-proxy-4xxxh 0/1 ContainerCreating 2 13d 10.0.1.49 k8s-node1 <none> <none>
kube-proxy-7rs4w 1/1 Running 0 13d 10.0.1.50 k8s-node2 <none> <none>
kube-proxy-d5hrv 1/1 Running 4 13d 10.0.1.48 k8s-master <none> <none>
kube-scheduler-k8s-master            1/1     Running             5          13d   10.0.1.48    k8s-master   <none>           <none>

7.查看node情况

[root@k8s-master ~]# kubectl  get nodes
NAME STATUS ROLES AGE VERSION
k8s-master Ready master 13d v1.19.3
k8s-node1 Ready <none> 24m v1.19.3
k8s-node2    Ready    <none>   24m   v1.19.3

高新科技园

k8s集群进行删除并添加node节点的更多相关文章

  1. K8s集群部署(三)------ Node节点部署

    之前的docker和etcd已经部署好了,现在node节点要部署二个服务:kubelet.kube-proxy. 部署kubelet(Master 节点操作) 1.二进制包准备 [root@k8s-m ...

  2. K8S线上集群排查,实测排查Node节点NotReady异常状态

    一,文章简述 大家好,本篇是个人的第 2 篇文章.是关于在之前项目中,k8s 线上集群中 Node 节点状态变成 NotReady 状态,导致整个 Node 节点中容器停止服务后的问题排查. 文章中所 ...

  3. K8s集群部署(二)------ Master节点部署

    Master节点要部署三个服务:API Server.Scheduler.Controller Manager. apiserver提供集群管理的REST API接口,包括认证授权.数据校验以 及集群 ...

  4. Node节点如何加入K8S集群

    k8s集群中,有时候发现有些节点状态为 NotReady,如何修复为Ready状态呢? [root@k8s-master~]# kubectl get nodes NAME STATUS ROLES ...

  5. 【K8S】基于单Master节点安装K8S集群

    写在前面 最近在研究K8S,今天就输出部分研究成果吧,后续也会持续更新. 集群规划 IP 主机名 节点 操作系统版本 192.168.175.101 binghe101 Master CentOS 8 ...

  6. 使用kubeadm部署k8s集群[v1.18.0]

    使用kubeadm部署k8s集群 环境 IP地址 主机名 节点 10.0.0.63 k8s-master1 master1 10.0.0.63 k8s-master2 master2 10.0.0.6 ...

  7. 冰河教你一次性成功安装K8S集群(基于一主两从模式)

    写在前面 研究K8S有一段时间了,最开始学习K8S时,根据网上的教程安装K8S环境总是报错.所以,我就改变了学习策略,先不搞环境搭建了.先通过官网学习了K8S的整体架构,底层原理,又硬啃了一遍K8S源 ...

  8. Centos7使用kubeadm安装1.23.1版本的k8s集群

    系统环境 #cat /etc/redhat-release CentOS Linux release 7.6.1810 (Core) #Linux内核一定要大约等于3.10,也就是centos版本要大 ...

  9. Centos7 安装部署Kubernetes(k8s)集群

    目录 一.系统环境 二.前言 三.Kubernetes 3.1 概述 3.2 Kubernetes 组件 3.2.1 控制平面组件 3.2.2 Node组件 四.安装部署Kubernetes集群 4. ...

  10. k8s集群新增节点

    节点为centos7.4 一.node节点基本环境配置 1.配置主机名 2.配置hosts文件(master和node相互解析) 3.时间同步 ntpdate pool.ntp.org date ec ...

随机推荐

  1. 【xUtils框架问题】xUtils继承基类的x.view().inject(this)绑定点击事件@Event无效

    由于看得教程里的xUtils比较老了,不知道什么版本的. 还是使用ViewUtils.inject()进行绑定反射的,使用@OnClick进行点击监听绑定的. 3.9.0版本的xUtils使用: x. ...

  2. unable to access 'http://*****/': The requested URL returned error: 414

    git拉取gitlab项目: unable to access 'http://git.yijiago.com/meimeng/lsyjg_java.git/': The requested URL ...

  3. 中国台湾BSMI认证变动

    China Taiwan 中国台湾 2022 年 11 月 1 日,BSMI和经济部发布了针对 18 种音像产品的修订法定检验要求. 自发布之日起,CNS 15598-1:2020 Audio/vid ...

  4. 狐漠漠养成日记 Cp.00000 前言

    前言 狐漠漠是我的常用网名,来源是因为我非常非常非常喜欢耳廓狐(也称作沙漠狐),所以我就给自己拟造了一个名叫狐漠漠的虚拟形象(如下图所示). 设定上是女孩子因为我想当女孩子但是我不是所以我就在设定上满 ...

  5. Spring系列之类型转换-12

    目录 类型转换 转换器 SPI 使用`ConverterFactory` 使用`GenericConverter` `ConversionService` 配置一个`ConversionService ...

  6. 容器内Java微服务报错:unable to create new native thread

    unable to create new native threadhttps://stackoverflow.com/questions/16789288/java-lang-outofmemory ...

  7. Day02 差点水掉 欸呀呀

    Java狂神6.17星期四 知识行 冯诺依曼+图灵 软件+硬件 .......... 快捷键 ctrl+a 全选 ctrl+x 剪切 alt+F4 关闭窗口 win+r 运行 +cmd命令行 win+ ...

  8. 5、什么是MIME

    MIME 类型 媒体类型(通常称为 Multipurpose Internet Mail Extensions 或 MIME 类型 )是一种标准,用来表示文档.文件或字节流的性质和格式.它在IETF ...

  9. H5软键盘回车事件

    //软键盘回车事件 document.onkeydown = function (event) { var e = event || window.event; if (e.keyCode === 1 ...

  10. Q:oracle 日期筛选

    一.oracle where条件日期筛选 两种方法:tochar和todate todate:将字符串按照指定的格式输出,得到的是日期类型. to_date('2019-12-01','yyyy-MM ...