Skip to content

Commit

Permalink
[zh-cn]sync kubelet-config-file inject-data-application/* manage-daem…
Browse files Browse the repository at this point in the history
…on/*

Signed-off-by: xin.li <xin.li@daocloud.io>
  • Loading branch information
my-git9 committed Oct 17, 2023
1 parent 0082100 commit 1ce0830
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 42 deletions.
42 changes: 31 additions & 11 deletions content/zh-cn/docs/tasks/administer-cluster/kubelet-config-file.md
Expand Up @@ -59,21 +59,35 @@ address: "192.168.0.8"
port: 20250
serializeImagePulls: false
evictionHard:
memory.available: "200Mi"
memory.available: "100Mi"
nodefs.available: "10%"
nodefs.inodesFree: "5%"
imagefs.available: "15%"
```

<!--
In the example, the kubelet is configured to serve on IP address 192.168.0.8 and port 20250, pull images in parallel,
and evict Pods when available memory drops below 200Mi. Since only one of the four evictionHard thresholds is configured,
other evictionHard thresholds are reset to 0 from their built-in defaults.
All other kubelet configuration values are left at their built-in defaults, unless overridden
by flags. Command line flags which target the same value as a config file will override that value.
In this example, the kubelet is configured with the following settings:
-->
在此示例中,kubelet 配置为以下设置:

<!--
1. `address`: The kubelet will serve on IP address `192.168.0.8`.
2. `port`: The kubelet will serve on port `20250`.
3. `serializeImagePulls`: Image pulls will be done in parallel.
4. `evictionHard`: The kubelet will evict Pods under one of the following conditions:
- When the node's available memory drops below 100MiB.
- When the node's main filesystem's available space is less than 10%.
- When the image filesystem's available space is less than 15%.
- When more than 95% of the node's main filesystem's inodes are in use.
-->
在这个示例中, kubelet 被设置为在地址 192.168.0.8 端口 20250 上提供服务,以并行方式拉取镜像,
当可用内存低于 200Mi 时, kubelet 将会开始驱逐 Pod。
由于仅配置了四个 evictionHard 阈值之一,因此其他 evictionHard 阈值被重置为 0,而不是使用其内置默认值。
没有声明的其余配置项都将使用默认值,除非使用命令行参数来重载。
命令行中的参数将会覆盖配置文件中的对应值。
1. `address`:kubelet 将在 `192.168.0.8` IP 地址上提供服务。
2. `port`:kubelet 将在 `20250` 端口上提供服务。
3. `serializeImagePulls`:并行拉取镜像。
4. `evictionHard`:kubelet 将在以下情况之一驱逐 Pod:
- 当节点的可用内存降至 100MiB 以下时。
- 当节点主文件系统的已使用 inode 超过 95%。
- 当镜像文件系统的可用空间小于 15% 时。
- 当节点主文件系统的 inode 超过 95% 正在使用时。

{{< note >}}
<!--
Expand All @@ -86,6 +100,12 @@ the threshold values respectively.
其他参数的默认值将不会被继承,他们会被设置为零。如果要提供自定义值,你应该分别设置所有阈值。
{{< /note >}}

<!--
The `imagefs` is an optional filesystem that container runtimes use to store container
images and container writable layers.
-->
`imagefs` 是一个可选的文件系统,容器运行时使用它来存储容器镜像和容器可写层。

<!--
## Start a kubelet process configured via the config file
--->
Expand Down
Expand Up @@ -80,7 +80,7 @@ Pod:
本示例中,将创建一个只包含单个容器的 Pod。此 Pod 的配置文件中设置环境变量的名称为 `DEMO_GREETING`
其值为 `"Hello from the environment"`。下面是此 Pod 的配置清单:

{{< codenew file="pods/inject/envars.yaml" >}}
{{% code_sample file="pods/inject/envars.yaml" %}}

<!--
1. Create a Pod based on that manifest:
Expand Down
Expand Up @@ -24,7 +24,9 @@ in a Kubernetes Pod.
<!--
## Define an environment dependent variable for a container
When you create a Pod, you can set dependent environment variables for the containers that run in the Pod. To set dependent environment variables, you can use $(VAR_NAME) in the `value` of `env` in the configuration file.
When you create a Pod, you can set dependent environment variables for the containers
that run in the Pod. To set dependent environment variables, you can use $(VAR_NAME)
in the `value` of `env` in the configuration file.
In this exercise, you create a Pod that runs one container. The configuration
file for the Pod defines a dependent environment variable with common usage defined. Here is the configuration manifest for the
Expand All @@ -39,7 +41,7 @@ Pod:
此 Pod 的配置文件定义了一个已定义常用用法的相互依赖的环境变量。
下面是此 Pod 的配置清单:

{{< codenew file="pods/inject/dependent-envars.yaml" >}}
{{% code_sample file="pods/inject/dependent-envars.yaml" %}}

<!--
1. Create a Pod based on that manifest:
Expand Down Expand Up @@ -82,7 +84,8 @@ Pod:
```

<!--
As shown above, you have defined the correct dependency reference of `SERVICE_ADDRESS`, bad dependency reference of `UNCHANGED_REFERENCE` and skip dependent references of `ESCAPED_REFERENCE`.
As shown above, you have defined the correct dependency reference of `SERVICE_ADDRESS`,
bad dependency reference of `UNCHANGED_REFERENCE` and skip dependent references of `ESCAPED_REFERENCE`.
When an environment variable is already defined when being referenced,
the reference can be correctly resolved, such as in the `SERVICE_ADDRESS` case.
Expand All @@ -104,7 +107,10 @@ fails to resolve `$(PROTOCOL)` in the example above.
这就是为什么 `UNCHANGED_REFERENCE` 在上面的示例中解析 `$(PROTOCOL)` 失败的原因。

<!--
When the environment variable is undefined or only includes some variables, the undefined environment variable is treated as a normal string, such as `UNCHANGED_REFERENCE`. Note that incorrectly parsed environment variables, in general, will not block the container from starting.
When the environment variable is undefined or only includes some variables,
the undefined environment variable is treated as a normal string, such as
`UNCHANGED_REFERENCE`. Note that incorrectly parsed environment variables,
in general, will not block the container from starting.
The `$(VAR_NAME)` syntax can be escaped with a double `$`, ie: `$$(VAR_NAME)`.
Escaped references are never expanded, regardless of whether the referenced variable
Expand All @@ -126,4 +132,3 @@ is defined or not. This can be seen from the `ESCAPED_REFERENCE` case above.
-->
* 进一步了解[环境变量](/zh-cn/docs/tasks/inject-data-application/environment-variable-expose-pod-information/)
* 参阅 [EnvVarSource](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#envvarsource-v1-core)。

Expand Up @@ -65,7 +65,7 @@ username and password:

这里是一个配置文件,可以用来创建存有用户名和密码的 Secret:

{{% code file="pods/inject/secret.yaml" %}}
{{% code_sample file="pods/inject/secret.yaml" %}}

<!--
1. Create the Secret
Expand Down Expand Up @@ -154,7 +154,7 @@ Here is a configuration file you can use to create a Pod:

这里是一个可以用来创建 Pod 的配置文件:

{{% code file="pods/inject/secret-pod.yaml" %}}
{{% code_sample file="pods/inject/secret-pod.yaml" %}}

1. <!-- Create the Pod:-->
创建 Pod:
Expand Down Expand Up @@ -398,7 +398,7 @@ secrets change.
-->
- 在 Pod 规约中,将 Secret 中定义的值 `backend-username` 赋给 `SECRET_USERNAME` 环境变量。

{{% code file="pods/inject/pod-single-secret-env-variable.yaml" %}}
{{% code_sample file="pods/inject/pod-single-secret-env-variable.yaml" %}}

<!--
- Create the Pod:
Expand Down Expand Up @@ -447,7 +447,7 @@ secrets change.
-->
- 在 Pod 规约中定义环境变量:

{{% code file="pods/inject/pod-multiple-secret-env-variable.yaml" %}}
{{% code_sample file="pods/inject/pod-multiple-secret-env-variable.yaml" %}}

<!--
- Create the Pod:
Expand Down Expand Up @@ -505,7 +505,7 @@ This functionality is available in Kubernetes v1.6 and later.
- 使用 `envFrom` 来将 Secret 中的所有数据定义为环境变量。
Secret 中的键名成为容器中的环境变量名:

{{% code file="pods/inject/pod-secret-envFrom.yaml" %}}
{{% code_sample file="pods/inject/pod-secret-envFrom.yaml" %}}

<!--
- Create the Pod:
Expand Down
Expand Up @@ -56,7 +56,7 @@ Here is the manifest for the Pod:
在这部分的练习中,你将创建一个包含一个容器的 Pod,并将 Pod 级别的字段作为文件投射到正在运行的容器中。
Pod 的清单如下:

{{< codenew file="pods/inject/dapi-volume.yaml" >}}
{{% code_sample file="pods/inject/dapi-volume.yaml" %}}

<!--
In the manifest, you can see that the Pod has a `downwardAPI` Volume,
Expand Down Expand Up @@ -148,7 +148,7 @@ In your shell, view the `labels` file:
The output shows that all of the Pod's labels have been written
to the `labels` file:
-->
输出显示 Pod 的所有标签都已写入 `labels` 文件
输出显示 Pod 的所有标签都已写入 `labels` 文件

```
cluster="test-cluster1"
Expand Down Expand Up @@ -245,7 +245,7 @@ just one container:
但这些字段取自特定[容器](/zh-cn/docs/reference/kubernetes-api/workload-resources/pod-v1/#Container)而不是整个 Pod。
下面是一个同样只有一个容器的 Pod 的清单:

{{< codenew file="pods/inject/dapi-volume-resources.yaml" >}}
{{% code_sample file="pods/inject/dapi-volume-resources.yaml" %}}

<!--
In the manifest, you can see that the Pod has a
Expand Down Expand Up @@ -355,4 +355,3 @@ Read about volumes in the legacy API reference:
* 参阅
[`ResourceFieldSelector`](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#resourcefieldselector-v1-core)
API 定义,该 API 指定容器资源及其输出格式。

Expand Up @@ -60,7 +60,7 @@ project Pod-level fields into the running container as environment variables.

在这部分练习中,你将创建一个包含一个容器的 Pod。并将 Pod 级别的字段作为环境变量投射到正在运行的容器中。

{{< codenew file="pods/inject/dapi-envars-pod.yaml" >}}
{{% code_sample file="pods/inject/dapi-envars-pod.yaml" %}}

<!--
In that manifest, you can see five environment variables. The `env`
Expand Down Expand Up @@ -185,7 +185,7 @@ Here is a manifest for another Pod that again has just one container:

这里是只包含一个容器的 Pod 的清单:

{{< codenew file="pods/inject/dapi-envars-container.yaml" >}}
{{% code_sample file="pods/inject/dapi-envars-container.yaml" %}}

<!--
In this manifest, you can see four environment variables. The `env`
Expand Down Expand Up @@ -271,4 +271,3 @@ Read about Pods, containers and environment variables in the legacy API referenc
* [EnvVarSource](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#envvarsource-v1-core)
* [ObjectFieldSelector](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#objectfieldselector-v1-core)
* [ResourceFieldSelector](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#resourcefieldselector-v1-core)

9 changes: 6 additions & 3 deletions content/zh-cn/docs/tasks/manage-daemon/pods-some-nodes.md
Expand Up @@ -12,7 +12,9 @@ weight: 30
<!-- overview -->

<!--
This page demonstrates how can you run {{<glossary_tooltip term_id="pod" text="Pods">}} on only some {{<glossary_tooltip term_id="node" text="Nodes">}} as part of a {{<glossary_tooltip term_id="daemonset" text="DaemonSet">}}
This page demonstrates how can you run {{<glossary_tooltip term_id="pod" text="Pods">}}
on only some {{<glossary_tooltip term_id="node" text="Nodes">}} as part of a
{{<glossary_tooltip term_id="daemonset" text="DaemonSet">}}
-->
本页演示了你如何能够仅在某些{{<glossary_tooltip term_id="node" text="节点">}}上作为
{{<glossary_tooltip term_id="daemonset" text="DaemonSet">}}
Expand Down Expand Up @@ -51,7 +53,8 @@ kubectl label nodes example-node-1 example-node-2 ssd=true
<!--
### Step 2: Create the manifest
Let's create a {{<glossary_tooltip term_id="daemonset" text="DaemonSet">}} which will provision the daemon pods on the SSD labeled {{<glossary_tooltip term_id="node" text="nodes">}} only.
Let's create a {{<glossary_tooltip term_id="daemonset" text="DaemonSet">}} which
will provision the daemon pods on the SSD labeled {{<glossary_tooltip term_id="node" text="nodes">}} only.
Next, use a `nodeSelector` to ensure that the DaemonSet only runs Pods on nodes
with the `ssd` label set to `"true"`.
Expand All @@ -63,7 +66,7 @@ with the `ssd` label set to `"true"`.

接下来,使用 `nodeSelector` 确保 DaemonSet 仅在 `ssd` 标签设为 `"true"` 的节点上运行 Pod。

{{<codenew file="controllers/daemonset-label-selector.yaml">}}
{{% code_sample file="controllers/daemonset-label-selector.yaml" %}}

<!--
### Step 3: Create the DaemonSet
Expand Down
20 changes: 10 additions & 10 deletions content/zh-cn/docs/tasks/manage-daemon/update-daemon-set.md
Expand Up @@ -45,9 +45,9 @@ DaemonSet 有两种更新策略:
the DaemonSet will be running on each node during the whole update process.
-->

* `OnDelete`: 使用 `OnDelete` 更新策略时,在更新 DaemonSet 模板后,只有当你手动删除老的
DaemonSet pods 之后,新的 DaemonSet Pod **才会**被自动创建。跟 Kubernetes 1.6 以前的版本类似。
* `RollingUpdate`: 这是默认的更新策略。使用 `RollingUpdate` 更新策略时,在更新 DaemonSet 模板后,
* `OnDelete`使用 `OnDelete` 更新策略时,在更新 DaemonSet 模板后,只有当你手动删除老的
DaemonSet Pod 之后,新的 DaemonSet Pod **才会**被自动创建。跟 Kubernetes 1.6 以前的版本类似。
* `RollingUpdate`这是默认的更新策略。使用 `RollingUpdate` 更新策略时,在更新 DaemonSet 模板后,
老的 DaemonSet Pod 将被终止,并且将以受控方式自动创建新的 DaemonSet Pod。
更新期间,最多只能有 DaemonSet 的一个 Pod 运行于每个节点上。

Expand All @@ -71,8 +71,8 @@ You may want to set
(defaults to 0) as well.
-->
你可能想设置
[`.spec.updateStrategy.rollingUpdate.maxUnavailable`](/zh-cn/docs/reference/kubernetes-api/workload-resources/daemon-set-v1/#DaemonSetSpec) (默认为 1),
[`.spec.minReadySeconds`](/zh-cn/docs/reference/kubernetes-api/workload-resources/daemon-set-v1/#DaemonSetSpec) (默认为 0)
[`.spec.updateStrategy.rollingUpdate.maxUnavailable`](/zh-cn/docs/reference/kubernetes-api/workload-resources/daemon-set-v1/#DaemonSetSpec)默认为 1)、
[`.spec.minReadySeconds`](/zh-cn/docs/reference/kubernetes-api/workload-resources/daemon-set-v1/#DaemonSetSpec)默认为 0
[`.spec.updateStrategy.rollingUpdate.maxSurge`](/zh-cn/docs/reference/kubernetes-api/workload-resources/daemon-set-v1/#DaemonSetSpec)
(默认为 0)。

Expand All @@ -85,7 +85,7 @@ This YAML file specifies a DaemonSet with an update strategy as 'RollingUpdate'

下面的 YAML 包含一个 DaemonSet,其更新策略为 'RollingUpdate':

{{< codenew file="controllers/fluentd-daemonset.yaml" >}}
{{% code_sample file="controllers/fluentd-daemonset.yaml" %}}

<!--
After verifying the update strategy of the DaemonSet manifest, create the DaemonSet:
Expand Down Expand Up @@ -115,7 +115,7 @@ Check the update strategy of your DaemonSet, and make sure it's set to
-->
### 检查 DaemonSet 的滚动更新策略 {#checking-daemonset-rollingupdate-update-strategy}

首先,检查 DaemonSet 的更新策略,确保已经将其设置为 `RollingUpdate`:
首先,检查 DaemonSet 的更新策略,确保已经将其设置为 `RollingUpdate`

```shell
kubectl get ds/fluentd-elasticsearch -o go-template='{{.spec.updateStrategy.type}}{{"\n"}}' -n kube-system
Expand Down Expand Up @@ -157,7 +157,7 @@ update. Let's update the DaemonSet by applying a new YAML file. This can be done
`RollingUpdate` DaemonSet 的 `.spec.template` 的任何更新都将触发滚动更新。
这可以通过几个不同的 `kubectl` 命令来完成。

{{< codenew file="controllers/fluentd-daemonset-update.yaml" >}}
{{% code_sample file="controllers/fluentd-daemonset-update.yaml" %}}

<!--
#### Declarative commands
Expand Down Expand Up @@ -278,7 +278,7 @@ replicated. This does not respect [PodDisruptionBudget](/docs/tasks/run-applicat
either.
-->
{{< note >}}
当所删除的 Pod 不受任何控制器管理,也不是多副本的 Pod时,上述操作将导致服务中断。
当所删除的 Pod 不受任何控制器管理,也不是多副本的 Pod 时,上述操作将导致服务中断。
同时,上述操作也不会考虑
[PodDisruptionBudget](/zh-cn/docs/tasks/run-application/configure-pdb/)
所施加的约束。
Expand Down Expand Up @@ -317,7 +317,7 @@ DaemonSet 无法检测到正确的滚动更新进度。
<!--
## Clean up
Delete DaemonSet from a namespace :
Delete DaemonSet from a namespace:
-->
## 清理 {#clean-up}

Expand Down

0 comments on commit 1ce0830

Please sign in to comment.