美文网首页
k8s运维-04-重启node机器的过程

k8s运维-04-重启node机器的过程

作者: 当当一丢丢 | 来源:发表于2019-03-20 23:10 被阅读0次

重启node的情况

此处是直接reboot node节点


重启时间较短

  • Node controller 默认的驱逐时间为5分钟,在此时间之内,node重启后,kubelet 会 自动重启所有pod
    • 重启后 pod ip 地址会变
    • controller manager上的 --pod-eviction-timeout 参数设定时长

重启时间较长-超过5minutes

  • 首先,Node Controller(实际是Controller manager)会驱逐node 上的pod,驱逐即删除
  • 若pod为ReplicaSet,在其他node上新建相同个pod
  • 若pod没有副本,则GG

结论

  • 在有Replicaset 副本下,重启机器没有影响(只要不是所有node同时重启)

drain过程

一般在重启机器,或者对接点更新内核版本等时,可以首先执行优雅的关闭所有pod(gracefully terminate all pods),即drain node


drain前10.5.0.44节点

[root@k8smaster163075 ~]
$kubectl get pods -n test-kubeasy-k8s -o wide | grep 10.5.0.44
atlas-uat-deployment-5b65898567-7728f   1/1     Running   2          25h   10.5.44.108   10.5.0.44   <none>
atlas-uat-deployment-5b65898567-pgnkg   1/1     Running   2          25h   10.5.44.109   10.5.0.44   <none>
atlas-uat-deployment-5b65898567-w6xsz   1/1     Running   2          25h   10.5.44.107   10.5.0.44   <none>

drain 节点

  • 标记为了不可调度(通过cordon实现)
[root@k8smaster163075 ~]
$kubectl drain 10.5.0.44
node/10.5.0.44 cordoned
pod/atlas-uat-deployment-5b65898567-w6xsz evicted
pod/atlas-uat-deployment-5b65898567-pgnkg evicted
pod/atlas-uat-deployment-5b65898567-7728f evicted

查看 drain后的节点pod状态

  • 已不存在pod
[root@k8smaster163075 ~]
$kubectl get pods -n test-kubeasy-k8s -o wide | grep 10.5.0.44

查看 nodes 状态

  • 标记为SchedulingDisabled
$kubectl get nodes
NAME        STATUS                     ROLES    AGE   VERSION
10.5.0.43   Ready                      <none>   25h   v1.11.3
10.5.0.44   Ready,SchedulingDisabled   <none>   25h   v1.11.3
10.5.0.45   Ready                      <none>   25h   v1.11.3
10.5.0.46   Ready                      <none>   25h   v1.11.3
10.5.0.47   Ready                      <none>   25h   v1.11.3
10.5.0.48   Ready                      <none>   25h   v1.11.3
10.5.0.49   Ready                      <none>   25h   v1.11.3

其他节点上新建了3个pod(replicaset实现)

image.png
  • 附:drain之前的pod状态
    • 10.5.0.44 节点存在3个pod
image.png

附-流程图

image.png

参考

相关文章

网友评论

      本文标题:k8s运维-04-重启node机器的过程

      本文链接:https://www.haomeiwen.com/subject/tsnxvqtx.html