Skip to content

Commit 28ca4eb

Browse files
authored
Merge pull request #29546 from mengjiao-liu/sync-1.22-kubeadm-part2
[zh] Setup files to sync for 1.22(kubeadm part-2)
2 parents 2b27d92 + 57deb4f commit 28ca4eb

File tree

1 file changed

+248
-33
lines changed

1 file changed

+248
-33
lines changed
Lines changed: 248 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,123 @@
11
---
2-
title: 使用 kubeadm 定制控制平面配置
2+
title: 使用 kubeadm API 定制组件
33
content_type: concept
44
weight: 40
55
---
66
<!--
77
---
88
reviewers:
99
- sig-cluster-lifecycle
10-
title: Customizing control plane configuration with kubeadm
10+
title: Customizing components with the kubeadm API
1111
content_type: concept
1212
weight: 40
1313
---
1414
-->
1515

1616
<!-- overview -->
1717

18+
<!--
19+
This page covers how to customize the components that kubeadm deploys. For control plane components
20+
you can use flags in the `ClusteConfiguration` structure or patches per-node. For the kubelet
21+
and kube-proxy you can use `KubeletConfiguration` and `KubeProxyConfiguration`, accordingly.
22+
23+
All of these options are possible via the kubeadm configuration API.
24+
For more details on each field in the configuration you can navigate to our
25+
[API reference pages](https://godoc.org/k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3).
26+
-->
27+
本页面介绍了如何自定义 kubeadm 部署的组件。
28+
你可以使用 `ClusteConfiguration` 结构中定义的参数,或者在每个节点上应用补丁来定制控制平面组件。
29+
你可以使用 `KubeletConfiguration``KubeProxyConfiguration` 结构分别定制 kubelet 和 kube-proxy 组件。
30+
31+
所有这些选项都可以通过 kubeadm 配置 API 实现。
32+
有关配置中的每个字段的详细信息,你可以导航到我们的
33+
[API 参考页面](/docs/reference/config-api/kubeadm-config.v1beta3/)
34+
35+
{{< note >}}
36+
<!--
37+
Customizing the CoreDNS deployment of kubeadm is currently not supported. You must manually
38+
patch the `kube-system/coredns` {{< glossary_tooltip text="ConfigMap" term_id="configmap" >}}
39+
and recreate the CoreDNS {{< glossary_tooltip text="Pods" term_id="pod" >}} after that. Alternatively,
40+
you can skip the default CoreDNS deployment and deploy your own variant.
41+
For more details on that see [Using init phases with kubeadm](/docs/reference/setup-tools/kubeadm/kubeadm-init/#init-phases).
42+
-->
43+
kubeadm 目前不支持对 CoreDNS 部署进行定制。
44+
你必须手动更新 `kube-system/coredns` {{< glossary_tooltip text="ConfigMap" term_id="configmap" >}}
45+
并在更新后重新创建 CoreDNS {{< glossary_tooltip text="Pods" term_id="pod" >}}。
46+
或者,你可以跳过默认的 CoreDNS 部署并部署你自己的 CoreDNS 变种。
47+
有关更多详细信息,请参阅[在 kubeadm 中使用 init phases](/zh/docs/reference/setup-tools/kubeadm/kubeadm-init/#init-phases).
48+
{{< /note >}}
49+
50+
<!-- body -->
51+
1852
{{< feature-state for_k8s_version="1.12" state="stable" >}}
1953

2054
<!--
21-
The kubeadm `ClusterConfiguration` object exposes the field `extraArgs` that can override the default flags passed to control plane
22-
components such as the APIServer, ControllerManager and Scheduler. The components are defined using the following fields:
55+
## Customizing the control plane with flags in `ClusterConfiguration`
56+
57+
The kubeadm `ClusterConfiguration` object exposes a way for users to override the default
58+
flags passed to control plane components such as the APIServer, ControllerManager, Scheduler and Etcd.
59+
The components are defined using the following structures:
2360
-->
24-
kubeadm `ClusterConfiguration` 对象公开了 `extraArgs` 字段,它可以覆盖传递给控制平面组件(如 APIServer、ControllerManager 和 Scheduler)的默认参数。各组件配置使用如下字段定义:
61+
## 使用 `ClusterConfiguration` 中的标志自定义控制平面 {#customizing-the-control-plane-with-flags-in-clusterconfiguration}
62+
63+
kubeadm `ClusterConfiguration` 对象为用户提供了一种方法,
64+
用以覆盖传递给控制平面组件(如 APIServer、ControllerManager、Scheduler 和 Etcd)的默认参数。
65+
各组件配置使用如下字段定义:
2566

2667
- `apiServer`
2768
- `controllerManager`
2869
- `scheduler`
70+
- `etcd`
2971

3072
<!--
31-
The `extraArgs` field consist of `key: value` pairs. To override a flag for a control plane component:
73+
These structures contain a common `extraArgs` field, that consists of `key: value` pairs.
74+
To override a flag for a control plane component:
3275
-->
33-
`extraArgs` 字段由 `key: value` 对组成
34-
要覆盖控制平面组件的参数:
76+
这些结构包含一个通用的 `extraArgs` 字段,该字段由 `key: value` 组成
77+
要覆盖控制平面组件的参数
3578

3679
<!--
37-
1. Add the appropriate field to your configuration.
38-
2. Add the flags to override to the field.
80+
1. Add the appropriate `extraArgs` to your configuration.
81+
2. Add flags to the `extraArgs` field.
3982
3. Run `kubeadm init` with `--config <YOUR CONFIG YAML>`.
4083
-->
41-
1. 将适当的字段添加到配置中
42-
2. 向字段添加要覆盖的参数值
84+
1. 将适当的字段 `extraArgs` 添加到配置中
85+
2. 向字段 `extraArgs` 添加要覆盖的参数值
4386
3.`--config <YOUR CONFIG YAML>` 运行 `kubeadm init`
4487

45-
<!--
46-
For more details on each field in the configuration you can navigate to our
47-
[API reference pages](https://godoc.org/k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2#ClusterConfiguration).
88+
{{< note >}}
89+
<!--
90+
You can generate a `ClusterConfiguration` object with default values by running `kubeadm config print init-defaults`
91+
and saving the output to a file of your choice.
4892
-->
49-
有关配置中的每个字段的详细信息,您可以导航到我们的 [API 参考页面](https://godoc.org/k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2#ClusterConfiguration)
93+
你可以通过运行 `kubeadm config print init-defaults` 并将输出保存到你所选的文件中,
94+
以默认值形式生成 `ClusterConfiguration` 对象。
95+
{{< /note >}}
5096

5197
{{< note >}}
5298
<!--
53-
You can generate a `ClusterConfiguration` object with default values by running `kubeadm config print init-defaults` and saving the output to a file of your choice.
99+
The `ClusterConfiguration` object is currently global in kubeadm clusters. This means that any flags that you add,
100+
will apply to all instances of the same component on different nodes. To apply individual configuration per component
101+
on different nodes you can use [patches](#patches).
54102
-->
55-
您可以通过运行 `kubeadm config print init-defaults` 并将输出保存到您选择的文件中,以默认值形式生成 `ClusterConfiguration` 对象。
103+
`ClusterConfiguration` 对象目前在 kubeadm 集群中是全局的。
104+
这意味着你添加的任何标志都将应用于同一组件在不同节点上的所有实例。
105+
要在不同节点上为每个组件应用单独的配置,您可以使用[补丁](#patches)
56106
{{< /note >}}
57107

58-
59-
60-
<!-- body -->
108+
{{< note >}}
109+
<!--
110+
Duplicate flags (keys), or passing the same flag `--foo` multiple times, is currently not supported.
111+
To workaround that you must use [patches](#patches).
112+
-->
113+
当前不支持重复的参数(keys)或多次传递相同的参数 `--foo`
114+
要解决此问题,你必须使用[补丁](#patches)
115+
{{< /note >}}
61116

62117
<!--
63118
## APIServer flags
64119
-->
65-
## APIServer 参数
120+
### APIServer 参数 {#apiserver-flags}
66121

67122
<!--
68123
For details, see the [reference documentation for kube-apiserver](/docs/reference/command-line-tools-reference/kube-apiserver/).
@@ -74,12 +129,11 @@ Example usage:
74129
-->
75130
使用示例:
76131
```yaml
77-
apiVersion: kubeadm.k8s.io/v1beta2
132+
apiVersion: kubeadm.k8s.io/v1beta3
78133
kind: ClusterConfiguration
79134
kubernetesVersion: v1.16.0
80135
apiServer:
81136
extraArgs:
82-
advertise-address: 192.168.0.103
83137
anonymous-auth: "false"
84138
enable-admission-plugins: AlwaysPullImages,DefaultStorageClass
85139
audit-log-path: /home/johndoe/audit.log
@@ -88,7 +142,7 @@ apiServer:
88142
<!--
89143
## ControllerManager flags
90144
-->
91-
## ControllerManager 参数
145+
### ControllerManager 参数 {#controllermanager-flags}
92146
93147
<!--
94148
For details, see the [reference documentation for kube-controller-manager](/docs/reference/command-line-tools-reference/kube-controller-manager/).
@@ -100,20 +154,19 @@ Example usage:
100154
-->
101155
使用示例:
102156
```yaml
103-
apiVersion: kubeadm.k8s.io/v1beta2
157+
apiVersion: kubeadm.k8s.io/v1beta3
104158
kind: ClusterConfiguration
105159
kubernetesVersion: v1.16.0
106160
controllerManager:
107161
extraArgs:
108162
cluster-signing-key-file: /home/johndoe/keys/ca.key
109-
bind-address: 0.0.0.0
110163
deployment-controller-sync-period: "50"
111164
```
112165
113166
<!--
114-
## Scheduler flags
167+
### Scheduler flags
115168
-->
116-
## Scheduler 参数
169+
## Scheduler 参数 {#scheduler-flags}
117170
118171
<!--
119172
For details, see the [reference documentation for kube-scheduler](/docs/reference/command-line-tools-reference/kube-scheduler/).
@@ -125,14 +178,176 @@ Example usage:
125178
-->
126179
使用示例:
127180
```yaml
128-
apiVersion: kubeadm.k8s.io/v1beta2
181+
apiVersion: kubeadm.k8s.io/v1beta3
129182
kind: ClusterConfiguration
130183
kubernetesVersion: v1.16.0
131184
scheduler:
132185
extraArgs:
133-
bind-address: 0.0.0.0
134-
config: /home/johndoe/schedconfig.yaml
135-
kubeconfig: /home/johndoe/kubeconfig.yaml
186+
config: /etc/kubernetes/scheduler-config.yaml
187+
extraVolumes:
188+
- name: schedulerconfig
189+
hostPath: /home/johndoe/schedconfig.yaml
190+
mountPath: /etc/kubernetes/scheduler-config.yaml
191+
readOnly: true
192+
pathType: "File"
193+
```
194+
<!--
195+
### Etcd flags
196+
197+
For details, see the [etcd server documentation](https://etcd.io/docs/).
198+
199+
Example usage:
200+
-->
201+
### Etcd 参数 {#etcd-flags}
202+
203+
有关详细信息,请参阅 [etcd 服务文档](https://etcd.io/docs/).
204+
205+
使用示例:
206+
207+
```yaml
208+
apiVersion: kubeadm.k8s.io/v1beta3
209+
kind: ClusterConfiguration
210+
etcd:
211+
local:
212+
extraArgs:
213+
election-timeout: 1000
136214
```
215+
<!--
216+
## Customizing the control plane with patches {#patches}
217+
218+
{{< feature-state for_k8s_version="v1.22" state="beta" >}}
219+
220+
Kubeadm allows you to pass a directory with patch files to `InitConfiguration` and `JoinConfiguration`
221+
on individual nodes. These patches can be used as the last customization step before the control
222+
plane component manifests are written to disk.
223+
224+
You can pass this file to `kubeadm init` with `--config <YOUR CONFIG YAML>`:
225+
-->
226+
## 使用补丁定制控制平面 {#patches}
227+
228+
{{< feature-state for_k8s_version="v1.22" state="beta" >}}
229+
230+
Kubeadm 允许将包含补丁文件的目录传递给各个节点上的 `InitConfiguration` 和 `JoinConfiguration`。
231+
这些补丁可被用作控制平面组件清单写入磁盘之前的最后一个自定义步骤。
232+
233+
可以使用 `--config <你的 YAML 格式控制文件>` 将配置文件传递给 `kubeadm init`:
234+
235+
```yaml
236+
apiVersion: kubeadm.k8s.io/v1beta3
237+
kind: InitConfiguration
238+
nodeRegistration:
239+
patches:
240+
directory: /home/user/somedir
241+
```
242+
243+
{{< note >}}
244+
<!--
245+
For `kubeadm init` you can pass a file containing both a `ClusterConfiguration` and `InitConfiguration`
246+
separated by `---`.
247+
-->
248+
对于 `kubeadm init`,你可以传递一个包含 `ClusterConfiguration` 和 `InitConfiguration` 的文件,以 `---` 分隔。
249+
{{< /note >}}
250+
251+
<!--
252+
You can pass this file to `kubeadm join` with `--config <YOUR CONFIG YAML>`:
253+
-->
254+
你可以使用 `--config <你的 YAML 格式配置文件>` 将配置文件传递给 `kubeadm join`:
255+
256+
```yaml
257+
apiVersion: kubeadm.k8s.io/v1beta3
258+
kind: JoinConfiguration
259+
nodeRegistration:
260+
patches:
261+
directory: /home/user/somedir
262+
```
263+
264+
<!--
265+
The directory must contain files named `target[suffix][+patchtype].extension`.
266+
For example, `kube-apiserver0+merge.yaml` or just `etcd.json`.
267+
-->
268+
补丁目录必须包含名为 `target[suffix][+patchtype].extension` 的文件。
269+
例如,`kube-apiserver0+merge.yaml` 或只是 `etcd.json`。
270+
271+
<!--
272+
- `target` can be one of `kube-apiserver`, `kube-controller-manager`, `kube-scheduler` and `etcd`.
273+
- `patchtype` can be one of `strategic`, `merge` or `json` and these must match the patching formats
274+
[supported by kubectl](/docs/tasks/manage-kubernetes-objects/update-api-object-kubectl-patch).
275+
The default `patchtype` is `strategic`.
276+
- `extension` must be either `json` or `yaml`.
277+
- `suffix` is an optional string that can be used to determine which patches are applied first
278+
alpha-numerically.
279+
-->
280+
- `target` 可以是 `kube-apiserver`、`kube-controller-manager`、`kube-scheduler` 和 `etcd` 之一。
281+
- `patchtype` 可以是 `strategy`、`merge` 或 `json` 之一,并且这些必须匹配
282+
[kubectl 支持](/zh/docs/tasks/manage-kubernetes-objects/update-api-object-kubectl-patch) 的补丁格式。
283+
默认补丁类型是 `strategic` 的。
284+
- `extension` 必须是 `json` 或 `yaml`。
285+
- `suffix` 是一个可选字符串,可用于确定首先按字母数字应用哪些补丁。
286+
287+
{{< note >}}
288+
<!--
289+
If you are using `kubeadm upgrade` to upgrade your kubeadm nodes you must again provide the same
290+
patches, so that the customization is preserved after upgrade. To do that you can use the `--patches`
291+
flag, which must point to the same directory. `kubeadm upgrade` currently does not support a configuration
292+
API structure that can be used for the same purpose.
293+
-->
294+
如果你使用 `kubeadm upgrade` 升级 kubeadm 节点,你必须再次提供相同的补丁,以便在升级后保留自定义配置。
295+
为此,你可以使用 `--patches` 参数,该参数必须指向同一目录。 `kubeadm upgrade` 目前不支持用于相同目的的 API 结构配置。
296+
{{< /note >}}
297+
298+
<!--
299+
## Customizing the kubelet
300+
301+
To customize the kubelet you can add a `KubeletConfiguration` next to the `ClusterConfiguration` or
302+
`InitConfiguration` separated by `---` within the same configuration file. This file can then be passed to `kubeadm init`.
303+
-->
304+
## 自定义 kubelet {#customizing-the-kubelet}
305+
306+
要自定义 kubelet,你可以在同一配置文件中的 `ClusterConfiguration` 或 `InitConfiguration`
307+
之外添加一个 `KubeletConfiguration`,用 `---` 分隔。
308+
然后可以将此文件传递给 `kubeadm init`。
309+
310+
{{< note >}}
311+
<!--
312+
kubeadm applies the same `KubeletConfiguration` to all nodes in the cluster. To apply node
313+
specific settings you can use kubelet flags as overrides by passing them in the `nodeRegistration.kubeletExtraArgs`
314+
field supported by both `InitConfiguration` and `JoinConfiguration`. Some kubelet flags are deprecated,
315+
so check their status in the [kubelet reference documentation](/docs/reference/command-line-tools-reference/kubelet)
316+
before using them.
317+
-->
318+
kubeadm 将相同的 `KubeletConfiguration` 配置应用于集群中的所有节点。
319+
要应用节点特定设置,你可以使用 `kubelet` 参数进行覆盖,方法是将它们传递到 `InitConfiguration` 和 `JoinConfiguration`
320+
支持的 `nodeRegistration.kubeletExtraArgs` 字段中。一些 kubelet 参数已被弃用,
321+
因此在使用这些参数之前,请在 [kubelet 参考文档](/zh/docs/reference/command-line-tools-reference/kubelet) 中检查它们的状态。
322+
{{< /note >}}
323+
324+
<!--
325+
For more details see [Configuring each kubelet in your cluster using kubeadm](/docs/setup/production-environment/tools/kubeadm/kubelet-integration)
326+
-->
327+
更多详情,请参阅[使用 kubeadm 配置集群中的每个 kubelet](/zh/docs/setup/production-environment/tools/kubeadm/kubelet-integration)
328+
329+
<!--
330+
## Customizing kube-proxy
331+
332+
To customize kube-proxy you can pass a `KubeProxyConfiguration` next your `ClusterConfiguration` or
333+
`InitConfiguration` to `kubeadm init` separated by `---`.
334+
335+
For more details you can navigate to our [API reference pages](https://godoc.org/k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3).
336+
-->
337+
## 自定义 kube-proxy {#customizing-kube-proxy}
338+
339+
要自定义 kube-proxy,你可以在 `ClusterConfiguration` 或 `InitConfiguration` 之外添加一个
340+
由 `---` 分隔的 `KubeProxyConfiguration`, 传递给 `kubeadm init`。
341+
342+
可以导航到 [API 参考页面](/docs/reference/config-api/kubeadm-config.v1beta3/) 查看更多详情,
343+
344+
{{< note >}}
345+
<!--
346+
kubeadm deploys kube-proxy as a {{< glossary_tooltip text="DaemonSet" term_id="daemonset" >}}, which means
347+
that the `KubeProxyConfiguration` would apply to all instances of kube-proxy in the cluster.
348+
-->
349+
kubeadm 将 kube-proxy 部署为 {{< glossary_tooltip text="DaemonSet" term_id="daemonset" >}},
350+
这意味着 `KubeProxyConfiguration` 将应用于集群中的所有 kube-proxy 实例。
351+
{{< /note >}}
137352

138353

0 commit comments

Comments
 (0)