[英]Kubernetes: Update all pods in parallel
Is there any way to perform an update action on all pods simultaneously?有没有办法同时对所有 pod 执行更新操作?
We have a process running in kubernetes as a stateful set where we want to update all the pods at the same time.我们有一个在 kubernetes 中运行的进程作为有状态集,我们希望同时更新所有 pod。 We cannot seem to find a configuration for that.我们似乎无法为此找到配置。 I am aware of rollingUpdate
, which only updates one pod at a time.我知道rollingUpdate
,它一次只更新一个 pod。
This is what we have currently这是我们目前拥有的
updateStrategy:
rollingUpdate:
partition: 2
type: RollingUpdate
I also tried with maxUnavailable
, but still did not work.我也尝试使用maxUnavailable
,但仍然没有用。 Is there any other hack to get this done?有没有其他技巧可以完成这项工作?
There is no native alternative for updating all pods simultaneously when using Statefulsets.使用 Statefulsets 时,没有本地替代方法可以同时更新所有 pod。
The closest thing to it is to use the Parallel Pod Management policy , but it only affects the behavior for scaling operations (including initial setup) and doesn't work for updates.最接近它的是使用Parallel Pod Management 策略,但它只影响扩展操作的行为(包括初始设置),不适用于更新。
Although, the OpenKruise project has an extended component suite that enables Advanced StatefulSet to update workflow.虽然,OpenKruise 项目有一个扩展的组件套件,它使Advanced StatefulSet能够更新工作流。
Here is a minimal working example that will upgrade all pods at once :这是一个最小的工作示例,它将一次升级所有 pod :
apiVersion: apps.kruise.io/v1beta1
kind: StatefulSet
metadata:
name: sample
spec:
replicas: 5
serviceName: fake-service
selector:
matchLabels:
app: sample
template:
metadata:
labels:
app: sample
spec:
readinessGates:
- conditionType: InPlaceUpdateReady
containers:
- name: main
image: nginx:alpine
podManagementPolicy: Parallel
updateStrategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 100%
Note this will certainly cause downtime , but you can adjust to something like maxUnavailable: 50%
to make it more resilient.请注意,这肯定会导致downtime ,但您可以调整为maxUnavailable: 50%
以使其更具弹性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.