Skip to main content
In this lesson you’ll learn how to create the TLS certificates required for a Kubernetes cluster using OpenSSL. While there are several tooling options (Easy-RSA, CFSSL, OpenSSL, etc.), this guide demonstrates concepts and examples using OpenSSL so you can understand the certificate types, common fields (CN/OU), and SANs required by Kubernetes components. Tools & references:

CA (Certificate Authority)

The cluster CA signs all other cluster certificates. Keep its private key secret and backed up: losing the CA key prevents signing new certs and can complicate cluster recovery.
Protect your CA private key (ca.key). If it is compromised, all certificates signed by that CA must be revoked and reissued. Use strict filesystem permissions and consider storing the CA key in a secure secret management system.
Generate the CA private key, then a CSR and a self-signed root certificate:
Important: ensure the root certificate contains the Basic Constraints CA:TRUE. Use an OpenSSL config with a v3_ca section or pass -extensions/-extfile when creating a CA certificate so TLS clients treat it as a CA.
The image is a diagram titled "Certificate Authority (CA)" showing a decorative certificate labeled "KUBERNETES_CA" flanked by UI buttons for ca.key, ca.csr and ca.crt. To the right are actions like "Generate Keys," "Certificate Signing Request," and "Sign Certificates."

Client certificates (users and system components)

Client certificates authenticate users and components to the API server and etcd. The certificate Common Name (CN) identifies the user or component in audit logs and RBAC. For example, to make a user a cluster admin include OU=system:masters in the CSR. Generate an admin client certificate signed by your CA:
You can use the certificate pair with curl or kubectl. Example: curl using the client certs (API server must be reachable at the host/port shown):
Minimal kubeconfig snippet for kubectl using the admin cert:
Common certificate file naming (examples):
A diagram showing Kubernetes client and server TLS certificates, with labeled certificate/key filenames (e.g., admin.crt/admin.key, apiserver.crt/apiserver.key) grouped by components like kube-apiserver, kubelet, etcd and kube-proxy. Icons and green checkmarks indicate status or completion for each certificate pair.

etcd server certificates

etcd requires TLS for both client-server and peer-to-peer communication. Create a server certificate for the etcd HTTPS endpoint and separate peer certificates for inter-member TLS if running an HA cluster. Configure etcd to require client certs (mutual TLS) so only trusted clients signed by your CA can connect. Representative etcd flags and their purpose: Example etcd configuration flags (provide correct paths for your environment):

kube-apiserver certificate (server certificate with SANs)

The kube-apiserver certificate must include every DNS name and IP address clients use to reach the API server in the Subject Alternative Names (SANs). Common names include kubernetes, kubernetes.default, kubernetes.default.svc, kubernetes.default.svc.cluster.local and the cluster IP (e.g., 10.96.0.1) and node IPs. Generate the API server key, CSR using an OpenSSL config containing SANs, and sign with the CA:
Example openssl.cnf fragment specifying SANs:
Always list all relevant hostnames and IPs in alt_names. Modern TLS implementations prioritise SANs over CN and will reject certs that lack correct SAN entries.
A stylized certificate graphic labeled "Kube-api Server" showing certificate details, IPs and encoded text. The left side displays a box with icons for apiserver.crt and apiserver.key.

kube-apiserver runtime flags and certificate locations

When starting the kube-apiserver, supply the CA and server certificate/key, plus any client certificates the API server uses to connect to etcd and kubelets. Example systemd ExecStart snippet (paths correspond to the certificate files above):
Note: the API server needs the CA (--client-ca-file) to verify client (user/component) certificates and it also supplies its own server certificate (--tls-cert-file) to clients.

kubelet server and client certificates (per-node)

Each kubelet exposes an HTTPS endpoint on the node and therefore requires a server certificate that identifies the node (CN or SAN). Kubelets also act as clients (when making requests to the API server) and need client certs. Use the system:node:<nodeName> CN format and include the system:nodes group in OU for node client certs. Example subject for a node client certificate:
  • /CN=system:node:node01/OU=system:nodes
Generate per-node server and client certs for each node (node01, node02, node03) and place the cert/key pairs plus ca.crt into the kubelet kubeconfig or provide them via kubelet flags.
An infographic showing Kubernetes "kubectl Nodes (Server Certificates)" with three nodes (node01, node02, node03), each displaying a certificate image and kubelet components. The top also highlights kubelet.crt and kubelet.key used by the kubelet server.
After generating node client certs, include them in the kubeconfig used by each kubelet so kubelets authenticate to the API server as a node identity.
A Kubernetes diagram showing kubelet client certificates. It depicts a kubelet server with kubelet-client.crt/.key and three node certificates labeled system:node:node01, node02, and node03, each tied to a kubelet.

Inspecting certificates

To view certificate details (SANs, issuer, validity), use OpenSSL:

Final notes

  • Distribute the CA root certificate (ca.crt) to every component that must validate certificates.
  • Restrict access to private keys and use secure storage or secret management where possible.
  • Always include all DNS names and IP addresses in SANs for server certificates — modern clients require SANs.
  • Rotate certificates before expiration and maintain a certificate inventory.
Always include the correct Subject Alternative Names (SANs) in server certificates. Many TLS clients reject certificates that only set the CN and omit SANs.
References

Watch Video