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 的当前启动状态。

相关推荐
人工干智能1 小时前
科普:“docker”与“docker compose”
运维·docker·容器
神马都会亿点点的毛毛张1 小时前
【Docker教程】万字长文详解Docker命令
java·运维·后端·docker·容器
Anna_Tong2 小时前
阿里云 ACS:高效、弹性、低成本的容器计算解决方案
人工智能·阿里云·容器·kubernetes·serverless·云计算·devops
魏 无羡3 小时前
k8s ssl 漏洞修复
容器·kubernetes·ssl
ITPUB-微风4 小时前
云原生监控体系建设:Kubernetes架构下的全面监控策略
云原生·架构·kubernetes
hjnjmjkj4 小时前
基于windows的docker-desktop安装kubenetes以及dashboard
docker·容器·kubernetes
Libby博仙4 小时前
docker 改了镜像源为阿里云,还是下载失败
阿里云·docker·容器
钗头风5 小时前
3.Docker常用命令
运维·docker·容器
ITPUB-微风7 小时前
网易严选DevOps实践:从传统到云原生的演进
运维·云原生·devops
桂月二二7 小时前
基于eBPF的全栈可观测性系统:重新定义云原生环境诊断范式
云原生