Certificates have come up several times in this series without ever getting the spotlight: kubeadm init generates a pile of files under /etc/kubernetes/pki, the etcd backup needed --cacert, --cert and --key, and the RBAC section signed a client certificate for jane through the CSR API. This post puts those pieces together: what each certificate in a kubeadm cluster is, who issues it, who uses it, and where to look when one of them breaks. As before, everything here can be checked on the three-node cluster (k8s-cp1, k8s-w1, k8s-w2) built in Building a kubeadm Cluster (Part 2).
PKI in Five Minutes
Just enough background to read the rest of the post.
Key pairs, CAs, and certificates
- Key pair: a private key (
.key) that only its owner holds, and a public key that can be handed to anyone. Data signed with the private key can be verified with the public key. - Certificate (
.crt): a public key plus identity information (who this key belongs to, what it may be used for, when it expires), signed by a CA. - CA (Certificate Authority): whoever signs the certificates. If you trust a CA's certificate (
ca.crt), you trust every certificate it signed. The CA's private key (ca.key) is the most valuable file in the whole cluster: anyone holding it can mint a certificate for any identity.
The X.509 fields Kubernetes cares about
| Field | Meaning | What Kubernetes does with it |
|---|---|---|
Subject CN |
Common Name | User name for client certificates |
Subject O |
Organization | Group name for client certificates (can appear more than once) |
| Issuer | Who signed it | Must be a CA the other side trusts |
| Not Before / Not After | Validity period | Expired certificates are rejected |
| Subject Alternative Name (SAN) | DNS names and IPs this certificate is valid for | For server certificates, the address the client connects to must be in the SAN |
| Extended Key Usage | serverAuth, clientAuth |
Whether it can be used as a server certificate, a client certificate, or both |
Mutual TLS
With ordinary HTTPS, only the server presents a certificate. Inside a Kubernetes cluster, almost every connection is mutual TLS (mTLS): the server proves who it is to the client, and the client presents its own certificate so the server knows who is calling. That's why the components have both server certificates and client certificates, and why the same CA shows up on both sides of a connection.
What kubeadm Generates
/etc/kubernetes/pki
On k8s-cp1:
sudo tree /etc/kubernetes/pki
/etc/kubernetes/pki
├── apiserver.crt
├── apiserver.key
├── apiserver-etcd-client.crt
├── apiserver-etcd-client.key
├── apiserver-kubelet-client.crt
├── apiserver-kubelet-client.key
├── ca.crt
├── ca.key
├── etcd
│ ├── ca.crt
│ ├── ca.key
│ ├── healthcheck-client.crt
│ ├── healthcheck-client.key
│ ├── peer.crt
│ ├── peer.key
│ ├── server.crt
│ └── server.key
├── front-proxy-ca.crt
├── front-proxy-ca.key
├── front-proxy-client.crt
├── front-proxy-client.key
├── sa.key
└── sa.pub
It looks like a lot, but it boils down to three CAs, the certificates they sign, and one key pair that isn't a certificate at all.
Three CAs
| CA | Files | What it signs |
|---|---|---|
| Kubernetes CA | ca.crt / ca.key |
The API server certificate, the API server's client certificate for the kubelet, every kubeconfig's client certificate, and CSRs approved through the CSR API |
| etcd CA | etcd/ca.crt / etcd/ca.key |
Everything that talks to etcd: etcd's own server and peer certificates, the API server's client certificate for etcd, the health check certificate |
| front-proxy CA | front-proxy-ca.crt / front-proxy-ca.key |
Only front-proxy-client, used by the aggregation layer |
Why not a single CA? Each CA defines a separate circle of trust. etcd trusts only certificates signed by the etcd CA, so even a valid cluster-admin client certificate from the Kubernetes CA can't connect to etcd directly. Likewise, extension API servers only accept proxied requests from certificates signed by the front-proxy CA, so an ordinary user certificate can't pretend to be the API server forwarding a request.
Certificate by certificate
| File | Signed by | Type | Used by → for |
|---|---|---|---|
apiserver.crt |
Kubernetes CA | Server | kube-apiserver, presented to every client (kubectl, kubelet, controllers, Pods) |
apiserver-kubelet-client.crt |
Kubernetes CA | Client | kube-apiserver → kubelet API (kubectl logs, exec, port-forward) |
apiserver-etcd-client.crt |
etcd CA | Client | kube-apiserver → etcd |
etcd/server.crt |
etcd CA | Server | etcd, presented to its clients |
etcd/peer.crt |
etcd CA | Server + client | Between etcd members (matters with multiple control plane nodes) |
etcd/healthcheck-client.crt |
etcd CA | Client | The etcd liveness probe; also handy for etcdctl |
front-proxy-client.crt |
front-proxy CA | Client | kube-apiserver → extension API servers such as metrics-server |
sa.key / sa.pub |
None | Key pair | Signing and verifying ServiceAccount tokens |
sa.key and sa.pub are the odd ones out: there's no certificate and no CA. kube-apiserver signs ServiceAccount tokens (the JWTs mounted into Pods) with sa.key and verifies them with sa.pub. If every control plane node didn't share the same pair, a token issued by one API server would be rejected by another.
The API server certificate's SAN deserves a closer look, because it decides which addresses clients can use:
sudo openssl x509 -in /etc/kubernetes/pki/apiserver.crt -noout -ext subjectAltName
X509v3 Subject Alternative Name:
DNS:k8s-cp1, DNS:kubernetes, DNS:kubernetes.default, DNS:kubernetes.default.svc, DNS:kubernetes.default.svc.cluster.local, IP Address:10.96.0.1, IP Address:<cp1 IP>
kubernetes.default.svc...and10.96.0.1are thekubernetesService inside the cluster (the first IP of the Service CIDR); that's how Pods reach the API server.k8s-cp1and the node IP are for connections from outside (your IP will differ).- If
--control-plane-endpointwas set atkubeadm init, that name shows up here too.
kubeconfig files in /etc/kubernetes
The control plane components that act as clients of the API server don't read .crt files directly. Each one has a kubeconfig, which bundles the CA certificate, the API server address, and that component's own client certificate and key:
ls /etc/kubernetes/*.conf
| kubeconfig | Used by | Certificate CN | Certificate O |
|---|---|---|---|
admin.conf |
Administrator (copied to ~/.kube/config) |
kubernetes-admin |
kubeadm:cluster-admins |
super-admin.conf |
Emergency use only | kubernetes-super-admin |
system:masters |
controller-manager.conf |
kube-controller-manager | system:kube-controller-manager |
|
scheduler.conf |
kube-scheduler | system:kube-scheduler |
|
kubelet.conf |
kubelet | system:node:k8s-cp1 |
system:nodes |
Decode the certificate in admin.conf to see this for yourself:
sudo grep client-certificate-data /etc/kubernetes/admin.conf | awk '{print $2}' | base64 -d \
| openssl x509 -noout -subject -issuer -dates
subject=O=kubeadm:cluster-admins, CN=kubernetes-admin
issuer=CN=kubernetes
notBefore=...
notAfter=...
The issuer CN=kubernetes is the Kubernetes CA.
From certificate to RBAC identity
This is where certificates connect back to RBAC in the cluster maintenance post. When a client authenticates with a certificate signed by the CA in --client-ca-file, the API server takes:
CNas the user name- every
Oas a group
From there, authorization is ordinary RBAC: kubernetes-admin is in the group kubeadm:cluster-admins, which a ClusterRoleBinding binds to cluster-admin. The kubelet's certificate is a bit special: the system:node:<nodeName> user plus the system:nodes group is what the Node authorizer (the Node in --authorization-mode=Node,RBAC) looks for, limiting each kubelet to reading and writing only the objects related to its own node.
This also means a certificate can't be revoked. Kubernetes doesn't check CRLs, so a leaked client certificate stays valid until it expires. To cut off its access, remove the RBAC bindings for that user or group, which is exactly why kubeadm moved admin.conf out of the unrevocable system:masters group.
Where Each Component Points at Its Certificates
In the exam you don't need to memorize the paths. They're all written in the static Pod manifests under /etc/kubernetes/manifests/, and reading those flags is the core skill for certificate troubleshooting.
kube-apiserver
sudo grep -E 'pki|\.conf' /etc/kubernetes/manifests/kube-apiserver.yaml
| Flag | File | Purpose |
|---|---|---|
--tls-cert-file / --tls-private-key-file |
apiserver.crt / .key |
Its own server certificate |
--client-ca-file |
ca.crt |
Trust client certificates signed by this CA |
--kubelet-client-certificate / --kubelet-client-key |
apiserver-kubelet-client.* |
Client certificate when calling the kubelet |
--etcd-cafile |
etcd/ca.crt |
Verify etcd's server certificate |
--etcd-certfile / --etcd-keyfile |
apiserver-etcd-client.* |
Client certificate when calling etcd |
--proxy-client-cert-file / --proxy-client-key-file |
front-proxy-client.* |
Client certificate when proxying to extension API servers |
--requestheader-client-ca-file |
front-proxy-ca.crt |
The front-proxy CA |
--service-account-key-file |
sa.pub |
Verify ServiceAccount tokens |
--service-account-signing-key-file |
sa.key |
Sign ServiceAccount tokens |
kube-controller-manager
| Flag | File | Purpose |
|---|---|---|
--kubeconfig |
controller-manager.conf |
Connect to the API server |
--cluster-signing-cert-file / --cluster-signing-key-file |
ca.crt / ca.key |
Sign approved CSRs (this is what signed jane's certificate) |
--root-ca-file |
ca.crt |
Put into each namespace's kube-root-ca.crt ConfigMap so Pods can verify the API server |
--service-account-private-key-file |
sa.key |
Sign legacy ServiceAccount token Secrets |
etcd
sudo grep -E 'pki|client-cert-auth' /etc/kubernetes/manifests/etcd.yaml
| Flag | File | Purpose |
|---|---|---|
--cert-file / --key-file |
etcd/server.* |
Server certificate for clients |
--trusted-ca-file |
etcd/ca.crt |
Trust client certificates signed by the etcd CA |
--client-cert-auth=true |
Require client certificates | |
--peer-cert-file / --peer-key-file |
etcd/peer.* |
Certificate between members |
--peer-trusted-ca-file |
etcd/ca.crt |
Trust peer certificates signed by the etcd CA |
These are the same values etcdctl snapshot save needed in the backup section: --cacert is the etcd CA, and --cert / --key can be apiserver-etcd-client or etcd/server, since both are signed by the etcd CA.
kubelet
The kubelet lives outside the manifests directory, as a systemd service:
/etc/kubernetes/kubelet.conf: its kubeconfig for the API server. The client certificate isn't embedded; it points at/var/lib/kubelet/pki/kubelet-client-current.pem./var/lib/kubelet/config.yaml:authentication.x509.clientCAFile: /etc/kubernetes/pki/ca.crtmakes the kubelet trust the API server'sapiserver-kubelet-clientcertificate./var/lib/kubelet/pki/kubelet.crt: the kubelet's own server certificate. By default it's self-signed rather than signed by the cluster CA, which is why tools such as metrics-server often need--kubelet-insecure-tls.
How Worker Nodes Get Their Certificates
On k8s-w1, /etc/kubernetes/pki contains only one file:
ls /etc/kubernetes/pki
# ca.crt
Workers never receive a CA private key. When they join, they go through TLS bootstrapping:
kubeadm join <cp1 IP>:6443 --token <token> \
--discovery-token-ca-cert-hash sha256:<hash>
- Discovery: the worker fetches the cluster CA from the API server.
--discovery-token-ca-cert-hashis the SHA-256 of the CA's public key, so the worker can confirm it's talking to the right cluster and not an impostor. - Bootstrap: using the bootstrap token as a temporary credential, the kubelet generates a key pair and submits a CSR.
- Signing: kube-controller-manager auto-approves CSRs from bootstrap tokens and signs them with the Kubernetes CA.
- The kubelet writes the certificate to
/var/lib/kubelet/pki/kubelet-client-current.pem, and from then on uses it instead of the token.
If you've lost the original join command, the hash can be computed from ca.crt on the control plane:
openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt \
| openssl rsa -pubin -outform der 2>/dev/null \
| openssl dgst -sha256 -hex | sed 's/^.* //'
Or simply regenerate the whole command, token included:
kubeadm token create --print-join-command
Expiry, Renewal, and Rotation
Lifetimes
| Item | Validity | Who renews it |
|---|---|---|
| The three CAs | 10 years | Manual (out of scope for the CKA) |
Certificates in /etc/kubernetes/pki |
1 year | kubeadm certs renew or kubeadm upgrade |
admin.conf, super-admin.conf, controller-manager.conf, scheduler.conf |
1 year | kubeadm certs renew or kubeadm upgrade |
| kubelet client certificate | 1 year | The kubelet itself (automatic rotation) |
sudo kubeadm certs check-expiration
The output has two tables: the leaf certificates with their expiry date, remaining time and signing CA, then the CAs. kubelet.conf isn't in the list, because the kubelet takes care of its own certificate.
Renewing with kubeadm
As covered in the cluster maintenance post, kubeadm upgrade apply renews these certificates by default. To renew manually:
sudo kubeadm certs renew all # everything
sudo kubeadm certs renew apiserver # or just one
Renewal reuses the existing CA and keeps the same SANs, so nothing else in the cluster needs to change. But the running components keep the old certificates in memory, so restart the static Pods afterwards:
sudo mkdir -p /tmp/manifests
sudo mv /etc/kubernetes/manifests/*.yaml /tmp/manifests/
# wait until crictl ps no longer shows kube-apiserver, etcd and the rest
sudo mv /tmp/manifests/*.yaml /etc/kubernetes/manifests/
Then copy the renewed admin.conf to ~/.kube/config again.
Automatic kubelet rotation
kubeadm sets this in /var/lib/kubelet/config.yaml:
rotateCertificates: true
As the client certificate approaches expiry, the kubelet generates a new key, submits a CSR, gets it auto-approved and signed, then switches over. kubelet-client-current.pem is a symlink to the latest file:
ls -l /var/lib/kubelet/pki/
💡 A node that was off for a year
Rotation only happens while the kubelet is running. If a VM is shut down long enough for its kubelet certificate to expire, the kubelet can't authenticate anymore and the node stays NotReady. The quickest fix is usually to remove it and join it again with a new token.
Adding a SAN to the API server certificate
kubeadm certs renew keeps the existing SANs, so adding a new name or IP (a load balancer, a new DNS name) means regenerating the certificate:
# 1. Export the current ClusterConfiguration
kubectl -n kube-system get cm kubeadm-config -o jsonpath='{.data.ClusterConfiguration}' > kubeadm.yaml
# 2. Add the new entries under apiServer.certSANs
# apiServer:
# certSANs:
# - k8s-api.lab.local
# - 192.168.122.100
# 3. Move the old certificate away, or kubeadm will reuse it
sudo mv /etc/kubernetes/pki/apiserver.{crt,key} /tmp/
# 4. Generate a new one
sudo kubeadm init phase certs apiserver --config kubeadm.yaml
# 5. Save the change back so future upgrades keep it
sudo kubeadm init phase upload-config kubeadm --config kubeadm.yaml
Then restart kube-apiserver (move its manifest out and back in), and confirm with openssl x509 -ext subjectAltName.
Inspecting Certificates with openssl
A handful of commands covers almost everything:
# Everything
openssl x509 -in apiserver.crt -noout -text
# Just who, signed by whom, and when
openssl x509 -in apiserver.crt -noout -subject -issuer -dates
# Just the SAN
openssl x509 -in apiserver.crt -noout -ext subjectAltName
# Was it signed by this CA?
openssl verify -CAfile ca.crt apiserver.crt
# apiserver.crt: OK
# Do the certificate and private key belong together? (the two hashes must match)
openssl x509 -in apiserver.crt -noout -pubkey | sha256sum
openssl pkey -in apiserver.key -pubout | sha256sum
All the files under /etc/kubernetes/pki are readable only by root, so add sudo or work as root.
Troubleshooting Certificate Problems
Certificate problems usually show up in one of two ways.
kubectl can't connect
| Error | Likely cause |
|---|---|
x509: certificate has expired or is not yet valid |
Certificate expired, or the clock is off (the VM snapshot case from the kubeadm post) |
x509: certificate signed by unknown authority |
The CA in your kubeconfig doesn't match the cluster, e.g. a stale ~/.kube/config after rebuilding the cluster |
x509: certificate is valid for ..., not ... |
You're connecting with a name or IP that isn't in the API server certificate's SAN |
You must be logged in to the server (Unauthorized) |
The client certificate is expired or wasn't signed by the cluster CA |
A control plane component won't start
When the API server itself is down, kubectl is useless, so go one layer down to the container runtime:
sudo crictl ps -a | grep kube-apiserver
sudo crictl logs <container-id>
# if the container keeps getting recreated, the logs are also here:
sudo ls /var/log/pods/
Typical messages and what to check:
open /etc/kubernetes/pki/apiserver.crt: no such file or directory: a wrong path in the manifest, often a typo planted by the exam. Compare eachpkiflag against the files actually in the directory.- An error connecting to
127.0.0.1:2379withcertificate signed by unknown authority: the API server's etcd flags point at the wrong CA or certificate, such as--etcd-cafileset toca.crtinstead ofetcd/ca.crt. tls: private key does not match public key: thecertandkeyflags point at files from different pairs. Check with thepubkeyhash comparison above.
The method is always the same: read the flags in the manifest → check the files exist → check with openssl that the certificate is signed by the right CA, hasn't expired, has the right SAN, and matches its key. After fixing the manifest, the kubelet notices the change and recreates the static Pod by itself.
💡 Keep a backup before editing a manifest
Copy it outside /etc/kubernetes/manifests/ first (sudo cp kube-apiserver.yaml /tmp/). Don't leave the backup inside the manifests directory, or the kubelet will try to run it as a second static Pod.
Summary
- A kubeadm cluster has three CAs: the Kubernetes CA, the etcd CA and the front-proxy CA, each defining its own circle of trust.
sa.key/sa.pubis a key pair for ServiceAccount tokens, not a certificate. - Nearly every connection inside the cluster is mTLS: servers present certificates whose SANs must match the address, and clients present certificates whose
CNbecomes the user andOthe groups for RBAC. - Control plane components use certificates directly (flags in
/etc/kubernetes/manifests/) or through kubeconfigs in/etc/kubernetes/*.conf. - Workers join through TLS bootstrapping and only hold
ca.crt; the kubelet rotates its own client certificate withrotateCertificates: true. - Leaf certificates last 1 year and CAs 10 years; check with
kubeadm certs check-expiration, renew withkubeadm certs renewand restart the static Pods. Adding a SAN means regenerating withkubeadm init phase certs apiserver. - For troubleshooting: read the manifest flags, check the files exist, then use
openssl x509andopenssl verifyto check the CA, expiry, SAN and key.
References
- Kubernetes - PKI certificates and requirementskubernetes.io
- Kubernetes - Certificate Management with kubeadmkubernetes.io
- Kubernetes - TLS bootstrappingkubernetes.io
- Kubernetes - Configure Certificate Rotation for the Kubeletkubernetes.io
- Kubernetes - Authenticating (X509 client certificates)kubernetes.io
- Kubernetes - Using Node Authorizationkubernetes.io
- Kubernetes - Configure the Aggregation Layerkubernetes.io