diff --git a/content/zh/docs/tasks/manage-daemon/update-daemon-set.md b/content/zh/docs/tasks/manage-daemon/update-daemon-set.md index ee8bc83eaf..7b6b45772e 100644 --- a/content/zh/docs/tasks/manage-daemon/update-daemon-set.md +++ b/content/zh/docs/tasks/manage-daemon/update-daemon-set.md @@ -12,6 +12,7 @@ content_type: task --> + @@ -28,7 +29,7 @@ This page shows how to perform a rolling update on a DaemonSet. DaemonSet has two update strategy types: --> -## DaemonSet 更新策略 +## DaemonSet 更新策略 {#daemonset-update-strategy} DaemonSet 有两种更新策略: @@ -40,8 +41,8 @@ DaemonSet 有两种更新策略: * `RollingUpdate`: This is the default update strategy. With `RollingUpdate` update strategy, after you update a DaemonSet template, old DaemonSet pods will be killed, and new DaemonSet pods - will be created automatically, in a controlled fashion. - At most one pod of the DaemonSet will be running on each node during the whole update process. + will be created automatically, in a controlled fashion. At most one pod of + the DaemonSet will be running on each node during the whole update process. --> * `OnDelete`: 使用 `OnDelete` 更新策略时,在更新 DaemonSet 模板后,只有当你手动删除老的 @@ -56,16 +57,16 @@ DaemonSet 有两种更新策略: To enable the rolling update feature of a DaemonSet, you must set its `.spec.updateStrategy.type` to `RollingUpdate`. --> -## 执行滚动更新 +## 执行滚动更新 {#performing-a-rolling-update} 要启用 DaemonSet 的滚动更新功能,必须设置 `.spec.updateStrategy.type` 为 `RollingUpdate`。 -### 创建带有 `RollingUpdate` 更新策略的 DaemonSet +### 创建带有 `RollingUpdate` 更新策略的 DaemonSet {#creating-a-daemonset-with-rollingupdate-update-strategy} 下面的 YAML 包含一个 DaemonSet,其更新策略为 'RollingUpdate': @@ -113,7 +114,7 @@ kubectl apply -f https://k8s.io/examples/controllers/fluentd-daemonset.yaml Check the update strategy of your DaemonSet, and make sure it's set to `RollingUpdate`: --> -### 检查 DaemonSet 的滚动更新策略 +### 检查 DaemonSet 的滚动更新策略 {#checking-daemonset-rollingupdate-update-strategy} 首先,检查 DaemonSet 的更新策略,确保已经将其设置为 `RollingUpdate`: @@ -152,7 +153,7 @@ manifest accordingly. Any updates to a `RollingUpdate` DaemonSet `.spec.template` will trigger a rolling update. Let's update the DaemonSet by applying a new YAML file. This can be done with several different `kubectl` commands. --> -### 更新 DaemonSet 模板 +### 更新 DaemonSet 模板 {#updating-a-daemonset-template} 对 `RollingUpdate` DaemonSet 的 `.spec.template` 的任何更新都将触发滚动更新。 这可以通过几个不同的 `kubectl` 命令来完成。 @@ -166,7 +167,7 @@ If you update DaemonSets using [configuration files](/docs/tasks/manage-kubernetes-objects/declarative-config/), use `kubectl apply`: --> -#### 声明式命令 +#### 声明式命令 {#declarative-commands} 如果你使用 [配置文件](/zh/docs/tasks/manage-kubernetes-objects/declarative-config/) @@ -180,14 +181,14 @@ kubectl apply -f https://k8s.io/examples/controllers/fluentd-daemonset-update.ya #### Imperative commands If you update DaemonSets using -[imperative commands](/docs/concepts/overview/object-management-kubectl/imperative-command/), +[imperative commands](/docs/tasks/manage-kubernetes-objects/imperative-command/), use `kubectl edit`: --> -#### 指令式命令 +#### 指令式命令 {#imperative-commands} 如果你使用 [指令式命令](/zh/docs/tasks/manage-kubernetes-objects/imperative-command/) -来更新 DaemonSets,请使用`kubectl edit`: +来更新 DaemonSets,请使用 `kubectl edit`: ```shell kubectl edit ds/fluentd-elasticsearch -n kube-system @@ -199,21 +200,21 @@ kubectl edit ds/fluentd-elasticsearch -n kube-system If you only need to update the container image in the DaemonSet template, i.e. `.spec.template.spec.containers[*].image`, use `kubectl set image`: ---> -##### 只更新容器镜像 +##### 只更新容器镜像 {#updating-only-the-container-image} -如果你只需要更新 DaemonSet 模板里的容器镜像,比如,`.spec.template.spec.containers[*].image`, -请使用 `kubectl set image`: +如果你只需要更新 DaemonSet 模板里的容器镜像,比如 `.spec.template.spec.containers[*].image`, +请使用 `kubectl set image`: ```shell kubectl set image ds/fluentd-elasticsearch fluentd-elasticsearch=quay.io/fluentd_elasticsearch/fluentd:v2.6.0 -n kube-system ``` -### 监视滚动更新状态 +### 监视滚动更新状态 {#watching-the-rolling-update-status} 最后,观察 DaemonSet 最新滚动更新的进度: @@ -235,9 +236,9 @@ daemonset "fluentd-elasticsearch" successfully rolled out ### DaemonSet rolling update is stuck --> -## 故障排查 +## 故障排查 {#troubleshooting} -### DaemonSet 滚动更新卡住 +### DaemonSet 滚动更新卡住 {#daemonset-rolling-update-is-stuck} -#### 不完整的滚动更新 +#### 不完整的滚动更新 {#broken-rollout} 如果最近的 DaemonSet 模板更新被破坏了,比如,容器处于崩溃循环状态或者容器镜像不存在 (通常由于拼写错误),就会发生 DaemonSet 滚动更新中断。 @@ -312,7 +313,7 @@ If `.spec.minReadySeconds` is specified in the DaemonSet, clock skew between master and nodes will make DaemonSet unable to detect the right rollout progress. --> -#### 时钟偏差 +#### 时钟偏差 {#clock-skew} 如果在 DaemonSet 中指定了 `.spec.minReadySeconds`,主控节点和工作节点之间的时钟偏差会使 DaemonSet 无法检测到正确的滚动更新进度。 @@ -322,7 +323,7 @@ DaemonSet 无法检测到正确的滚动更新进度。 Delete DaemonSet from a namespace : --> -## 清理 +## 清理 {#clean-up} 从名字空间中删除 DaemonSet: diff --git a/content/zh/docs/tasks/manage-kubernetes-objects/update-api-object-kubectl-patch.md b/content/zh/docs/tasks/manage-kubernetes-objects/update-api-object-kubectl-patch.md index af9c187e4d..3acc52f7c8 100644 --- a/content/zh/docs/tasks/manage-kubernetes-objects/update-api-object-kubectl-patch.md +++ b/content/zh/docs/tasks/manage-kubernetes-objects/update-api-object-kubectl-patch.md @@ -9,7 +9,7 @@ weight: 50 title: Update API Objects in Place Using kubectl patch description: Use kubectl patch to update Kubernetes API objects in place. Do a strategic merge patch or a JSON merge patch. content_type: task -weight: 40 +weight: 50 --> @@ -34,7 +34,7 @@ in this task demonstrate a strategic merge patch and a JSON merge patch. Here's the configuration file for a Deployment that has two replicas. Each replica is a Pod that has one container: --> -## 使用策略合并 patch 更新 Deployment +## 使用策略合并 patch 更新 Deployment {#use-a-strategic-merge-patch-to-update-a-deployment} 下面是具有两个副本的 Deployment 的配置文件。每个副本是一个 Pod,有一个容器: @@ -46,7 +46,7 @@ Create the Deployment: 创建 Deployment: ```shell -kubectl create -f https://k8s.io/examples/application/deployment-patch.yaml +kubectl apply -f https://k8s.io/examples/application/deployment-patch.yaml ``` -创建一个名为 `patch-file-containers.yaml` 的文件。内容如下: +创建一个名为 `patch-file.yaml` 的文件。内容如下: ```yaml spec: @@ -102,7 +102,7 @@ Patch your Deployment: 修补你的 Deployment: ```shell -kubectl patch deployment patch-demo --patch "$(cat patch-file-containers.yaml)" +kubectl patch deployment patch-demo --patch-file patch-file.yaml ``` -### 策略性合并类的 patch 的说明 +### 策略性合并类的 patch 的说明 {#notes-on-the-strategic-merge-patch} -你在前面的练习中所做的 patch 称为`策略性合并 patch(Strategic Merge Patch)`。 -请注意,patch 没有替换`containers` 列表。相反,它向列表中添加了一个新 Container。换句话说, +你在前面的练习中所做的 patch 称为 `策略性合并 patch(Strategic Merge Patch)`。 +请注意,patch 没有替换 `containers` 列表。相反,它向列表中添加了一个新 Container。换句话说, patch 中的列表与现有列表合并。当你在列表中使用策略性合并 patch 时,并不总是这样。 在某些情况下,列表是替换的,而不是合并的。 @@ -295,7 +295,7 @@ Notice that the `tolerations` list in the PodSpec was replaced, not merged. This the Tolerations field of PodSpec does not have a `patchStrategy` key in its field tag. So the strategic merge patch uses the default patch strategy, which is `replace`. --> -请注意,PodSpec 中的 `tolerations` 列表被替换,而不是合并。这是因为 PodSpec 的 `tolerations` +请注意,PodSpec 中的 `tolerations` 列表被替换,而不是合并。这是因为 PodSpec 的 `tolerations` 的字段标签中没有 `patchStrategy` 键。所以策略合并 patch 操作使用默认的 patch 策略,也就是 `replace`。 ```go @@ -313,7 +313,7 @@ With a JSON merge patch, if you want to update a list, you have to specify the entire new list. And the new list completely replaces the existing list. --> -## 使用 JSON 合并 patch 更新 Deployment +## 使用 JSON 合并 patch 更新 Deployment {#use-a-json-merge-patch-to-update-a-deployment} 策略性合并 patch 不同于 [JSON 合并 patch](https://tools.ietf.org/html/rfc7386)。 使用 JSON 合并 patch,如果你想更新列表,你必须指定整个新列表。新的列表完全取代现有的列表。 @@ -324,11 +324,15 @@ The `kubectl patch` command has a `type` parameter that you can set to one of th `kubectl patch` 命令有一个 `type` 参数,你可以将其设置为以下值之一:
参数值 | 合并类型 |
---|---|
json | JSON Patch, RFC 6902 |
merge | JSON Merge Patch, RFC 7386 |
strategic | 策略合并 patch |