Pages

Topics

Tools

↑↓navigate↵openescclose
All guides

Kubernetes: x509 certificate has expired or is not yet valid

kubeadm control plane certificates last one year. Renew them, restart the static pods, refresh kubeconfigs, and alert before the next expiry.

~5 min readKubernetes
#kubernetes#kubeadm#tls#certificates
Kubernetes certificate card expiring beside a control plane node platform and a renew tool

Introduction & Quick Summary

kubectl suddenly fails on every command, and nothing was deployed:

code
Unable to connect to the server: x509: certificate has expired or is not yet valid: certificate is valid for kubernetes, kubernetes.default, 10.96.0.1, not ... current time 2026-11-28T10:04:11Z is after 2026-11-14T09:12:40Z

Quick answer: the API server's serving certificate — created by kubeadm one year earlier — has passed its expiry date. Renew the control plane certificates, then restart the static pods that hold them in memory, because they were loaded at process start:

bash
sudo kubeadm certs check-expiration # read the dates first sudo kubeadm certs renew all # writes new files to /etc/kubernetes/pki # static pod manifests pick the new certificates up only on restart sudo crictl ps -q --name kube-apiserver | xargs -r sudo crictl stop sudo mv /etc/kubernetes/manifests/kube-apiserver.yaml /tmp/ && sleep 20 sudo mv /tmp/kube-apiserver.yaml /etc/kubernetes/manifests/
bash
kubectl get nodes # verify the API answers again sudo kubeadm certs check-expiration # all "RESIDUAL TIME" positive

On a single control plane node that restart is enough. On a multi-node cluster, renew on every control plane node and copy the regenerated kubeconfigs to the clients that use them. This guide covers the layout, the restart order, the kubelet side people forget, and how to make the next expiry an alert.

Core Mechanics, Signatures & Reproducible Setup

kubeadm init writes a PKI tree under /etc/kubernetes/pki and embeds it in the static pod manifests under /etc/kubernetes/manifests. Every leaf certificate is valid for one year; the two CAs are valid for ten.

CertificateFileDefault lifetimeRenewed by
API server servingapiserver.crt1 yearkubeadm certs renew apiserver
API server clientapiserver-kubelet-client.crt1 yearrenew apiserver-kubelet-client
etcd server / peeretcd/server.crt, etcd/peer.crt1 yearrenew etcd-server, etcd-peer
front proxy clientfront-proxy-client.crt1 yearrenew front-proxy-client
admin kubeconfigadmin.conf1 yearrenew all (regenerates it)
controller-manager / scheduler kubeconfigscontroller-manager.conf, scheduler.conf1 yearrenew all
cluster CAca.crt, ca.key10 yearsnot renewed by kubeadm

The expiry is inside the certificate, so the client is the one that notices first. kubectl reads ~/.kube/config, builds a TLS connection, and rejects the server certificate before any authentication happens.

Check the dates before touching anything:

bash
sudo kubeadm certs check-expiration
code
CERTIFICATE EXPIRES RESIDUAL TIME SIGNING CA admin.conf Nov 14, 2026 09:12 UTC 1w ca apiserver Nov 14, 2026 09:12 UTC 1w ca apiserver-kubelet-client Nov 14, 2026 09:12 UTC 1w ca front-proxy-client Nov 14, 2026 09:12 UTC 1w ca etcd-server Nov 14, 2026 09:12 UTC 1w ca

To inspect a single file directly, openssl prints the same facts and works on any machine that has the certificate:

bash
sudo openssl x509 -in /etc/kubernetes/pki/apiserver.crt -noout -subject -dates -ext subjectAltName
code
subject=CN = kube-apiserver notBefore=Nov 14 09:12:40 2025 GMT notAfter=Nov 14 09:12:40 2026 GMT X509v3 Subject Alternative Name: DNS:kubernetes, DNS:kubernetes.default, IP Address:10.96.0.1, IP Address:192.168.1.10

The SAN list is the other half of this error class: an unexpired certificate is still rejected as "not valid for" a new node IP.

Key Comparison Table

MessageCauseFix
certificate has expiredpast notAfterrenew and restart static pods
certificate is valid for ..., not <name>SAN missing the address usedregenerate with a kubeadm config listing the SANs
certificate signed by unknown authorityCA changed or wrong CA bundlerestore the original ca.crt or use the right kubeconfig
current time ... is before ...clock skew, not expiryfix NTP on the node
x509: certificate is not valid for any namesconnecting by raw IPuse the API server name or add the IP to SANs
Renewal routeCoversRequires
kubeadm certs renew allall control plane leaf certsroot on each control plane node
kubeadm upgradeall leaves during an upgradea version upgrade
systemd timer + renew alleverything, unattendedone timer per control plane node
kubelet certificate rotationkubelet client and serving certsrotateCertificates: true
manual openssl / cert-managerexternal PKI setupsyour own PKI process
ComponentReads certificates whenRestart needed after renew
kube-apiserverprocess startyes
kube-controller-managerprocess startyes
kube-schedulerprocess startyes
etcdprocess startyes
kubeletprocess start, then rotationonly if rotation is disabled

Practical Edge Cases, Error Fixes & Deep Dive Code Examples

1. Renew everything, then restart the right processes

kubeadm certs renew all rewrites files but changes nothing for running processes. Static pods are supervised by the kubelet, which restarts a manifest when its file changes:

bash
sudo kubeadm certs renew all # touch each manifest to trigger a restart without stopping the API for long for f in /etc/kubernetes/manifests/*.yaml; do sudo touch "$f"; sleep 5; done sudo crictl ps --name kube-apiserver # started seconds ago sudo journalctl -u kubelet -n 30 --no-pager

Restarting while the API is down is safe: the renewed files are already on disk.

2. Kubeconfig files are separate certificates

/etc/kubernetes/admin.conf contains a client certificate with the same one-year lifetime. Renewing the PKI does not update the copy in ~/.kube/config, so kubectl keeps failing with the old certificate:

bash
sudo kubeadm certs renew admin.conf sudo cp /etc/kubernetes/admin.conf ~/.kube/config sudo chown "$(id -u):$(id -g)" ~/.kube/config # or merge just the new client credentials into an existing config KUBECONFIG=~/.kube/config:/etc/kubernetes/admin.conf kubectl config view --flatten > /tmp/merged mv /tmp/merged ~/.kube/config

Every user, CI runner and mounted kubeconfig needs the refreshed file.

3. The kubelet side, which fails differently

Kubelet certificates are not control plane certificates. Client certificates issued through the CSR API expire after about a year and are rotated automatically when rotateCertificates is enabled; a node that shows NotReady with kubelet: x509: certificate has expired needs either rotation or a manual reissue:

# /var/lib/kubelet/config.yaml rotateCertificates: true serverTLSBootstrap: true
bash
sudo systemctl restart kubelet sudo journalctl -u kubelet -n 50 --no-pager | grep -i -e cert -e rotate kubectl get csr # pending requests from the node kubectl certificate approve <csr-name>

If the node cannot authenticate at all, kubeadm kubeconfig user --org system:nodes --client-name system:node:<node> generates a fresh client certificate from the CA on a control plane node.

4. When the CA itself expired

Ten years is long, but it does happen in long-lived labs, and no renewal command can fix it: every certificate signed by that CA must be reissued, and the kubeconfigs of every client replaced.

bash
sudo openssl x509 -in /etc/kubernetes/pki/ca.crt -noout -dates # notAfter=... 2026 GMT <- if this is past, the cluster certificates cannot be renewed in place

The supported path is a new control plane with kubeadm init (optionally reusing etcd data) and nodes rejoining. Plan it as a migration, not a repair.

5. Make the next expiry an alert

A gauge from the certificate file turns expiry into a monitoring problem instead of an outage:

bash
#!/usr/bin/env bash # prints days left for the API server certificate end=$(date -d "$(openssl x509 -in /etc/kubernetes/pki/apiserver.crt -noout -enddate | cut -d= -f2)" +%s) echo "kube_apiserver_cert_days_left $(( (end - $(date +%s)) / 86400 ))"

Alert below 30 days and schedule kubeadm certs renew all with a systemd timer at 60, followed by a manifest touch. Keeping the timer and the alert separate means a failed renewal still pages someone. Comparing an old and a new kubeconfig while debugging the client side is easier with the text diff tool, and checking the endpoint and its certificate by hand is quicker with the curl command generator:

curl -vk https://192.168.1.10:6443/healthz 2>&1 | grep -E "subject:|expire|issuer:"

Common Compilation/Runtime Mistakes & Version Gotchas

  • Renewing without restarting. New files on disk, old certificates in memory; nothing changes until the static pod restarts.
  • Updating only admin.conf. Every kubeconfig file carries its own client certificate and expires on the same schedule.
  • Renewing on one control plane node. Each node has its own PKI copy; renew on all of them, and keep the same CA everywhere.
  • Deleting the CA while "starting fresh". A new ca.crt invalidates every existing kubeconfig, kubelet certificate, and service account token signer at once.
  • Treating not yet valid as expiry. It is a clock problem (NTP, a restored VM snapshot), so check timedatectl and chronyc tracking before renewing anything.
  • Version notes. kubeadm certs renew all has been stable since 1.15 and replaced the older kubeadm alpha certs renew; kubeadm upgrade renews all leaf certificates as part of the upgrade, so clusters upgraded at least yearly never see this error. Since 1.15 the kubelet rotates client certificates by default when the CSR API is reachable, which is why control plane certificates, not kubelet ones, are the usual expiry surprise.

Official documentation: kubeadm certificate management and Certificates and certificate signing requests.

Official references

primary documentation

The Kubernetes documentation that defines the behaviour this guide explains.

Try matching browser tools

All tools

Small utilities that fit Kubernetes work — they run entirely in this browser tab, so nothing you paste leaves your device.

All Kubernetes guides

More in Kubernetes

All Kubernetes guides

The guides filed next to this one in Kubernetes, in library order.