Skip to content

Commit 58fc28e

Browse files
antoinep92neolit123
andcommitted
Document kubelet client certificate recovery
break long lines simplify wording (suggested by neolit123) phrasing error/typo don't mention creating a new kuebadm config file, not really relevant here remove unnecessary stop from kubelet cert troubleshoot minor phrasing improvement: *the* kublet make the steps for fixing kubelet certs separate from other troubleshooting suggestions move kubelet cert troubleshooting to a better place improve note wording and add link add missing dot Co-authored-by: Lubomir I. Ivanov <[email protected]> add missing dot Co-authored-by: Lubomir I. Ivanov <[email protected]> remove steps not related to the issue Make instructions work on worker nodes too Co-authored-by: Lubomir I. Ivanov <[email protected]>
1 parent 55f1b0a commit 58fc28e

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

content/en/docs/setup/production-environment/tools/kubeadm/troubleshooting-kubeadm.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,25 @@ Unable to connect to the server: x509: certificate signed by unknown authority (
220220
sudo chown $(id -u):$(id -g) $HOME/.kube/config
221221
```
222222

223+
## Kubelet client certificate rotation fails {#kubelet-client-cert}
224+
225+
By default, kubeadm configures a kubelet with automatic rotation of client certificates by using the `/var/lib/kubelet/pki/kubelet-client-current.pem` symlink specified in `/etc/kubernetes/kubelet.conf`.
226+
If this rotation process fails you might see errors such as `x509: certificate has expired or is not yet valid`
227+
in kube-apserver logs. To fix the issue you must follow these steps:
228+
229+
1. Backup and delete `/etc/kubernetes/kubelet.conf` and `/var/lib/kubelet/pki/kubelet-client*` from the failed node.
230+
1. From a working control plane node in the cluster that has `/etc/kubernetes/pki/ca.key` execute
231+
`kubeadm kubeconfig user --org system:nodes --client-name system:node:$NODE > kubelet.conf`.
232+
`$NODE` must be set to the name of the existing failed node in the cluster.
233+
Modify the resulted `kubelet.conf` manually to adjust the cluster name and server endpoint,
234+
or pass `kubeconfig user --config` (it accepts `InitConfiguration`). If your cluster does not have
235+
the `ca.key` you must sign the embedded certificates in the `kubelet.conf` externally.
236+
1. Copy this resulted `kubelet.conf` to `/etc/kubernetes/kubelet.conf` on the failed node.
237+
1. Restart the kubelet (`systemctl restart kubelet`) on the failed node and wait for
238+
`/var/lib/kubelet/pki/kubelet-client-current.pem` to be recreated.
239+
1. Run `kubeadm init phase kubelet-finalize all` on the failed node. This will make the new
240+
`kubelet.conf` file use `/var/lib/kubelet/pki/kubelet-client-current.pem` and will restart the kubelet.
241+
1. Make sure the node becomes `Ready`.
223242
## Default NIC When using flannel as the pod network in Vagrant
224243

225244
The following error might indicate that something was wrong in the pod network:

content/en/docs/tasks/administer-cluster/kubeadm/kubeadm-certs.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ Additionally, kubeadm informs the user if the certificate is externally managed;
8585
{{< /warning >}}
8686

8787
{{< note >}}
88-
`kubelet.conf` is not included in the list above because kubeadm configures kubelet for automatic certificate renewal.
88+
`kubelet.conf` is not included in the list above because kubeadm configures kubelet
89+
for [automatic certificate renewal](/docs/tasks/tls/certificate-rotation/)
90+
with rotatable certificates under `/var/lib/kubelet/pki`.
91+
To repair an expired kubelet client certificate see
92+
[Kubelet client certificate rotation fails](/docs/setup/production-environment/tools/kubeadm/troubleshooting-kubeadm/#kubelet-client-cert).
8993
{{< /note >}}
9094

9195
{{< warning >}}

0 commit comments

Comments
 (0)