1
1
---
2
2
reviewers :
3
3
- sig-cluster-lifecycle
4
- title : Customizing control plane configuration with kubeadm
4
+ title : Customizing components with the kubeadm API
5
5
content_type : concept
6
6
weight : 40
7
7
---
8
8
9
9
<!-- overview -->
10
10
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
+
11
29
{{< feature-state for_k8s_version="v1.12" state="stable" >}}
12
30
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:
15
36
16
37
- ` apiServer `
17
38
- ` controllerManager `
18
39
- ` scheduler `
40
+ - ` etcd `
19
41
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:
21
44
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.
24
47
3 . Run ` kubeadm init ` with ` --config <YOUR CONFIG YAML> ` .
25
48
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
-
29
49
{{< 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.
31
52
{{< /note >}}
32
53
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 >}}
33
59
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 >}}
34
64
35
- <!-- body -->
36
-
37
- ## APIServer flags
65
+ ### APIServer flags
38
66
39
67
For details, see the [ reference documentation for kube-apiserver] ( /docs/reference/command-line-tools-reference/kube-apiserver/ ) .
40
68
41
69
Example usage:
70
+
42
71
``` yaml
43
72
apiVersion : kubeadm.k8s.io/v1beta3
44
73
kind : ClusterConfiguration
45
74
kubernetesVersion : v1.16.0
46
75
apiServer :
47
76
extraArgs :
48
- advertise-address : 192.168.0.103
49
77
anonymous-auth : " false"
50
78
enable-admission-plugins : AlwaysPullImages,DefaultStorageClass
51
79
audit-log-path : /home/johndoe/audit.log
52
80
` ` `
53
81
54
- ## ControllerManager flags
82
+ ### ControllerManager flags
55
83
56
84
For details, see the [reference documentation for kube-controller-manager](/docs/reference/command-line-tools-reference/kube-controller-manager/).
57
85
58
86
Example usage:
87
+
59
88
` ` ` yaml
60
89
apiVersion : kubeadm.k8s.io/v1beta3
61
90
kind : ClusterConfiguration
62
91
kubernetesVersion : v1.16.0
63
92
controllerManager :
64
93
extraArgs :
65
94
cluster-signing-key-file : /home/johndoe/keys/ca.key
66
- bind-address : 0.0.0.0
67
95
deployment-controller-sync-period : " 50"
68
96
` ` `
69
97
70
- ## Scheduler flags
98
+ ### Scheduler flags
71
99
72
100
For details, see the [reference documentation for kube-scheduler](/docs/reference/command-line-tools-reference/kube-scheduler/).
73
101
74
102
Example usage:
103
+
75
104
` ` ` yaml
76
105
apiVersion : kubeadm.k8s.io/v1beta3
77
106
kind : ClusterConfiguration
@@ -86,3 +115,96 @@ scheduler:
86
115
readOnly : true
87
116
pathType : " File"
88
117
` ` `
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