Interview Prep/Real-World Interview/Kubernetes cluster-level

On a kubeadm cluster, `kubectl` suddenly fails with "Unable to connect to the server: x509: certificate has expired or is not yet valid", exactly one year after the cluster was built.

AdvancedTroubleshootingKubernetes cluster-level
Answer

Likely causes → kubeadm issues control-plane certificates (apiserver, kubelet client, front-proxy, etcd, admin.conf) valid for one year. They renew automatically only during kubeadm upgrade, so a cluster that was never upgraded expires all at once.

Diagnose →

sudo kubeadm certs check-expiration
sudo openssl x509 -in /etc/kubernetes/pki/apiserver.crt -noout -enddate

Fix → On each control-plane node:

sudo kubeadm certs renew all
# restart static pods: move manifests out, wait ~20s, move them back
sudo mkdir -p /tmp/manifests && sudo mv /etc/kubernetes/manifests/*.yaml /tmp/manifests/
sleep 20 && sudo mv /tmp/manifests/*.yaml /etc/kubernetes/manifests/
sudo cp /etc/kubernetes/admin.conf ~/.kube/config

Check kubelet client certs too (/var/lib/kubelet/pki) and enable rotateCertificates: true.

Prevent → Upgrade the cluster at least yearly (which renews the certs), monitor cert expiry with an exporter, and calendar the renewal.

All Real-World Interview questions Roadmap: Interview readiness

More on Kubernetes cluster-level