I have a kubeadm
installed kubernetes cluster. Recently it stopped working. kubelet
is running but seems stuck in initialization phases. I think the root cause is this recurring log in kube-apiserver
:
1 authentication.go:63] "Unable to authenticate the request" err="[x509: certificate has expired or is not yet valid: current time 2021-06-02T13:18:50Z is after 2021-05-29T15:48:22Z
So there is a certificate issue, also kubectl
is failing with unauthorized
. The thing is, kubeadm certs check-expiration
seems happy, and I even manually checked a few yaml config files (base64 decoded certificates, and run them through openssl to check the date). Nevertheless, I asked kubeadm to renew all certificates and rebooted everything, to no effect.
Any idea how I can identify which certificate exactly has expired ?
[acknowledgment and reference] I was helped by a kubernetes' dev here
The expired certificate was
/var/lib/kubelet/pki/kubelet/pki/kubelet-client-2020-*.pem
. The certificates in/var/lib/kublet/pki/
are not handled bykubeadm cert
but bykubelet
itself, so it's supposed to be renewed automatically, but for some reason this didn't happen as planned for us. Thekubelet-client-current.pem
had been renewed, but something was still using an old (and expired) certificate.Here is how I fixed the issue:
/etc/kubernetes/kubelet.conf
was obsolete, in particular usingdefault-user
instead ofsystem:node:node_name
. I deleted the file, created a kubeadm conf file and rankubeadm init phase kubeconfig kubelet
to recreate a cleankubelet.conf
/var/lib/kublet/pki/kubelet-client-current.pem
is supposed to be a symlink, which was not the case for me. So I removed it.kubelet-client-current.pem
to be created ; it should be a symlink.kubeadm init phase kubelet-finalize all
kubeadm certs renew all
/etc/kubernetes/admin.conf
Similar issues seems to be linked to NTP desynchronization.
Try forcing time synchronization (run as root):
Renew Kubernetes certificates (RUN on all master node)