@@ -19,6 +19,11 @@ to kubeadm certificate management.
19
19
20
20
You should be familiar with [ PKI certificates and requirements in Kubernetes] ( /docs/setup/best-practices/certificates/ ) .
21
21
22
+ This guide covers the usage of the ` openssl ` command (used for manual certificate signing,
23
+ if you choose that approach), but you can use your preferred tools.
24
+
25
+ Some of the steps here use ` sudo ` for administrator access. You can use any equivalent tool.
26
+
22
27
<!-- steps -->
23
28
24
29
## Using custom certificates {#custom-certificates}
@@ -53,6 +58,9 @@ There are various ways to prepare the component credentials when using external
53
58
[ PKI certificates and requirements] ( /docs/setup/best-practices/certificates/ ) includes information
54
59
on how to prepare all the required by kubeadm component credentials manually.
55
60
61
+ This guide covers the usage of the ` openssl ` command (used for manual certificate signing,
62
+ if you choose that approach), but you can use your preferred tools.
63
+
56
64
### Preparation of credentials by signing CSRs generated by kubeadm
57
65
58
66
kubeadm can [ generate CSR files] ( #signing-csr ) that you can sign manually with tools like
@@ -87,7 +95,11 @@ Once the credentials are prepared on all nodes, call `kubeadm init` and `kubeadm
87
95
join the cluster. kubeadm will use the existing kubeconfig and certificate files under ` /etc/kubernetes/ `
88
96
and its ` pki ` sub directory.
89
97
90
- ## Check certificate expiration
98
+ ## Certificate expiry and management {#check-certificate-expiration}
99
+
100
+ {{< note >}}
101
+ ` kubeadm ` cannot manage certificates signed by an external CA.
102
+ {{< /note >}}
91
103
92
104
You can use the ` check-expiration ` subcommand to check when certificates expire:
93
105
@@ -123,20 +135,15 @@ by kubeadm (`admin.conf`, `controller-manager.conf` and `scheduler.conf`).
123
135
Additionally, kubeadm informs the user if the certificate is externally managed; in this case, the
124
136
user should take care of managing certificate renewal manually/using other tools.
125
137
126
- {{< warning >}}
127
- ` kubeadm ` cannot manage certificates signed by an external CA.
128
- {{< /warning >}}
129
-
130
- {{< note >}}
131
- ` kubelet.conf ` is not included in the list above because kubeadm configures kubelet
138
+ The ` kubelet.conf ` configuration file is not included in the list above because kubeadm
139
+ configures kubelet
132
140
for [ automatic certificate renewal] ( /docs/tasks/tls/certificate-rotation/ )
133
141
with rotatable certificates under ` /var/lib/kubelet/pki ` .
134
142
To repair an expired kubelet client certificate see
135
143
[ Kubelet client certificate rotation fails] ( /docs/setup/production-environment/tools/kubeadm/troubleshooting-kubeadm/#kubelet-client-cert ) .
136
- {{< /note >}}
137
144
138
- {{< warning >}}
139
- On nodes created with ` kubeadm init ` , prior to kubeadm version 1.17, there is a
145
+ {{< note >}}
146
+ On nodes created with ` kubeadm init ` from versions prior to kubeadm version 1.17, there is a
140
147
[ bug] ( https://github.com/kubernetes/kubeadm/issues/1753 ) where you manually have to modify the
141
148
contents of ` kubelet.conf ` . After ` kubeadm init ` finishes, you should update ` kubelet.conf ` to
142
149
point to the rotated kubelet client certificates, by replacing ` client-certificate-data ` and
@@ -146,7 +153,7 @@ point to the rotated kubelet client certificates, by replacing `client-certifica
146
153
client-certificate : /var/lib/kubelet/pki/kubelet-client-current.pem
147
154
client-key : /var/lib/kubelet/pki/kubelet-client-current.pem
148
155
` ` `
149
- {{< /warning >}}
156
+ {{< /note >}}
150
157
151
158
## Automatic certificate renewal
152
159
@@ -166,18 +173,20 @@ If you have more complex requirements for certificate renewal, you can opt out f
166
173
behavior by passing ` --certificate-renewal=false` to `kubeadm upgrade apply` or to `kubeadm
167
174
upgrade node`.
168
175
169
- {{< warning >}}
170
- Prior to kubeadm version 1.17 there is a [bug](https://github.com/kubernetes/kubeadm/issues/1818)
171
- where the default value for `--certificate-renewal` is `false` for the `kubeadm upgrade node`
172
- command. In that case, you should explicitly set `--certificate-renewal=true`.
173
- {{< /warning >}}
174
-
175
176
# # Manual certificate renewal
176
177
177
- You can renew your certificates manually at any time with the `kubeadm certs renew` command, with the appropriate command line options.
178
+ You can renew your certificates manually at any time with the `kubeadm certs renew` command,
179
+ with the appropriate command line options. If you are running cluster with a replicated control
180
+ plane, this command needs to be executed on all the control-plane nodes.
178
181
179
182
This command performs the renewal using CA (or front-proxy-CA) certificate and key stored in `/etc/kubernetes/pki`.
180
183
184
+ ` kubeadm certs renew` uses the existing certificates as the authoritative source for attributes
185
+ (Common Name, Organization, subject alternative name) and does not rely on the `kubeadm-config`
186
+ ConfigMap.
187
+ Even so, the Kubernetes project recommends keeping the served certificate and the associated
188
+ values in that ConfigMap synchronized, to avoid any risk of confusion.
189
+
181
190
After running the command you should restart the control plane Pods. This is required since
182
191
dynamic certificate reload is currently not supported for all components and certificates.
183
192
[Static Pods](/docs/tasks/configure-pod-container/static-pod/) are managed by the local kubelet
@@ -188,33 +197,25 @@ The kubelet will terminate the Pod if it's no longer in the manifest directory.
188
197
You can then move the file back and after another `fileCheckFrequency` period, the kubelet will recreate
189
198
the Pod and the certificate renewal for the component can complete.
190
199
191
- {{< warning >}}
192
- If you are running an HA cluster, this command needs to be executed on all the control-plane nodes.
193
- {{< /warning >}}
194
-
195
- {{< note >}}
196
- ` certs renew` uses the existing certificates as the authoritative source for attributes (Common
197
- Name, Organization, SAN, etc.) instead of the `kubeadm-config` ConfigMap. It is strongly recommended
198
- to keep them both in sync.
199
- {{< /note >}}
200
-
201
- `kubeadm certs renew` can renew any specific certificate or, with the subcommand `all`, it can renew all of them, as shown below :
200
+ `kubeadm certs renew` can renew any specific certificate or, with the subcommand `all`, it can renew all of them :
202
201
203
202
` ` ` shell
203
+ # If you are running cluster with a replicated control plane, this command
204
+ # needs to be executed on all the control-plane nodes.
204
205
kubeadm certs renew all
205
206
` ` `
206
207
207
- {{< note >}}
208
+ # ## Copying the administrator certificate (optional) {#admin-certificate-copy}
209
+
208
210
Clusters built with kubeadm often copy the `admin.conf` certificate into
209
211
` $HOME/.kube/config` , as instructed in [Creating a cluster with kubeadm](/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/).
210
212
On such a system, to update the contents of `$HOME/.kube/config`
211
- after renewing the `admin.conf`, you must run the following commands :
213
+ after renewing the `admin.conf`, you could run the following commands :
212
214
213
215
` ` ` shell
214
216
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
215
217
sudo chown $(id -u):$(id -g) $HOME/.kube/config
216
218
` ` `
217
- {{< /note >}}
218
219
219
220
# # Renew certificates with the Kubernetes certificates API
220
221
@@ -430,16 +431,13 @@ as extra SANs and custom IP addresses must be stored in the same configuration
430
431
file and used for all relevant kubeadm commands by passing it as `--config`.
431
432
432
433
{{< note >}}
433
- This guide will cover the usage of the `openssl` command for singing the CSRs,
434
- but you can use your preferred tools.
435
- {{< /note >}}
434
+ This guide uses the default Kubernetes directory `/etc/kubernetes`, which requires
435
+ a super user. If you are following this guide and are using directories that you can
436
+ write to (typically, this means running `kubeadm` with `--cert-dir` and `--kubeconfig-dir`)
437
+ then you can omit the `sudo` command).
436
438
437
- {{< note >}}
438
- This guide will use the default Kubernetes directory `/etc/kubernetes`, which requires
439
- a super user. If you are following this guide with permissive directories
440
- (by passing `--cert-dir` and `--kubeconfig-dir`) you can omit the `sudo` command).
441
- But note that the resulted files must be copied to the `/etc/kubernetes` tree,
442
- so that `kubeadm init` or `kubeadm join` will find them.
439
+ You must then copy the files that you produced over to within the `/etc/kubernetes`
440
+ directory so that `kubeadm init` or `kubeadm join` will find them.
443
441
{{< /note >}}
444
442
445
443
# ## Preparing CA and service account files
@@ -460,8 +458,9 @@ private keys) that kubeadm needs for a control plane node.
460
458
461
459
{{< note >}}
462
460
If you are using an external CA, you must generate the same files out of band and manually
463
- copy them to the primary control plane node in `/etc/kubernetes`. Once all CSRs
464
- are signed, you can delete the root CA key (`ca.key`) as noted in the
461
+ copy them to the primary control plane node in `/etc/kubernetes`.
462
+
463
+ Once all CSRs are signed, you can delete the root CA key (`ca.key`) as noted in the
465
464
[External CA mode](#external-ca-mode) section.
466
465
{{< /note >}}
467
466
@@ -500,9 +499,10 @@ That is because the active kube-controller-manager will be responsible
500
499
for signing new kubelet client certificates.
501
500
502
501
{{< note >}}
503
- Processing the `kubelet.conf.csr` on the primary control plane node
504
- (`kubeadm init`) is required, because that is considered the node that
505
- bootstraps the cluster and a pre-populated `kubelet.conf` is needed.
502
+ You must process the `kubelet.conf.csr` file on the primary control plane node
503
+ (the host where you originally ran `kubeadm init`). This is because `kubeadm`
504
+ considers that as the node that bootstraps the cluster, and a pre-populated
505
+ ` kubelet.conf` is needed.
506
506
{{< /note >}}
507
507
508
508
# ### Control plane nodes
@@ -539,8 +539,8 @@ the steps for worker nodes entirely.
539
539
540
540
{{< note >}}
541
541
If you are using external CA and already have CA serial number files (`.srl`) for
542
- ` openssl` you can copy such files to a kubeadm node where CSRs will be processed.
543
- ` .srl` files to copy are `/etc/kubernetes/pki/ca.srl`,
542
+ ` openssl` , you can copy such files to a kubeadm node where CSRs will be processed.
543
+ The `.srl` files to copy are `/etc/kubernetes/pki/ca.srl`,
544
544
` /etc/kubernetes/pki/front-proxy-ca.srl` and `/etc/kubernetes/pki/etcd/ca.srl`.
545
545
The files can be then moved to a new node where CSR files will be processed.
546
546
0 commit comments