开启本地集群,发现一台节点出问题了,想删除再换一台节点,结果就踩坑了,还好本地有好几套环境。

再master节点执行以下命令

[root@k8s-master ~]# kubectl drain k8s-node01 --delete-local-data --force --ignore-daemonsets
node/k8s-node01 cordoned
WARNING: ignoring DaemonSet-managed Pods: kube-system/kube-flannel-ds-amd64-jz65p, kube-system/kube-proxy-92x28
evicting pod "coredns-58cc8c89f4-88ns2"
evicting pod "nginx-document1-854875f78d-8cbxw"
pod/coredns-58cc8c89f4-88ns2 evicted
pod/nginx-document1-854875f78d-8cbxw evicted
node/k8s-node01 evicted
[root@k8s-master ~]# kubectl delete node k8s-node01
node "k8s-node01" deleted
[root@k8s-master ~]# kubectl get node
NAME STATUS ROLES AGE VERSION
k8s-master Ready master 3d4h v1.16.1
k8s-node02 Ready <none> 3d3h v1.16.1
[root@k8s-master ~]#

在node节点执行(网上有人说运行,没有指定那个环境,我直接在master运行了,导致一套集群出问题了)

[root@k8s-node01 ~]# kubeadm reset
[reset] Reading configuration from the cluster...
[reset] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -oyaml'
W1219 20:47:15.318403 89075 reset.go:96] [reset] Unable to fetch the kubeadm-config ConfigMap from cluster: failed to get node registration: failed to get corresponding node: nodes "k8s-node01" not found
[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
W1219 20:47:19.276564 89075 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 /var/lib/cni] 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.

注意:重新在K8s上获取Token

[root@k8s-master pki]# kubeadm token create --print-join-command
kubeadm join 192.168.180.121:6443 --token p08kmc.nci5h0xfmlcw92vg --discovery-token-ca-cert-hash sha256:44315d59e08f4d94bc75d20730b861818dfeda6517c1b228399f061f4256329b

子节点重新加入

[root@k8s-node01 lib]# kubeadm join 192.168.180.121:6443 --token p08kmc.nci5h0xfmlcw92vg     --discovery-token-ca-cert-hash sha256:44315d59e08f4d94bc75d20730b861818dfeda6517c1b228399f061f4256329b
[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] Downloading configuration for the kubelet from the "kubelet-config-1.16" 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.
[root@k8s-master pki]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8s-master Ready master 3d4h v1.16.1
k8s-node01 Ready <none> 2m35s v1.16.1
k8s-node02 Ready <none> 3d3h v1.16.1
[root@k8s-master pki]#

k8s删除节点后再重新添加进去(踩坑)的更多相关文章

  1. k8s删除节点

    k8s 删除节点 线上环境 # ctl get nodes NAME STATUS ROLES AGE VERSION 10.0.0.123 Ready <none> 104d v1.20 ...

  2. kafka删除topic后再创建同名的topic报错(ERROR org.apache.kafka.common.errors.TopicExistsException)

    [hadoop@datanode3 logs]$ kafka-topics.sh --delete --zookeeper datanode1:2181 --topic firstTopic firs ...

  3. VSTO PowerPoint 代码删除Shape后再恢复出现无法再次获取的问题

    做PowerPoint的VSTO插件项目,遇到个很奇怪的问题,当代码执行删除某些Shape时,没问题,但是操作Undo也就是恢复后,无法再次获取到之前删除的对象,这种情况只在Office2007中出现 ...

  4. adoop集群动态添加和删除节点

    hadoop集群动态添加和删除节点说明 上篇博客我已经安装了Hadoop集群(hadoop集群的安装步骤和配置),现在写这个博客我将在之前的基础上进行节点的添加的删除. 首先将启动四台机器(一主三从) ...

  5. Hadoop记录-Hadoop集群添加节点和删除节点

    1.添加节点 A:新节点中添加账户,设置无密码登陆 B:Name节点中设置到新节点的无密码登陆 C:在Name节点slaves文件中添加新节点 D:在所有节点/etc/hosts文件中增加新节点(所有 ...

  6. CRS添加、删除节点

    一.如何删除一个节点: 1.1 在存活的节点上操作,使用dbca删除DB实例 1.2 清除ASM实例  在存活的节点上做如下操作  1.2.1 停止ASM实例    export ORACLE_HOM ...

  7. RedisCluster 添加/删除节点

    一,redis cluster命令行 //集群(cluster) CLUSTER INFO 打印集群的信息 CLUSTER NODES 列出集群当前已知的所有节点(node),以及这些节点的相关信息. ...

  8. Elasticsearch集群管理之添加、删除节点

    1.问题抛出 1.1 新增节点问题 我的群集具有黄色运行状况,因为它只有一个节点,因此副本保持未分配状态,我想要添加一个节点,该怎么弄? 1.2 删除节点问题 假设集群中有5个节点,我必须在运行时删除 ...

  9. Hadoop日常维护系列——Hadoop添加删除节点

    添加节点 1.修改host    和普通的datanode一样.添加namenode的ip 2.修改namenode的配置文件conf/slaves    添加新增节点的ip或host 3.在新节点的 ...

随机推荐

  1. # 深圳杯D题爬取电视收视率排行榜

    目录 深圳杯D题爬取电视收视率排行榜 站点分析 代码实现 深圳杯D题爬取电视收视率排行榜 站点分析 http://www.tvtv.hk/archives/category/tv 每天的排行版通过静态 ...

  2. git删除已经push的远程文件或文件夹

    在使用git提交项目时,有时候会误提交一下文件,比如:*.iml,*.project,*.settings,.idea/*等文件,有时候这些不需要提交的文件可以加入到.gitignore,在提交的时候 ...

  3. Volatile可见性 与 Synchronization原子性的优化

    Volatile可见性 比如现在我们有这样一段代码:线程等待另一个线程将数据装载完就输出success,可是最后程序一直卡在while循环里没有往下执行. public class VolatileD ...

  4. 进程管理工具之supervisor[详解]

    原文链接:https://blog.csdn.net/weixin_42390791/article/details/88866237 一.问题背景1.背景​   如何才能让一个进程摆脱终端,获得相对 ...

  5. 转载Google TPU论文

    选自 Google Drive 作者:Norman P. Jouppi 等 痴笑@矽说 编译 该论文将正式发表于 ISCA 2017 从去年七月起,Google就号称了其面向深度学习的专用集成电路(A ...

  6. js 格式化 json 字符串

    1.JSON.stringify的三个参数 var json = {"@odata.context":"$metadata#AddTableOne_466281s&quo ...

  7. idea安装完成后要做的几件事(设置字体、编码、行号)

    1.设置字体大小和样式 打开设置:File-->Settings 看到如下界面,输入font,点击Editor目录下的Font设置字体大小和样式: Font:字体样式 size:字体大小 Fal ...

  8. 谷歌对Intel 10nm进度不满

    Intel 在 10nm 处理器上的节奏可谓是“龟速”,一拖三年,且目前大规模发货的 10nm Ice Lake 处理器仅仅是移动平台低电压,桌面要到明年. 表面波澜不惊,实际上却暗流涌动. 首先是 ...

  9. [CF#592 E] [二分答案] Minimizing Difference

    链接:http://codeforces.com/contest/1244/problem/E 题意: 给定包含$n$个数的数组,你可以执行最多k次操作,使得数组的一个数加1或者减1. 问合理的操作, ...

  10. Codeforces 1000 组合数可行线段倒dp 边双联通缩点求树直径

    A /*Huyyt*/ #include<bits/stdc++.h> #define mem(a,b) memset(a,b,sizeof(a)) using namespace std ...