In this guide, you’ll learn how to encrypt and authenticate all traffic in a Kubernetes cluster using TLS. We’ll cover:Documentation Index
Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
Use this file to discover all available pages before exploring further.
- The role of keys, certificates, and Certificate Authorities (CAs)
- TLS requirements for Kubernetes control plane and data plane
- Mapping server and client certificates to Kubernetes components
- Best practices for generating and signing certificates
1. TLS Fundamentals: Keys, Certificates, and CAs
Before diving into Kubernetes-specific details, let’s recap the core concepts:-
Public/Private Key Pair
Each entity (server or client) generates a private key and a corresponding public key. -
Server Certificates (
server.crt,server.key)
Used by services exposing HTTPS endpoints. -
Client Certificates (
client.crt,client.key)
Prove a client’s identity to the server. -
Certificate Authority (CA) (
ca.crt,ca.key)
Signs certificates and establishes a trust chain.
Naming Conventions
- Public certificates: use
.crtor.pem - Private keys: use
.keyor include “key” in the filename - Examples:
apiserver.crt+apiserver.key,client.pem,client-key.pem
2. TLS Requirements in Kubernetes
All Kubernetes communications—intra-cluster or external—must be both encrypted and authenticated:-
Server Certificates
Each service that exposes an HTTPS endpoint (API server, etcd, kubelet). -
Client Certificates
Every client connecting to those services (kubectl, system components).
3. Certificate Assignments for Kubernetes Components
3.1 Server-Side Certificates
| Component | Certificate File | Key File |
|---|---|---|
| API Server | apiserver.crt | apiserver.key |
| etcd Server | etcd-server.crt | etcd-server.key |
| Kubelet (worker) | kubelet.crt | kubelet.key |
3.2 Client-Side Certificates
| Client | Certificate File | Key File |
|---|---|---|
Administrator (kubectl) | admin.crt | admin.key |
| Kube-Scheduler | scheduler.crt | scheduler.key |
| Kube-Controller-Manager | controller-manager.crt | controller-manager.key |
| Kube-Proxy | kube-proxy.crt | kube-proxy.key |
Inter-Service Authentication
- API Server → etcd: The API server acts as a client to etcd. You can reuse
apiserver.crt/keyor use a dedicated pair. - API Server → Kubelet: When the API server calls kubelet’s HTTPS endpoint, it presents a client certificate (either its serving cert or a separate client cert).
4. Certificate Authority and Signing Strategy
You need a CA to sign every server and client certificate. Kubernetes supports:- A single CA for all components
- Multiple CAs (e.g., one CA for etcd, another for the rest)
- CA Public Certificate:
ca.crt - CA Private Key:
ca.key
Never store
ca.key on nodes that aren’t fully secured. Loss of the CA key compromises your entire cluster.4.1 CA-Managed Certificate Hierarchy
- Generate the CA key and certificate (
ca.key/ca.crt). - For each server and client:
- Generate a CSR (Certificate Signing Request).
- Sign the CSR with the CA key, specifying the proper Extended Key Usages (
serverAuthorclientAuth).
- Distribute the signed certificates and corresponding keys to each component.
5. References and Further Reading
| Resource | Description |
|---|---|
| Kubernetes Official Docs | Deep dive into components and TLS setup |
| Certificate Management (CA) | Best practices for CA hierarchies |
| mTLS in Distributed Systems | Benefits of mutual TLS in microservices |