Skip to content

Commit f288fc6

Browse files
committed
kubeadm/control-plane-flags: update the page to include general details
- Re-purpose the page to include more general details about customizing components. - Add details about using patches via the config API (v1.22 feature).
1 parent fa3efa1 commit f288fc6

File tree

1 file changed

+139
-17
lines changed

1 file changed

+139
-17
lines changed
Lines changed: 139 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,106 @@
11
---
22
reviewers:
33
- sig-cluster-lifecycle
4-
title: Customizing control plane configuration with kubeadm
4+
title: Customizing components with the kubeadm API
55
content_type: concept
66
weight: 40
77
---
88

99
<!-- overview -->
1010

11+
This page covers how to customize the components that kubeadm deploys. For control plane components
12+
you can use flags in the `ClusteConfiguration` structure or patches per-node. For the kubelet
13+
and kube-proxy you can use `KubeletConfiguration` and `KubeProxyConfiguration`, accordingly.
14+
15+
All of these options are possible via the kubeadm configuration API.
16+
For more details on each field in the configuration you can navigate to our
17+
[API reference pages](https://godoc.org/k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3).
18+
19+
{{< note >}}
20+
Customizing the CoreDNS deployment of kubeadm is currently not supported. You must manually
21+
patch the `kube-system/coredns` {{< glossary_tooltip text="ConfigMap" term_id="configmap" >}}
22+
and recreate the CoreDNS {{< glossary_tooltip text="Pods" term_id="pod" >}} after that. Alternatively,
23+
you can skip the default CoreDNS deployment and deploy your own variant.
24+
For more details on that see [Using init phases with kubeadm](/docs/reference/setup-tools/kubeadm/kubeadm-init/#init-phases).
25+
{{< /note >}}
26+
27+
<!-- body -->
28+
1129
{{< feature-state for_k8s_version="v1.12" state="stable" >}}
1230

13-
The kubeadm `ClusterConfiguration` object exposes the field `extraArgs` that can override the default flags passed to control plane
14-
components such as the APIServer, ControllerManager and Scheduler. The components are defined using the following fields:
31+
## Customizing the control plane with flags in `ClusterConfiguration`
32+
33+
The kubeadm `ClusterConfiguration` object exposes a way for users to override the default
34+
flags passed to control plane components such as the APIServer, ControllerManager, Scheduler and Etcd.
35+
The components are defined using the following structures:
1536

1637
- `apiServer`
1738
- `controllerManager`
1839
- `scheduler`
40+
- `etcd`
1941

20-
The `extraArgs` field consist of `key: value` pairs. To override a flag for a control plane component:
42+
These structures contain a common `extraArgs` field, that consists of `key: value` pairs.
43+
To override a flag for a control plane component:
2144

22-
1. Add the appropriate fields to your configuration.
23-
2. Add the flags to override to the field.
45+
1. Add the appropriate `extraArgs` to your configuration.
46+
2. Add flags to the `extraArgs` field.
2447
3. Run `kubeadm init` with `--config <YOUR CONFIG YAML>`.
2548

26-
For more details on each field in the configuration you can navigate to our
27-
[API reference pages](https://godoc.org/k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3#ClusterConfiguration).
28-
2949
{{< note >}}
30-
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.
50+
You can generate a `ClusterConfiguration` object with default values by running `kubeadm config print init-defaults`
51+
and saving the output to a file of your choice.
3152
{{< /note >}}
3253

54+
{{< note >}}
55+
The `ClusterConfiguration` object is currently global in kubeadm clusters. This means that any flags that you add,
56+
will apply to all instances of the same component on different nodes. To apply individual configuration per component
57+
on different nodes you can use [patches](#patches).
58+
{{< /note >}}
3359

60+
{{< note >}}
61+
Duplicate flags (keys), or passing the same flag `--foo` multiple times, is currently not supported.
62+
To workaround that you must use [patches](#patches).
63+
{{< /note >}}
3464

35-
<!-- body -->
36-
37-
## APIServer flags
65+
### APIServer flags
3866

3967
For details, see the [reference documentation for kube-apiserver](/docs/reference/command-line-tools-reference/kube-apiserver/).
4068

4169
Example usage:
70+
4271
```yaml
4372
apiVersion: kubeadm.k8s.io/v1beta3
4473
kind: ClusterConfiguration
4574
kubernetesVersion: v1.16.0
4675
apiServer:
4776
extraArgs:
48-
advertise-address: 192.168.0.103
4977
anonymous-auth: "false"
5078
enable-admission-plugins: AlwaysPullImages,DefaultStorageClass
5179
audit-log-path: /home/johndoe/audit.log
5280
```
5381
54-
## ControllerManager flags
82+
### ControllerManager flags
5583
5684
For details, see the [reference documentation for kube-controller-manager](/docs/reference/command-line-tools-reference/kube-controller-manager/).
5785
5886
Example usage:
87+
5988
```yaml
6089
apiVersion: kubeadm.k8s.io/v1beta3
6190
kind: ClusterConfiguration
6291
kubernetesVersion: v1.16.0
6392
controllerManager:
6493
extraArgs:
6594
cluster-signing-key-file: /home/johndoe/keys/ca.key
66-
bind-address: 0.0.0.0
6795
deployment-controller-sync-period: "50"
6896
```
6997
70-
## Scheduler flags
98+
### Scheduler flags
7199
72100
For details, see the [reference documentation for kube-scheduler](/docs/reference/command-line-tools-reference/kube-scheduler/).
73101
74102
Example usage:
103+
75104
```yaml
76105
apiVersion: kubeadm.k8s.io/v1beta3
77106
kind: ClusterConfiguration
@@ -86,3 +115,96 @@ scheduler:
86115
readOnly: true
87116
pathType: "File"
88117
```
118+
119+
### Etcd flags
120+
121+
For details, see the [etcd server documentation](https://etcd.io/docs/).
122+
123+
Example usage:
124+
125+
```yaml
126+
apiVersion: kubeadm.k8s.io/v1beta3
127+
kind: ClusterConfiguration
128+
etcd:
129+
local:
130+
extraArgs:
131+
election-timeout: 1000
132+
```
133+
134+
## Customizing the control plane with patches {#patches}
135+
136+
{{< feature-state for_k8s_version="v1.22" state="beta" >}}
137+
138+
Kubeadm allows you to pass a directory with patch files to `InitConfiguration` and `JoinConfiguration`
139+
on individual nodes. These patches can be used as the last customization step before the control
140+
plane component manifests are written to disk.
141+
142+
You can pass this file to `kubeadm init` with `--config <YOUR CONFIG YAML>`:
143+
144+
```yaml
145+
apiVersion: kubeadm.k8s.io/v1beta3
146+
kind: InitConfiguration
147+
nodeRegistration:
148+
patches:
149+
directory: /home/user/somedir
150+
```
151+
152+
{{< note >}}
153+
For `kubeadm init` you can pass a file containing both a `ClusterConfiguration` and `InitConfiguration`
154+
separated by `---`.
155+
{{< /note >}}
156+
157+
You can pass this file to `kubeadm join` with `--config <YOUR CONFIG YAML>`:
158+
159+
```yaml
160+
apiVersion: kubeadm.k8s.io/v1beta3
161+
kind: JoinConfiguration
162+
nodeRegistration:
163+
patches:
164+
directory: /home/user/somedir
165+
```
166+
167+
The directory must contain files named `target[suffix][+patchtype].extension`.
168+
For example, `kube-apiserver0+merge.yaml` or just `etcd.json`.
169+
170+
- `target` can be one of `kube-apiserver`, `kube-controller-manager`, `kube-scheduler` and `etcd`.
171+
- `patchtype` can be one of `strategic`, `merge` or `json` and these must match the patching formats
172+
[supported by kubectl](/docs/tasks/manage-kubernetes-objects/update-api-object-kubectl-patch).
173+
The default `patchtype` is `strategic`.
174+
- `extension` must be either `json` or `yaml`.
175+
- `suffix` is an optional string that can be used to determine which patches are applied first
176+
alpha-numerically.
177+
178+
{{< note >}}
179+
If you are using `kubeadm upgrade` to upgrade your kubeadm nodes you must again provide the same
180+
patches, so that the customization is preserved after upgrade. To do that you can use the `--patches`
181+
flag, which must point to the same directory. `kubeadm upgrade` currently does not support a configuration
182+
API structure that can be used for the same purpose.
183+
{{< /note >}}
184+
185+
## Customizing the kubelet
186+
187+
To customize the kubelet you can add a `KubeletConfiguration` next to the `ClusterConfiguration` or
188+
`InitConfiguration` separated by `---` within the same configuration file. This file can then be passed to `kubeadm init`.
189+
190+
{{< note >}}
191+
kubeadm applies the same `KubeletConfiguration` to all nodes in the cluster. To apply node
192+
specific settings you can use kubelet flags as overrides by passing them in the `nodeRegistration.kubeletExtraArgs`
193+
field supported by both `InitConfiguration` and `JoinConfiguration`. Some kubelet flags are deprecated,
194+
so check their status in the [kubelet reference documentation](/docs/reference/command-line-tools-reference/kubelet)
195+
before using them.
196+
{{< /note >}}
197+
198+
For more details see [Configuring each kubelet in your cluster using kubeadm](/docs/setup/production-environment/tools/kubeadm/kubelet-integration)
199+
200+
## Customizing kube-proxy
201+
202+
To customize kube-proxy you can pass a `KubeProxyConfiguration` next your `ClusterConfiguration` or
203+
`InitConfiguration` to `kubeadm init` separated by `---`.
204+
205+
For more details you can navigate to our [API reference pages](https://godoc.org/k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3).
206+
207+
{{< note >}}
208+
kubeadm deploys kube-proxy as a {{< glossary_tooltip text="DaemonSet" term_id="daemonset" >}}, which means
209+
that the `KubeProxyConfiguration` would apply to all instances of kube-proxy in the cluster.
210+
{{< /note >}}

0 commit comments

Comments
 (0)