【问题标题】:Pods not moved on host failure主机故障时 Pod 未移动
【发布时间】:2020-05-11 16:34:59
【问题描述】:

我已经根据《Kuberenetes Up & Running》一书结合官方文档为自己设置了一个在 Ubuntu 上运行的简单 1 主节点和 3 节点设置。

它基本上可以工作,直到我关闭 worker 节点之一。 几秒钟后,节点运行状态切换到unknown。 即使 Pod 位于离线节点上,Pod 也会保持报告状态 running

k8s 不应该将这些 pod 移动到不同的健康主机吗? 我错过了什么吗?

感谢您的建议!

【问题讨论】:

标签: kubernetes


【解决方案1】:

在 Kubernetes 1.13 及更高版本中,节点故障/未就绪条件下的 pod 驱逐实际上由 taints 和 tolerations 控制。 --pod-eviction-timeout 参数不再使用。

当一个节点宕机或未准备好时,node-controller/kubelet 将向节点添加以下污点 - node.kubernetes.io/unreachablenode.kubernetes.io/not-ready。默认情况下,所有 pod 都会容忍这些污点 300 秒。您可以为所有带有 kube-api-server 标志的 pod 以及每个 pod 使用 pod 规范中的 tolerations 对象控制此容忍时间集群范围。

集群范围配置:

您可以使用--default-not-ready-toleration-seconds--default-unreachable-toleration-seconds 标志将容忍时间集群范围修改为kube-api-server

来自docs:

--default-not-ready-toleration-seconds int     Default: 300
Indicates the tolerationSeconds of the toleration for notReady:NoExecute that is added by default to every pod that does not already have such a toleration.
--default-unreachable-toleration-seconds int     Default: 300

每个 pod 配置:

您还可以使用以下配置修改每个 pod 的容忍时间。

tolerations:
  - key: "node.kubernetes.io/unreachable"
    operator: "Exists"
    effect: "NoExecute"
    tolerationSeconds: 120
  - key: "node.kubernetes.io/not-ready"
    operator: "Exists"
    effect: "NoExecute"
    tolerationSeconds: 120

https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/#taint-based-evictions

【讨论】:

    【解决方案2】:

    默认情况下,Pod 在 5m 分钟内不会移动,这可以通过控制器管理器上的以下标志 --pod-eviction-timeout duration 进行配置。

    5 分钟后,如果它仍然没有发生(有状态集),您需要使用 kubectl delete node 删除节点,这将触发节点上 Pod 的重新调度。

    从 Kubernetes 版本 1.13 及更高版本开始,节点故障/未就绪条件下的 pod 驱逐由污点和容忍度控制。 --pod-eviction-timeout 参数被忽略。

    集群范围的配置可以通过 kubelet 参数进行配置。

    --default-not-ready-toleration-seconds int     Default: 300Indicates the tolerationSeconds of the toleration for notReady:NoExecute that is added by default to every pod that does not already have such a me toleration.
    
    --default-unreachable-toleration-seconds int     Default: 300Indicates the tolerationSeconds of the toleration for unreachable:NoExecute that is added by default to every pod that does not already have such a toleration.
    

    如果你想在POD级别管理这个属性,你可以添加tolerations。

    spec:
      tolerations:
      - key: "node.kubernetes.io/unreachable"
        operator: "Exists"
        effect: "NoExecute"
        tolerationSeconds: 30
      - key: "node.kubernetes.io/not-ready"
        operator: "Exists"
        effect: "NoExecute"
        tolerationSeconds: 30
    

    查看相关issue

    https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/#taint-based-evictions

    【讨论】:

    • 其实 - 我想我太不耐烦了。谢谢@arghya-sadhu
    【解决方案3】:

    我能够使用此script 来解决此问题,以强制排空任何已进入未就绪状态超过 5 分钟(可调整)的节点,然后它将在节点返回后解除警戒线。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-08
      • 1970-01-01
      • 2016-03-12
      • 2013-01-07
      • 1970-01-01
      • 2016-03-19
      • 2018-09-14
      • 1970-01-01
      相关资源
      最近更新 更多