Merge pull request #51644 from windsonsea/updmon

[zh] Update DaemonSet examples and docs
pull/51652/head
Kubernetes Prow Robot 2025-07-18 17:12:25 -07:00 committed by GitHub
commit 4f53f104bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 26 additions and 27 deletions

View File

@ -9,7 +9,6 @@ content_type: concept
weight: 40
hide_summary: true # 在章节索引中单独列出
---
<!--
reviewers:
- enisoc
@ -68,16 +67,16 @@ different flags and/or different memory and cpu requests for different hardware
### Create a DaemonSet
-->
## 编写 DaemonSet Spec {#writing-a-daemon-set-spec}
## 编写 DaemonSet 规约 {#writing-a-daemonset-spec}
### 创建 DaemonSet {#create-a-daemon-set}
### 创建 DaemonSet {#create-a-daemonset}
<!--
You can describe a DaemonSet in a YAML file. For example, the `daemonset.yaml` file below
describes a DaemonSet that runs the fluentd-elasticsearch Docker image:
-->
你可以在 YAML 文件中描述 DaemonSet。
例如,下面的 daemonset.yaml 文件描述了一个运行 fluentd-elasticsearch Docker 镜像的 DaemonSet
例如,下面的 `daemonset.yaml` 文件描述了一个运行 fluentd-elasticsearch Docker 镜像的 DaemonSet
{{% code_sample file="controllers/daemonset.yaml" %}}
@ -86,7 +85,7 @@ Create a DaemonSet based on the YAML file:
-->
基于 YAML 文件创建 DaemonSet
```
```shell
kubectl apply -f https://k8s.io/examples/controllers/daemonset.yaml
```
@ -114,7 +113,8 @@ section.
DaemonSet 对象的名称必须是一个合法的
[DNS 子域名](/zh-cn/docs/concepts/overview/working-with-objects/names#dns-subdomain-names)。
DaemonSet 也需要 [`.spec` 部分](https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status)。
DaemonSet 也需要
[`.spec` 部分](https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status)。
<!--
### Pod Template
@ -137,7 +137,7 @@ A Pod Template in a DaemonSet must have a [`RestartPolicy`](/docs/concepts/workl
`.spec.template` 是一个 [Pod 模板](/zh-cn/docs/concepts/workloads/pods/#pod-templates)。
除了它是嵌套的,因而不具有 `apiVersion``kind` 字段之外,它与
{{< glossary_tooltip text="Pod" term_id="pod" >}} 具有相同的 schema
{{< glossary_tooltip text="Pod" term_id="pod" >}} 具有相同的模式
除了 Pod 必需字段外,在 DaemonSet 中的 Pod 模板必须指定合理的标签(查看 [Pod 选择算符](#pod-selector))。
@ -179,7 +179,7 @@ The `.spec.selector` is an object consisting of two fields:
-->
* `matchLabels` - 与 [ReplicationController](/zh-cn/docs/concepts/workloads/controllers/replicationcontroller/)
`.spec.selector` 的作用相同。
* `matchExpressions` - 允许构建更加复杂的选择,可以通过指定 key、value
* `matchExpressions` - 允许构建更加复杂的选择算符,可以通过指定 key、value
列表以及将 key 和 value 列表关联起来的 Operator。
<!--
@ -215,7 +215,7 @@ If you do not specify either, then the DaemonSet controller will create Pods on
<!--
## How Daemon Pods are scheduled
-->
## Daemon Pods 是如何被调度的 {#how-daemon-pods-are-scheduled}
## Daemon Pod 是如何被调度的 {#how-daemon-pods-are-scheduled}
<!--
A DaemonSet can be used to ensure that all eligible nodes run a copy of a Pod.
@ -299,7 +299,7 @@ nodeAffinity:
The DaemonSet controller automatically adds a set of {{< glossary_tooltip
text="tolerations" term_id="toleration" >}} to DaemonSet Pods:
-->
### 污点和容忍度 {#taint-and-toleration}
### 污点和容忍度 {#taints-and-tolerations}
DaemonSet 控制器会自动将一组容忍度添加到 DaemonSet Pod
@ -401,7 +401,7 @@ You can modify the Pods that a DaemonSet creates. However, Pods do not allow al
fields to be updated. Also, the DaemonSet controller will use the original template the next
time a node (even with the same name) is created.
-->
## 更新 DaemonSet {#updating-a-daemon-set}
## 更新 DaemonSet {#updating-a-daemonset}
如果节点的标签被修改DaemonSet 将立刻向新匹配上的节点添加 Pod
同时删除不匹配的节点上的 Pod。
@ -429,7 +429,7 @@ You can [perform a rolling update](/docs/tasks/manage-daemon/update-daemon-set/)
### Init scripts
-->
## DaemonSet 的替代方案 {#alternatives-to-daemon-set}
## DaemonSet 的替代方案 {#alternatives-to-daemonset}
### init 脚本 {#init-scripts}
@ -479,9 +479,9 @@ in cluster bootstrapping cases. Also, static Pods may be deprecated in the futu
-->
### 静态 Pod {#static-pods}
通过在一个指定的、受 `kubelet` 监视的目录下编写文件来创建 Pod 也是可行的。
通过在一个指定的、受 kubelet 监视的目录下编写文件来创建 Pod 也是可行的。
这类 Pod 被称为[静态 Pod](/zh-cn/docs/tasks/configure-pod-container/static-pod/)。
不像 DaemonSet静态 Pod 不受 `kubectl` 和其它 Kubernetes API 客户端管理。
不像 DaemonSet静态 Pod 不受 kubectl 和其它 Kubernetes API 客户端管理。
静态 Pod 不依赖于 API 服务器,这使得它们在启动引导新集群的情况下非常有用。
此外,静态 Pod 在将来可能会被废弃。
@ -501,7 +501,7 @@ For example, [network plugins](/docs/concepts/extend-kubernetes/compute-storage-
often include a component that runs as a DaemonSet. The DaemonSet component makes sure
that the node where it's running has working cluster networking.
-->
### Deployment
### Deployment {#deployments}
DaemonSet 与 [Deployment](/zh-cn/docs/concepts/workloads/controllers/deployment/) 非常类似,
它们都能创建 Pod并且 Pod 中的进程都不希望被终止例如Web 服务器、存储服务器)。
@ -511,10 +511,11 @@ DaemonSet 与 [Deployment](/zh-cn/docs/concepts/workloads/controllers/deployment
当需要 Pod 副本总是运行在全部或特定主机上,并且当该 DaemonSet 提供了节点级别的功能(允许其他 Pod 在该特定节点上正确运行)时,
应该使用 DaemonSet。
例如,[网络插件](/zh-cn/docs/concepts/extend-kubernetes/compute-storage-net/network-plugins/)通常包含一个以 DaemonSet 运行的组件。
这个 DaemonSet 组件确保它所在的节点的集群网络正常工作。
例如,[网络插件](/zh-cn/docs/concepts/extend-kubernetes/compute-storage-net/network-plugins/)通常包含一个以
DaemonSet 运行的组件。这个 DaemonSet 组件确保它所在的节点的集群网络正常工作。
## {{% heading "whatsnext" %}}
<!--
* Learn about [Pods](/docs/concepts/workloads/pods).
* Learn about [static Pods](#static-pods), which are useful for running Kubernetes
@ -531,11 +532,12 @@ DaemonSet 与 [Deployment](/zh-cn/docs/concepts/workloads/controllers/deployment
object definition to understand the API for daemon sets.
-->
* 了解 [Pod](/zh-cn/docs/concepts/workloads/pods)。
* 了解[静态 Pod](#static-pods),这对运行 Kubernetes {{< glossary_tooltip text="控制面" term_id="control-plane" >}}组件有帮助。
* 了解[静态 Pod](#static-pods),这对运行 Kubernetes
{{< glossary_tooltip text="控制面" term_id="control-plane" >}}组件有帮助。
* 了解如何使用 DaemonSet
* [对 DaemonSet 执行滚动更新](/zh-cn/docs/tasks/manage-daemon/update-daemon-set/)
* [对 DaemonSet 执行回滚](/zh-cn/docs/tasks/manage-daemon/rollback-daemon-set/)(例如:新的版本没有达到你的预期)
* 理解[Kubernetes 如何将 Pod 分配给节点](/zh-cn/docs/concepts/scheduling-eviction/assign-pod-node/)。
* 理解 [Kubernetes 如何将 Pod 分配给节点](/zh-cn/docs/concepts/scheduling-eviction/assign-pod-node/)。
* 了解[设备插件](/zh-cn/docs/concepts/extend-kubernetes/compute-storage-net/device-plugins/)和
[扩展Addons](/zh-cn/docs/concepts/cluster-administration/addons/),它们常以 DaemonSet 运行。
* `DaemonSet` 是 Kubernetes REST API 中的顶级资源。阅读 {{< api-reference page="workload-resources/daemon-set-v1" >}}

View File

@ -3,7 +3,6 @@ title: 对 DaemonSet 执行滚动更新
content_type: task
weight: 10
---
<!--
reviewers:
- janetkuo
@ -44,7 +43,6 @@ DaemonSet 有两种更新策略:
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 模板后,只有当你手动删除老的
DaemonSet Pod 之后,新的 DaemonSet Pod **才会**被自动创建。跟 Kubernetes 1.6 以前的版本类似。
* `RollingUpdate`:这是默认的更新策略。使用 `RollingUpdate` 更新策略时,在更新 DaemonSet 模板后,
@ -125,7 +123,7 @@ kubectl get ds/fluentd-elasticsearch -o go-template='{{.spec.updateStrategy.type
If you haven't created the DaemonSet in the system, check your DaemonSet
manifest with the following command instead:
-->
如果还没在系统中创建 DaemonSet请使用以下命令检查 DaemonSet 的清单:
如果还没在系统中创建 DaemonSet请使用以下命令检查 DaemonSet 的清单:
```shell
kubectl apply -f https://k8s.io/examples/controllers/fluentd-daemonset.yaml --dry-run=client -o go-template='{{.spec.updateStrategy.type}}{{"\n"}}'
@ -272,12 +270,12 @@ make room for new DaemonSet pods.
-->
一旦找到这些节点,从节点上删除一些非 DaemonSet Pod为新的 DaemonSet Pod 腾出空间。
{{< note >}}
<!--
This will cause service disruption when deleted pods are not controlled by any controllers or pods are not
replicated. This does not respect [PodDisruptionBudget](/docs/tasks/run-application/configure-pdb/)
either.
-->
{{< note >}}
当所删除的 Pod 不受任何控制器管理,也不是多副本的 Pod 时,上述操作将导致服务中断。
同时,上述操作也不会考虑
[PodDisruptionBudget](/zh-cn/docs/tasks/run-application/configure-pdb/)
@ -335,4 +333,3 @@ kubectl delete ds fluentd-elasticsearch -n kube-system
-->
* 查看[在 DaemonSet 上执行回滚](/zh-cn/docs/tasks/manage-daemon/rollback-daemon-set/)
* 查看[创建 DaemonSet 以收养现有 DaemonSet Pod](/zh-cn/docs/concepts/workloads/controllers/daemonset/)

View File

@ -25,7 +25,7 @@ spec:
effect: NoSchedule
containers:
- name: fluentd-elasticsearch
image: quay.io/fluentd_elasticsearch/fluentd:v2.5.2
image: quay.io/fluentd_elasticsearch/fluentd:v5.0.1
resources:
limits:
memory: 200Mi

View File

@ -29,7 +29,7 @@ spec:
effect: NoSchedule
containers:
- name: fluentd-elasticsearch
image: quay.io/fluentd_elasticsearch/fluentd:v2.5.2
image: quay.io/fluentd_elasticsearch/fluentd:v5.0.1
resources:
limits:
memory: 200Mi

View File

@ -25,7 +25,7 @@ spec:
effect: NoSchedule
containers:
- name: fluentd-elasticsearch
image: quay.io/fluentd_elasticsearch/fluentd:v2.5.2
image: quay.io/fluentd_elasticsearch/fluentd:v5.0.1
volumeMounts:
- name: varlog
mountPath: /var/log