How to Diagnose and Fix Expired Kubernetes Certificates with kubeadm
This guide walks SREs and DevOps engineers through the typical failures caused by expired kubeadm‑issued Kubernetes certificates, explains root causes, and provides a step‑by‑step, production‑ready process for checking expiration, backing up critical directories, renewing master and worker node certificates, and verifying cluster health, with long‑term maintenance recommendations.
1. Typical failures after certificate expiration
Common symptoms include:
kubectl cannot access the cluster – error x509: certificate has expired Node NotReady – kubelet logs report certificate issues
Core control‑plane services unavailable – apiserver, controller‑manager, scheduler, etcd cannot load expired certificates
Conclusion: expired certificates can cripple the entire control plane, so renewal must occur at least 30 days before expiry.
2. Complete certificate renewal workflow (production ready)
Core principle: backup before operating. Run during a low‑traffic window.
Step 1: Check current certificate expiration
kubeadm certs check-expirationFocus on the EXPIRES field and RESIDUAL TIME ; if less than 30 days, renewal is required.
Step 2: Backup critical directories
Directories to back up : /etc/kubernetes – control‑plane configuration and kubeconfig /etc/kubernetes/pki – all core certificates and keys /var/lib/kubelet/pki – kubelet client certificates $HOME/.kube/config – administrator kubeconfig /etc/kubernetes/manifests – static Pods
Recommended backup commands :
sudo cp -r /etc/kubernetes /etc/kubernetes.bak_$(date +%Y%m%d)
sudo cp -r /var/lib/kubelet/pki /var/lib/kubelet/pki.bak_$(date +%Y%m%d)
cp ~/.kube/config ~/.kube/config.bak.$(date +%F)Step 3: Renew master node certificates
For HA clusters, repeat on each master.
1. Renew all certificates sudo kubeadm certs renew all This re‑signs certificates with the cluster CA, extending validity by one year.
2. Restart control‑plane components sudo systemctl restart kubelet Wait 2–3 minutes, then verify that the following components are Running in the kube-system namespace:
kube-apiserver
kube-controller-manager
kube-scheduler
etcd
3. Update local kubeconfig
sudo cp /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/configStep 4: Handle worker node certificates (auto‑rotation & manual fix)
4.1 Verify auto‑rotation is enabled
cat /var/lib/kubelet/config.yaml | grep rotateCertificates
ps aux | grep kubelet | grep rotateExpected output includes rotateCertificates: true and the --rotate-certificates flag.
4.2 Approve pending CSRs
kubectl get csr
kubectl get csr -o name | xargs kubectl certificate approve4.3 Manually recover completely expired kubelet certificates
On the affected worker node:
sudo systemctl stop kubelet
sudo rm -rf /var/lib/kubelet/pki/kubelet-client-*
sudo systemctl start kubeletThen on the master, approve the new CSR:
kubectl get csr -o name | xargs kubectl certificate approveStep 5: Post‑renewal verification
Check certificate expiration again kubeadm certs check-expiration Node health check kubectl get nodes All nodes should show Ready.
System pod health check kubectl get pods -n kube-system Test cluster usability
kubectl run test --image=busybox --restart=Never -- sleep 5Long‑term maintenance recommendations
Run quarterly
kubeadm certs check-expirationMonitoring & alerting (Prometheus/Alertmanager)
Remaining days < 60: warning
Remaining days < 30: critical alert
Cross‑machine backups
Automate daily backup of:
/etc/kubernetes /etc/kubernetes/pkiSigned-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Ray's Galactic Tech
Practice together, never alone. We cover programming languages, development tools, learning methods, and pitfall notes. We simplify complex topics, guiding you from beginner to advanced. Weekly practical content—let's grow together!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
