K8S滚动更新守护进程集

Updating a DaemonSet 更新守护进程集

DaemonSets are great for deploying services across an entire cluster, but what about upgrades? Prior to Kubernetes 1.6, the only way to update Pods managed by a DaemonSet was to update the DaemonSet and then manually delete each Pod that was managed by the DaemonSet so that it would be re-created with the new configuration. With the release of Kubernetes 1.6, DaemonSets gained an equivalent to the Deployment object that manages a DaemonSet rollout inside the cluster.

DaemonSet非常适合在整个集群中部署服务,但升级怎么办?在 Kubernetes 1.6 之前,更新由 DaemonSet 管理的 Pod 的唯一方法是更新 DaemonSet,然后手动删除由 DaemonSet 管理的每个 Pod,以便用新配置重新创建 Pod。随着 Kubernetes 1.6 的发布,DaemonSets 获得了一个与部署对象等价的对象,可以在集群内管理 DaemonSet 的推出。

Rolling Update of a DaemonSet 滚动更新守护进程集

DaemonSets can be rolled out using the same RollingUpdate strategy that deployments use. You can configure the update strategy using the spec.updateStrategy.type field, which should have the value RollingUpdate. When a DaemonSet has an update strategy of RollingUpdate, any change to the spec.template field (or subfields) in the DaemonSet will initiate a rolling update.

可以使用与部署相同的 RollingUpdate 策略推出守护进程集。您可以使用 spec.updateStrategy.type 字段配置更新策略,该字段的值应为 RollingUpdate。当 DaemonSet 的更新策略为 RollingUpdate 时,DaemonSet 中 spec.template 字段(或子字段)的任何更改都将启动滚动更新。

As with rolling updates of deployments (see Chapter 10), the RollingUpdate strategy gradually updates members of a DaemonSet until all of the Pods are running the new configuration.

与部署的滚动更新一样(见第 10 章),RollingUpdate 策略会逐步更新 DaemonSet 的成员,直到所有 Pod 都运行新配置。

There are two parameters that control the rolling update of a DaemonSet:

  • spec.minReadySeconds, which determines how long a Pod must be "ready" before the rolling update proceeds to upgrade subsequent Pods
  • spec.updateStrategy.rollingUpdate.maxUna vailable, which indicates how many Pods may be simultaneously updated by the rolling update

有两个参数可以控制 DaemonSet 的滚动更新:

  • spec.minReadySeconds(最小就绪秒数),用于确定在滚动更新继续升级后续 Pod 之前,Pod 必须 "就绪 "多长时间

  • spec.updateStrategy.rollingUpdate.maxUna vailable,表示滚动更新可同时更新多少个 Pod

You will likely want to set spec.minReadySeconds to a reasonably long value, for example 30--60 seconds, to ensure that your Pod is truly healthy before the rollout proceeds.

您可能希望将 spec.minReadySeconds 设置为一个相当长的值,例如 30-60 秒,以确保 Pod 在启动前真正处于健康状态。

The setting for spec.updateStrategy.rollingUpdate.maxUnavailab le is more likely to be application-dependent. Setting it to 1 is a safe, general-purpose strategy, but it also takes a while to complete the rollout (number of nodes × minReadySeconds). Increasing the maximum unavailability will make your rollout move faster, but increases the "blast radius" of a failed rollout. The characteristics of your application and cluster environment dictate the relative values of speed versus safety. A good approach might be to set maxUnavailable to 1 and only increase it if users or administrators complain about DaemonSet rollout speed.

spec.updateStrategy.rollingUpdate.maxUnavailab le 的设置更可能取决于应用。将其设置为 1 是一种安全的通用策略,但也需要一段时间才能完成滚动(节点数 × minReadySeconds)。增加最大不可用时间会使推出速度更快,但会增加推出失败的 "爆炸半径"。应用程序和群集环境的特性决定了速度与安全的相对值。一个好的方法可能是将 maxUnavailable 设置为 1,只有在用户或管理员抱怨 DaemonSet 推出速度时才增加它。

Once a rolling update has started, you can use the kubectl rollout commands to see the current status of a DaemonSet rollout.

启动滚动更新后,可以使用 kubectl rollout 命令查看 DaemonSet 滚动的当前状态。

For example, kubectl rollout status daemonSets mydaemon-set will show the current rollout status of a DaemonSet named my-daemon-set.

例如,kubectl rollout status daemonSets mydaemon-set 将显示名为 my-daemon-set 的 DaemonSet 的当前启动状态。

相关推荐
赵谨言3 小时前
红蓝对抗Docker渗透复盘-技能与产出汇总
docker·容器·eureka
打工仔折腾 AI8 小时前
飞牛OS上用Docker Compose部署ExerciseDiary运动记录并配置远程访问
运维·人工智能·后端·python·docker·容器·ai agent 实战
天衍四九-8 小时前
Docker Compose企业实战系列(八·终章):多环境隔离实战,开发/测试/生产一键切换
运维·docker·容器
ysu_031410 小时前
Docker-Desktop-WSL2实战指南-Windows从安装配置到项目容器化
windows·python·docker·容器·composer·dockerfile·wsl2
陈陈CHENCHEN11 小时前
【Kubernetes】纯 IPv6 K8s 集群访问外部 IPv4 服务
云原生·容器·kubernetes
明王明王11 小时前
从零搭建一个 AI Infra 实验室⑫:Docker 为什么默认看不到 GPU
人工智能·docker·容器
天衍四九-11 小时前
Docker Compose企业实战系列(四):Redis生产级部署|密码加固、持久化、内存优化完整方案
redis·docker·容器
troy12811 小时前
如何在谷歌云(Google Cloud)上部署 Kubernetes 集群
云原生·容器·kubernetes
xiaoligangting11 小时前
太原岗亭款式齐全
云原生
guo_wen_qiang12 小时前
docker安装常见软件集合
运维·docker·容器