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.
More on Kubernetes cluster-level
Every `kubectl` command fails with "The connection to the server 10.0.1.10:6443 was refused - did you specify the right host or port?"BeginnerA new deployment's pods stay Pending with "0/5 nodes are available: 5 Insufficient cpu. preemption: 0/5 nodes are available: 5 No preemption victims found for incoming pod."BeginnerPods are Pending, but Cluster Autoscaler won't add nodes; the pod events say "pod didn't trigger scale-up: 2 node(s) didn't match Pod's node affinity/selector, 1 max node group size reached".IntermediateA node goes NotReady and kubelet logs "PLEG is not healthy: pleg was last seen active 3m10s ago; threshold is 3m0s".IntermediateAfter a node was terminated, its pods have shown `Terminating` for two hours and their replacements aren't being created.IntermediateYou deleted a namespace an hour ago and it's still `Terminating`.Intermediate