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

相关推荐
東雪蓮☆9 分钟前
K8s 平滑升级
linux·运维·云原生·kubernetes
我狸才不是赔钱货3 小时前
容器:软件世界的标准集装箱
linux·运维·c++·docker·容器
三坛海会大神5555 小时前
k8s(十)Helm详解
云原生·容器·kubernetes
安卓开发者5 小时前
Docker命令大全:从入门到精通
docker·容器·eureka
K_i1346 小时前
Kubernetes流量管理:从Ingress到GatewayAPI演进
云原生·容器·kubernetes
蓝色土耳其love7 小时前
centos 7.9 安装单机版k8s
linux·运维·服务器·kubernetes·centos
七度光阴;8 小时前
Docker入门手册
运维·docker·容器
007php00710 小时前
百度面试题解析:Zookeeper、ArrayList、生产者消费者模型及多线程(二)
java·分布式·zookeeper·云原生·职场和发展·eureka·java-zookeeper
weixin_4050233710 小时前
使用docker 安装部署easy-mock
运维·docker·容器
Asuncion00710 小时前
Docker核心揭秘:轻量级虚拟化的革命
服务器·开发语言·docker·云原生