Kubernetes PodDisruptionBudget、Horizo​​ntalPodAutoscaler 和 RollingUpdate 交互?

Kubernetes PodDisruptionBudget, HorizontalPodAutoscaler & RollingUpdate Interaction?

如果我有以下 Kubernetes 对象:

如果集群负载不足并且正在扩展,会发生什么:

  1. 在滚动更新期间?由于扩大规模而添加的新 Pod 是否使用新版本的 Pod
  2. 什么时候需要重启或更换节点? PodDisruptionBudget 是否完全停止重启? HorizontalPodAutoscaler 是否在关闭另一个节点之前增加节点数量?
  3. Pod 亲和力设置为避免将来自相同 Deployment 的两个 Pod 放置在同一节点上时。
  1. documentation

Pods which are deleted or unavailable due to a rolling upgrade to an application do count against the disruption budget, but controllers (like deployment and stateful-set) are not limited by PDBs when doing rolling upgrades – the handling of failures during application updates is configured in the controller spec.

所以它部分取决于控制器配置和实现。我相信自动缩放器添加的新 pods 将使用新版本的 Pod,因为那是当时部署定义中存在的版本。

  1. 这取决于您执行节点重启的方式。如果你只是切断电源,什么也做不了;)如果你在关闭节点之前执行适当的 drain,那么 PodDisruptionBudget 将被考虑在内并且排水过程不会违反它。 Eviction API 遵守中断预算,但可能会因手动 pod 删除等低级操作而违反。它更像是一些 API 尊重的建议,而不是整个 Kubernetes 强制执行的强制限制。

  2. 根据official documentation,如果affinity设置为"soft",那么pods无论如何都会被调度到同一个节点上。如果是 "hard",则部署将卡住,无法安排所需数量的 pods。滚动更新仍然是可能的,但 HPA 将无法再增加 pod 池。