Skip to content

Commit 5ebe87b

Browse files
authored
Merge pull request #46058 from windsonsea/dirmer
[zh] Add kubelet-config-directory-merging.md
2 parents e1ca4c8 + 2f5c21a commit 5ebe87b

File tree

1 file changed

+223
-0
lines changed

1 file changed

+223
-0
lines changed
Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
---
2+
content_type: "reference"
3+
title: kubelet 配置目录合并
4+
weight: 50
5+
---
6+
<!--
7+
content_type: "reference"
8+
title: Kubelet Configuration Directory Merging
9+
weight: 50
10+
-->
11+
12+
<!--
13+
When using the kubelet's `--config-dir` flag to specify a drop-in directory for
14+
configuration, there is some specific behavior on how different types are
15+
merged.
16+
17+
Here are some examples of how different data types behave during configuration merging:
18+
-->
19+
当使用 kubelet 的 `--config-dir` 标志来指定存放配置的目录时,不同类型的配置会有一些特定的行为。
20+
21+
以下是在配置合并过程中不同数据类型的一些行为示例:
22+
23+
<!--
24+
### Structure Fields
25+
26+
There are two types of structure fields in a YAML structure: singular (or a
27+
scalar type) and embedded (structures that contain scalar types).
28+
The configuration merging process handles the overriding of singular and embedded struct fields to create a resulting kubelet configuration.
29+
-->
30+
### 结构字段 {#structure-fields}
31+
32+
在 YAML 结构中有两种结构字段:独立(标量类型)和嵌入式(此结构包含标量类型)。
33+
配置合并过程将处理独立构造字段和嵌入式构造字段的重载,以创建最终的 kubelet 配置。
34+
35+
<!--
36+
For instance, you may want a baseline kubelet configuration for all nodes, but you may want to customize the `address` and `authorization` fields.
37+
This can be done as follows:
38+
39+
Main kubelet configuration file contents:
40+
-->
41+
例如,你可能想要为所有节点设置一个基准 kubelet 配置,但希望自定义 `address``authorization` 字段。
42+
这种情况下,你可以按以下方式完成:
43+
44+
kubelet 主配置文件内容:
45+
46+
```yaml
47+
apiVersion: kubelet.config.k8s.io/v1beta1
48+
kind: KubeletConfiguration
49+
port: 20250
50+
authorization:
51+
mode: Webhook
52+
webhook:
53+
cacheAuthorizedTTL: "5m"
54+
cacheUnauthorizedTTL: "30s"
55+
serializeImagePulls: false
56+
address: "192.168.0.1"
57+
```
58+
59+
<!--
60+
Contents of a file in `--config-dir` directory:
61+
-->
62+
`--config-dir` 目录中文件的内容:
63+
64+
```yaml
65+
apiVersion: kubelet.config.k8s.io/v1beta1
66+
kind: KubeletConfiguration
67+
authorization:
68+
mode: AlwaysAllow
69+
webhook:
70+
cacheAuthorizedTTL: "8m"
71+
cacheUnauthorizedTTL: "45s"
72+
address: "192.168.0.8"
73+
```
74+
75+
<!--
76+
The resulting configuration will be as follows:
77+
-->
78+
生成的配置如下所示:
79+
80+
```yaml
81+
apiVersion: kubelet.config.k8s.io/v1beta1
82+
kind: KubeletConfiguration
83+
port: 20250
84+
serializeImagePulls: false
85+
authorization:
86+
mode: AlwaysAllow
87+
webhook:
88+
cacheAuthorizedTTL: "8m"
89+
cacheUnauthorizedTTL: "45s"
90+
address: "192.168.0.8"
91+
```
92+
93+
<!--
94+
### Lists
95+
You can overide the slices/lists values of the kubelet configuration.
96+
However, the entire list gets overridden during the merging process.
97+
For example, you can override the `clusterDNS` list as follows:
98+
99+
Main kubelet configuration file contents:
100+
-->
101+
### 列表 {#lists}
102+
103+
你可以重载 kubelet 配置的切片/列表值。
104+
但在合并过程中整个列表将被重载。
105+
例如,你可以按以下方式重载 `clusterDNS` 列表:
106+
107+
kubelet 主配置文件的内容:
108+
109+
```yaml
110+
apiVersion: kubelet.config.k8s.io/v1beta1
111+
kind: KubeletConfiguration
112+
port: 20250
113+
serializeImagePulls: false
114+
clusterDNS:
115+
- "192.168.0.9"
116+
- "192.168.0.8"
117+
```
118+
119+
<!--
120+
Contents of a file in `--config-dir` directory:
121+
-->
122+
`--config-dir` 目录中文件的内容:
123+
124+
```yaml
125+
apiVersion: kubelet.config.k8s.io/v1beta1
126+
kind: KubeletConfiguration
127+
clusterDNS:
128+
- "192.168.0.2"
129+
- "192.168.0.3"
130+
- "192.168.0.5"
131+
```
132+
133+
<!--
134+
The resulting configuration will be as follows:
135+
-->
136+
生成的配置如下所示:
137+
138+
```yaml
139+
apiVersion: kubelet.config.k8s.io/v1beta1
140+
kind: KubeletConfiguration
141+
port: 20250
142+
serializeImagePulls: false
143+
clusterDNS:
144+
- "192.168.0.2"
145+
- "192.168.0.3"
146+
- "192.168.0.5"
147+
```
148+
149+
<!--
150+
### Maps, including Nested Structures
151+
152+
Individual fields in maps, regardless of their value types (boolean, string, etc.), can be selectively overridden.
153+
However, for `map[string][]string`, the entire list associated with a specific field gets overridden.
154+
Let's understand this better with an example, particularly on fields like `featureGates` and `staticPodURLHeader`:
155+
156+
Main kubelet configuration file contents:
157+
-->
158+
### 含嵌套结构的映射 {#maps-including-nested-structures}
159+
160+
映射中的各个字段(无论其值类型是布尔值、字符串等)都可以被选择性地重载。
161+
但对于 `map[string][]string` 类型来说,与特定字段关联的整个列表都将被重载。
162+
让我们通过一个例子更好地理解这一点,特别是 `featureGates` 和 `staticPodURLHeader` 这类字段:
163+
164+
kubelet 主配置文件的内容:
165+
166+
```yaml
167+
apiVersion: kubelet.config.k8s.io/v1beta1
168+
kind: KubeletConfiguration
169+
port: 20250
170+
serializeImagePulls: false
171+
featureGates:
172+
AllAlpha: false
173+
MemoryQoS: true
174+
staticPodURLHeader:
175+
kubelet-api-support:
176+
- "Authorization: 234APSDFA"
177+
- "X-Custom-Header: 123"
178+
custom-static-pod:
179+
- "Authorization: 223EWRWER"
180+
- "X-Custom-Header: 456"
181+
```
182+
183+
<!--
184+
Contents of a file in `--config-dir` directory:
185+
-->
186+
`--config-dir` 目录中文件的内容:
187+
188+
```yaml
189+
apiVersion: kubelet.config.k8s.io/v1beta1
190+
kind: KubeletConfiguration
191+
featureGates:
192+
MemoryQoS: false
193+
KubeletTracing: true
194+
DynamicResourceAllocation: true
195+
staticPodURLHeader:
196+
custom-static-pod:
197+
- "Authorization: 223EWRWER"
198+
- "X-Custom-Header: 345"
199+
```
200+
201+
<!--
202+
The resulting configuration will be as follows:
203+
-->
204+
生成的配置如下所示:
205+
206+
```yaml
207+
apiVersion: kubelet.config.k8s.io/v1beta1
208+
kind: KubeletConfiguration
209+
port: 20250
210+
serializeImagePulls: false
211+
featureGates:
212+
AllAlpha: false
213+
MemoryQoS: false
214+
KubeletTracing: true
215+
DynamicResourceAllocation: true
216+
staticPodURLHeader:
217+
kubelet-api-support:
218+
- "Authorization: 234APSDFA"
219+
- "X-Custom-Header: 123"
220+
custom-static-pod:
221+
- "Authorization: 223EWRWER"
222+
- "X-Custom-Header: 345"
223+
```

0 commit comments

Comments
 (0)