一旦工作,那就要努力的干,聪明的干,快速的干——用省下来的时间干自己喜欢干的事情。!

kubernetes(k8s)中添加删除节点

linux lampnick 6739℃ 0评论

一、删除节点

1.查看节点信息

[root@master ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
master Ready master 19d v1.14.1
worker1 Ready <none> 19d v1.14.1
worker2 Ready <none> 19d v1.14.1
worker3 Ready <none> 19d v1.14.1
worker4 Ready <none> 19d v1.14.1

2.驱逐节点

[root@master ~]# kubectl drain worker4 --delete-local-data --force --ignore-daemonsets
node/worker4 cordoned
WARNING: ignoring DaemonSet-managed Pods: kube-system/kube-proxy-ndnlx, kube-system/weave-net-j7xdl
evicting pod "istio-pilot-84b747d7cc-6v67c"
evicting pod "ratings-v1-5846c8598-djkq8"
evicting pod "reviews-v2-68467ff988-9r6l4"
evicting pod "istio-citadel-86b5b9fb58-vwrhn"
evicting pod "istio-egressgateway-6769c4cdcc-v45c4"
evicting pod "istio-grafana-post-install-1.1.5-p6r25"
error when evicting pod "istio-pilot-84b747d7cc-6v67c" (will retry after 5s): Cannot evict pod as it would violate the pod's disruption budget.
error when evicting pod "istio-egressgateway-6769c4cdcc-v45c4" (will retry after 5s): Cannot evict pod as it would violate the pod's disruption budget.
pod/istio-grafana-post-install-1.1.5-p6r25 evicted
evicting pod "istio-pilot-84b747d7cc-6v67c"
evicting pod "istio-egressgateway-6769c4cdcc-v45c4"
error when evicting pod "istio-pilot-84b747d7cc-6v67c" (will retry after 5s): Cannot evict pod as it would violate the pod's disruption budget.
error when evicting pod "istio-egressgateway-6769c4cdcc-v45c4" (will retry after 5s): Cannot evict pod as it would violate the pod's disruption budget.
evicting pod "istio-egressgateway-6769c4cdcc-v45c4"
evicting pod "istio-pilot-84b747d7cc-6v67c"
error when evicting pod "istio-pilot-84b747d7cc-6v67c" (will retry after 5s): Cannot evict pod as it would violate the pod's disruption budget.
evicting pod "istio-pilot-84b747d7cc-6v67c"
error when evicting pod "istio-pilot-84b747d7cc-6v67c" (will retry after 5s): Cannot evict pod as it would violate the pod's disruption budget.
evicting pod "istio-pilot-84b747d7cc-6v67c"
error when evicting pod "istio-pilot-84b747d7cc-6v67c" (will retry after 5s): Cannot evict pod as it would violate the pod's disruption budget.
evicting pod "istio-pilot-84b747d7cc-6v67c"
node/worker4 evicted
由于需要将节点上的pod迁移到其他的node上,所以要一段时间才能驱逐成功
[root@master ~]# kubectl get pods --all-namespaces -o wide -w
NAMESPACE NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
default details-v1-6db45f5fc8-5c8bl 2/2 Running 4 16d 10.38.0.8 worker1 <none> <none>
default productpage-v1-6b7645968-46gwq 2/2 Running 4 16d 10.44.0.6 worker3 <none> <none>
default ratings-v1-5846c8598-qmtzf 0/2 PodInitializing 0 94s 10.40.0.9 worker2 <none> <none>
default reviews-v1-7bd89ccb9f-kc5zv 2/2 Running 4 16d 10.40.0.6 worker2 <none> <none>
default reviews-v2-68467ff988-7j5nw 0/2 PodInitializing 0 94s 10.44.0.9 worker3 <none> <none>
default reviews-v3-5b467dd865-89jpr 2/2 Running 4 16d 10.38.0.7 worker1 <none> <none>
istio-system grafana-67c69bb567-6zwwn 1/1 Running 2 16d 10.40.0.7 worker2 <none> <none>
istio-system istio-citadel-86b5b9fb58-g8whl 1/1 Running 0 95s 10.38.0.11 worker1 <none> <none>
istio-system istio-cleanup-secrets-1.1.5-mrkfg 0/1 Completed 0 16d 10.44.0.1 worker1 <none> <none>
istio-system istio-egressgateway-6769c4cdcc-v45c4 1/1 Running 2 16d 10.32.0.8 worker4 <none> <none>
istio-system istio-galley-5b98bd6859-zl8rz 1/1 Running 2 14d 10.44.0.5 worker3 <none> <none>

3.再次查看node信息

[root@master ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
master Ready master 19d v1.14.1
worker1 Ready <none> 19d v1.14.1
worker2 Ready <none> 19d v1.14.1
worker3 Ready <none> 19d v1.14.1
worker4 Ready,SchedulingDisabled <none> 19d v1.14.1

4.删除节点

[root@master ~]# kubectl delete nodes worker4
node "worker4" deleted
[root@master ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
master Ready master 19d v1.14.1
worker1 Ready <none> 19d v1.14.1
worker2 Ready <none> 19d v1.14.1
worker3 Ready <none> 19d v1.14.1

5.重置node

[root@worker4 ~]# kubeadm reset

二、添加node节点

[root@worker4 ~]# kubeadm join 172.16.0.222:6443 --token smz672.4uxlpw056eykpqi3 \
 --discovery-token-ca-cert-hash sha256:8c0b46999ce4cb50f9add92c7c6b28b15fdfeec49c9b09e605e227e667bc0e6b

三、添加master节点,多master节点情况,至少3个master

1.复制master节点上的配置信息到另外一个master节点上

在master2节点上创建目录

转载请注明:MitNick » kubernetes(k8s)中添加删除节点

喜欢 (17)or分享 (0)
头像
发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址