K8s Certificate Rotation and Management
Manage Kubernetes cluster certificates with kubeadm. Check expiration, renew certificates, configure auto-rotation, and troubleshoot TLS errors.
π‘ Quick Answer: Check certificate expiration:
kubeadm certs check-expiration. Renew all:kubeadm certs renew all. Certificates auto-renew duringkubeadm upgrade. Default expiration: 1 year (CA: 10 years). After renewal, restart control plane components:crictlor move static pod manifests.
The Problem
Kubernetes uses TLS certificates everywhere:
- kube-apiserver, etcd, kubelet communication
- Service account token signing
- Webhook admission controllers
- Default expiration: 1 year β cluster breaks when they expire
The Solution
Check Certificate Expiration
# Check all certificate expirations
kubeadm certs check-expiration
# CERTIFICATE EXPIRES RESIDUAL TIME
# admin.conf May 02, 2027 20:00 UTC 364d
# apiserver May 02, 2027 20:00 UTC 364d
# apiserver-etcd-client May 02, 2027 20:00 UTC 364d
# apiserver-kubelet-client May 02, 2027 20:00 UTC 364d
# controller-manager.conf May 02, 2027 20:00 UTC 364d
# etcd-healthcheck-client May 02, 2027 20:00 UTC 364d
# etcd-peer May 02, 2027 20:00 UTC 364d
# etcd-server May 02, 2027 20:00 UTC 364d
# front-proxy-client May 02, 2027 20:00 UTC 364d
# scheduler.conf May 02, 2027 20:00 UTC 364d
#
# CERTIFICATE AUTHORITY EXPIRES RESIDUAL TIME
# ca Apr 30, 2036 20:00 UTC 3650d
# etcd-ca Apr 30, 2036 20:00 UTC 3650d
# front-proxy-ca Apr 30, 2036 20:00 UTC 3650d
# Check individual certificate
openssl x509 -in /etc/kubernetes/pki/apiserver.crt -noout -dates
# notBefore=May 2 20:00:00 2026 GMT
# notAfter=May 2 20:00:00 2027 GMT
# Check certificate details
openssl x509 -in /etc/kubernetes/pki/apiserver.crt -noout -text | grep -A2 "Subject Alternative"Renew Certificates
# Renew all certificates
kubeadm certs renew all
# Renew specific certificate
kubeadm certs renew apiserver
kubeadm certs renew apiserver-kubelet-client
kubeadm certs renew admin.conf
# After renewal, restart control plane components
# Option 1: Move manifests (triggers recreation)
mv /etc/kubernetes/manifests/kube-apiserver.yaml /tmp/
sleep 5
mv /tmp/kube-apiserver.yaml /etc/kubernetes/manifests/
# Option 2: Kill containers directly
crictl ps | grep kube-apiserver | awk '{print $1}' | xargs crictl stop
crictl ps | grep kube-controller-manager | awk '{print $1}' | xargs crictl stop
crictl ps | grep kube-scheduler | awk '{print $1}' | xargs crictl stop
crictl ps | grep etcd | awk '{print $1}' | xargs crictl stop
# Update kubeconfig with new certs
cp /etc/kubernetes/admin.conf ~/.kube/configCertificate Locations
# PKI directory structure
/etc/kubernetes/pki/
βββ apiserver.crt # API server certificate
βββ apiserver.key # API server key
βββ apiserver-etcd-client.crt # API server β etcd client cert
βββ apiserver-etcd-client.key
βββ apiserver-kubelet-client.crt # API server β kubelet client cert
βββ apiserver-kubelet-client.key
βββ ca.crt # Cluster CA (10 year)
βββ ca.key
βββ front-proxy-ca.crt # Front proxy CA
βββ front-proxy-ca.key
βββ front-proxy-client.crt
βββ front-proxy-client.key
βββ sa.key # ServiceAccount signing key
βββ sa.pub # ServiceAccount verification key
βββ etcd/
βββ ca.crt # etcd CA
βββ ca.key
βββ healthcheck-client.crt
βββ healthcheck-client.key
βββ peer.crt # etcd peer communication
βββ peer.key
βββ server.crt # etcd server certificate
βββ server.key
# Kubeconfig files (embed certificates)
/etc/kubernetes/
βββ admin.conf
βββ controller-manager.conf
βββ scheduler.conf
βββ kubelet.confKubelet Certificate Rotation
# kubelet auto-rotates its own certificates (enabled by default)
# Check kubelet config
cat /var/lib/kubelet/config.yaml | grep -A3 rotateCertificates
# rotateCertificates: true β Auto-rotation enabled
# Kubelet certificates
ls /var/lib/kubelet/pki/
# kubelet-client-current.pem β kubelet-client-2026-05-02.pem
# kubelet.crt
# kubelet.key
# Check kubelet certificate expiration
openssl x509 -in /var/lib/kubelet/pki/kubelet-client-current.pem -noout -datesAutomated Renewal CronJob
# /etc/cron.monthly/renew-k8s-certs
#!/bin/bash
EXPIRY=$(kubeadm certs check-expiration 2>/dev/null | grep apiserver | awk '{print $5}')
DAYS_LEFT=$(( ($(date -d "$EXPIRY" +%s) - $(date +%s)) / 86400 ))
if [ "$DAYS_LEFT" -lt 60 ]; then
kubeadm certs renew all
crictl ps | grep -E 'kube-apiserver|kube-controller|kube-scheduler|etcd' | \
awk '{print $1}' | xargs -r crictl stop
echo "Certificates renewed on $(date)" >> /var/log/k8s-cert-renewal.log
fiCommon Issues
βx509: certificate has expiredβ
Certificates expired β cluster is broken. Renew: kubeadm certs renew all. Restart all control plane components.
βUnable to connect to the serverβ after renewal
kubeconfig still has old certificates. Copy new admin.conf: cp /etc/kubernetes/admin.conf ~/.kube/config.
CA certificate expiring
CA has 10-year default. If it expires, ALL certs must be regenerated. Plan CA rotation well ahead.
Best Practices
- Monitor certificate expiration β alert at 30 days remaining
- Upgrade regularly β
kubeadm upgradeauto-renews certificates - Enable kubelet certificate rotation β
rotateCertificates: true - Backup PKI directory β
/etc/kubernetes/pki/before any changes - Automate renewal β cron job or monitoring integration
Key Takeaways
kubeadm certs check-expirationshows all certificate dateskubeadm certs renew allrenews everything in one command- Certificates auto-renew during
kubeadm upgrade - After renewal, restart control plane components and update kubeconfig
- Kubelet auto-rotates its own certificates by default

Recommended
Kubernetes Recipes β The Complete Book100+ production-ready patterns with detailed explanations, best practices, and copy-paste YAML. Everything in one place.
Get the Book βLearn by Doing
CopyPasteLearn β Hands-on Cloud & DevOps CoursesMaster Kubernetes, Ansible, Terraform, and MLOps with interactive, copy-paste-run lessons. Start free.
Browse Courses βπ Deepen Your Skills β Hands-on Courses
Courses by CopyPasteLearn.com β Learn IT by Doing
