立即将 Kubernetes Statefulset/Deployment 扩展至满容量

Immediately scale up Kubernetes Statefulset/Deployment to full capacity

目前我们将其中一个状态集扩展为拥有 11 个副本。我们当前的更新策略是

updateStrategy:
  type: RollingUpdate

如果我们从头开始部署有状态集,Kubernetes 会一个接一个地启动它们。启动一个副本需要大约 5 分钟。所以我们总共等待 55 分钟才填满容量。

有没有办法在从头开始时立即填满容量?这样所有 11 个副本将同时启动?

由于故障安全,应该通过 RollingUpdate 处理对现有 statefulset 的升级。

最良好的祝愿, 斯蒂芬

我不这么认为。 StatefulSets 的设计是为了安全高于一切,因此控制器一次操作一个 pod。

我们找到了隐藏在文档深处的答案:

https://kubernetes.io/docs/tutorials/stateful-application/basic-stateful-set/#parallel-pod-management

https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#pod-management-policies

Pod Management Policies

In Kubernetes 1.7 and later, StatefulSet allows you to relax its ordering guarantees while preserving its uniqueness and identity guarantees via its .spec.podManagementPolicy field.

OrderedReady Pod Management

OrderedReady pod management is the default for StatefulSets. It implements the behavior described above.

Parallel Pod Management

Parallel pod management tells the StatefulSet controller to launch or terminate all Pods in parallel, and to not wait for Pods to become Running and Ready or completely terminated prior to launching or terminating another Pod. This option only affects the behavior for scaling operations. Updates are not affected.