Skip to content

Commit a4ebb5a

Browse files
authored
Merge pull request #42585 from windsonsea/confile
[zh] sync kubelet-config-file.md
2 parents 2cc2460 + 686c1b7 commit a4ebb5a

File tree

1 file changed

+103
-20
lines changed

1 file changed

+103
-20
lines changed

content/zh-cn/docs/tasks/administer-cluster/kubelet-config-file.md

Lines changed: 103 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
---
2-
title: 通过配置文件设置 Kubelet 参数
2+
title: 通过配置文件设置 kubelet 参数
33
content_type: task
44
weight: 330
55
---
66
<!--
77
reviewers:
88
- mtaufen
99
- dawnchen
10-
title: Set Kubelet parameters via a config file
10+
title: Set Kubelet Parameters Via A Configuration File
1111
content_type: task
1212
weight: 330
1313
--->
1414

1515
<!-- overview -->
1616

1717
<!--
18-
A subset of the Kubelet's configuration parameters may be
18+
A subset of the kubelet's configuration parameters may be
1919
set via an on-disk config file, as a substitute for command-line flags.
2020
--->
2121
通过保存在硬盘的配置文件设置 kubelet 的部分配置参数,这可以作为命令行参数的替代。
@@ -31,26 +31,26 @@ it simplifies node deployment and configuration management.
3131
<!--
3232
## Create the config file
3333
34-
The subset of the Kubelet's configuration that can be configured via a file
34+
The subset of the kubelet's configuration that can be configured via a file
3535
is defined by the
3636
[`KubeletConfiguration`](/docs/reference/config-api/kubelet-config.v1beta1/)
3737
struct.
3838
-->
3939
## 创建配置文件 {#create-config-file}
4040

4141
[`KubeletConfiguration`](/zh-cn/docs/reference/config-api/kubelet-config.v1beta1/)
42-
结构体定义了可以通过文件配置的 Kubelet 配置子集,
42+
结构体定义了可以通过文件配置的 kubelet 配置子集,
4343

4444
<!--
4545
The configuration file must be a JSON or YAML representation of the parameters
46-
in this struct. Make sure the Kubelet has read permissions on the file.
46+
in this struct. Make sure the kubelet has read permissions on the file.
4747
4848
Here is an example of what this file might look like:
4949
-->
5050
配置文件必须是这个结构体中参数的 JSON 或 YAML 表现形式。
5151
确保 kubelet 可以读取该文件。
5252

53-
下面是一个 Kubelet 配置文件示例:
53+
下面是一个 kubelet 配置文件示例:
5454

5555
```yaml
5656
apiVersion: kubelet.config.k8s.io/v1beta1
@@ -63,13 +63,13 @@ evictionHard:
6363
```
6464
6565
<!--
66-
In the example, the Kubelet is configured to serve on IP address 192.168.0.8 and port 20250, pull images in parallel,
66+
In the example, the kubelet is configured to serve on IP address 192.168.0.8 and port 20250, pull images in parallel,
6767
and evict Pods when available memory drops below 200Mi. Since only one of the four evictionHard thresholds is configured,
6868
other evictionHard thresholds are reset to 0 from their built-in defaults.
69-
All other Kubelet configuration values are left at their built-in defaults, unless overridden
69+
All other kubelet configuration values are left at their built-in defaults, unless overridden
7070
by flags. Command line flags which target the same value as a config file will override that value.
7171
-->
72-
在这个示例中, Kubelet 被设置为在地址 192.168.0.8 端口 20250 上提供服务,以并行方式拉取镜像,
72+
在这个示例中, kubelet 被设置为在地址 192.168.0.8 端口 20250 上提供服务,以并行方式拉取镜像,
7373
当可用内存低于 200Mi 时, kubelet 将会开始驱逐 Pod。
7474
由于仅配置了四个 evictionHard 阈值之一,因此其他 evictionHard 阈值被重置为 0,而不是使用其内置默认值。
7575
没有声明的其余配置项都将使用默认值,除非使用命令行参数来重载。
@@ -87,9 +87,9 @@ the threshold values respectively.
8787
{{< /note >}}
8888
8989
<!--
90-
## Start a Kubelet process configured via the config file
90+
## Start a kubelet process configured via the config file
9191
--->
92-
## 启动通过配置文件配置的 Kubelet 进程 {#start-kubelet-via-config-file}
92+
## 启动通过配置文件配置的 kubelet 进程 {#start-kubelet-via-config-file}
9393
9494
{{< note >}}
9595
<!--
@@ -101,10 +101,10 @@ See [configuring kubelet using kubeadm](/docs/setup/production-environment/tools
101101
{{< /note >}}
102102

103103
<!--
104-
Start the Kubelet with the `--config` flag set to the path of the Kubelet's config file.
105-
The Kubelet will then load its config from this file.
104+
Start the kubelet with the `--config` flag set to the path of the kubelet's config file.
105+
The kubelet will then load its config from this file.
106106
-->
107-
启动 Kubelet 需要将 `--config` 参数设置为 Kubelet 配置文件的路径。Kubelet 将从此文件加载其配置。
107+
启动 kubelet 需要将 `--config` 参数设置为 kubelet 配置文件的路径。kubelet 将从此文件加载其配置。
108108

109109
<!--
110110
Note that command line flags which target the same value as a config file will override that value.
@@ -114,23 +114,106 @@ This helps ensure backwards compatibility with the command-line API.
114114
这有助于确保命令行 API 的向后兼容性。
115115

116116
<!--
117-
Note that relative file paths in the Kubelet config file are resolved relative to the
118-
location of the Kubelet config file, whereas relative paths in command line flags are resolved
119-
relative to the Kubelet's current working directory.
117+
Note that relative file paths in the kubelet config file are resolved relative to the
118+
location of the kubelet config file, whereas relative paths in command line flags are resolved
119+
relative to the kubelet's current working directory.
120120
-->
121121
请注意,kubelet 配置文件中的相对文件路径是相对于 kubelet 配置文件的位置解析的,
122122
而命令行参数中的相对路径是相对于 kubelet 的当前工作目录解析的。
123123

124124
<!--
125-
Note that some default values differ between command-line flags and the Kubelet config file.
125+
Note that some default values differ between command-line flags and the kubelet config file.
126126
If `--config` is provided and the values are not specified via the command line, the
127127
defaults for the `KubeletConfiguration` version apply.
128128
In the above example, this version is `kubelet.config.k8s.io/v1beta1`.
129129
--->
130-
请注意,命令行参数和 Kubelet 配置文件的某些默认值不同。
130+
请注意,命令行参数和 kubelet 配置文件的某些默认值不同。
131131
如果设置了 `--config`,并且没有通过命令行指定值,则 `KubeletConfiguration`
132132
版本的默认值生效。在上面的例子中,version 是 `kubelet.config.k8s.io/v1beta1`。
133133

134+
<!--
135+
## Drop-in directory for kubelet configuration files {#kubelet-conf-d}
136+
137+
As of Kubernetes v1.28.0, the Kubelet has been extended to support a drop-in configuration directory. The location of it can be specified with
138+
`--config-dir` flag, and it defaults to `""`, or disabled, by default.
139+
-->
140+
## kubelet 配置文件的插件目录 {#kubelet-conf-d}
141+
142+
自 Kubernetes v1.28.0 起,kubelet 被扩展以支持一个插件配置目录。
143+
该目录的位置可以使用 `--config-dir` 标志来指定,默认为 `""`,也就是被禁用状态。
144+
145+
<!--
146+
You can only set `--config-dir` if you set the environment variable `KUBELET_CONFIG_DROPIN_DIR_ALPHA` for the kubelet process (the value of that variable does not matter).
147+
For Kubernetes v{{< skew currentVersion >}}, the kubelet returns an error if you specify `--config-dir` without that variable set, and startup fails.
148+
You cannot specify the drop-in configuration directory using the kubelet configuration file; only the CLI argument `--config-dir` can set it.
149+
-->
150+
只有在为 kubelet 进程设置环境变量 `KUBELET_CONFIG_DROPIN_DIR_ALPHA`
151+
(该变量的值无关紧要)时才可以设置 `--config-dir`。对于 Kubernetes v{{< skew currentVersion >}},
152+
如果你未设置该变量而指定了 `--config-dir`,kubelet 将返回错误并且启动失败。
153+
你不能使用 kubelet 配置文件指定插件配置目录;只能使用 CLI 参数 `--config-dir` 进行设置。
154+
155+
<!--
156+
One can use the kubelet configuration directory in a similar way to the kubelet config file.
157+
-->
158+
你可以以类似于 kubelet 配置文件的方式使用 kubelet 配置目录。
159+
160+
{{< note >}}
161+
<!--
162+
The suffix of a valid kubelet drop-in configuration file must be `.conf`. For instance: `99-kubelet-address.conf`
163+
-->
164+
合法的 kubelet 插件配置文件的后缀必须为 `.conf`。例如 `99-kubelet-address.conf`。
165+
{{< /note >}}
166+
167+
<!--
168+
For instance, you may want a baseline kubelet configuration for all nodes, but you may want to customize the `address` field. This can be done as follows:
169+
170+
Main kubelet configuration file contents:
171+
-->
172+
例如,你可能想要为所有节点设置一个基准的 kubelet 配置,但你可能想要自定义 `address` 字段。
173+
可以按如下方式操作:
174+
175+
kubelet 配置文件的主要内容如下:
176+
177+
```yaml
178+
apiVersion: kubelet.config.k8s.io/v1beta1
179+
kind: KubeletConfiguration
180+
port: 20250
181+
serializeImagePulls: false
182+
evictionHard:
183+
memory.available: "200Mi"
184+
```
185+
186+
<!--
187+
Contents of a file in `--config-dir` directory:
188+
-->
189+
`--config-dir` 目录中某个文件的内容如下:
190+
191+
```yaml
192+
apiVersion: kubelet.config.k8s.io/v1beta1
193+
kind: KubeletConfiguration
194+
address: "192.168.0.8"
195+
```
196+
197+
<!--
198+
On startup, the kubelet merges configuration from:
199+
200+
* Command line arguments (lowest precedence).
201+
* the kubelet configuration
202+
* Drop-in configuration files, according to sort order.
203+
* Feature gates specified over the command line (highest precedence).
204+
-->
205+
在启动时,kubelet 会合并来自以下几部分的配置:
206+
207+
* 命令行参数(优先级最低)。
208+
* kubelet 配置文件。
209+
* 排序的插件配置文件。
210+
* 在命令行中指定的特性门控(优先级最高)。
211+
212+
<!--
213+
This produces the same outcome as if you used the [single configuration file](#create-the-config-file) used in the earlier example.
214+
-->
215+
这将产生与之前示例中使用的[单个配置文件](#create-the-config-file)相同的结果。
216+
134217
<!-- discussion -->
135218

136219
## {{% heading "whatsnext" %}}

0 commit comments

Comments
 (0)