Generating the CA Certificate
To begin, generate the CA private key, create a certificate signing request (CSR) with the common name “KUBERNETES-CA”, and then self-sign it. The CSR includes all certificate details but is unsigned until the CA key is applied. Run these commands to create your CA certificates:ca.crt) and its corresponding private key (ca.key).
Generating Client Certificates
Admin User Certificate
For the admin user, a private key is generated first. Then, a CSR is created with the common name “kube-admin”. The certificate is signed using the CA certificate and private key. This naming is essential since it is used within audit logs and other system functions. Run the following commands to generate the admin user’s certificate:To differentiate admin users from basic users, you can include group details in the CSR by specifying the Organizational Unit (OU). For example, adding the group
system:masters grants administrative privileges:Certificate Authorities and Mutual Trust
Both clients and servers must use a shared CA root certificate for secure communication. This mutual trust ensures that the certificates presented by each party are signed by a trusted authority, much like how browsers validate a website’s certificate.Generating Server-Side Certificates
ETCD Server Certificate
For the etcd server, which is critical in high-availability deployments, the certificate generation process is analogous to that for clients. The etcd server may also require additional peer certificates for secure inter-cluster communication. After generating the key and certificate for the etcd server, reference them in your etcd configuration file. For example, review your configuration via:etcd.yaml might look like this:
The CA root certificate is critical to verify that only valid clients can establish connections with the etcd server.
Kube API Server Certificate
The kube API server is the central component of the Kubernetes control plane. This server is recognized by multiple DNS names and IP addresses, so its certificate must include all alternate names.-
Generate a key and CSR for the kube API server:
-
Create an OpenSSL configuration file (e.g.,
openssl.cnf) with the following content to define Subject Alternative Names (SAN): - Sign the certificate using the CA certificate and key. Once complete, the kube API server certificate is ready for use.
Kubelet Server and Client Certificates
Each Kubernetes node runs a kubelet, which serves as an HTTPS API server to manage node operations. Every node must possess its own key and certificate pair, typically named after the node (e.g., node-01, node-02, node-03). The node-specific certificates are then referenced inside the kubelet configuration file. For example:
Summary
In this article, we covered the following key steps:-
Generating the CA Certificates:
Creating a self-signed CA to sign all other certificates. -
Creating Client Certificates:
Generating certificates for admin users and control plane components (like the kube scheduler, controller manager, and kube proxy) for secure authentication. -
Securing the Kube API Server:
Producing a kube API server certificate that includes multiple DNS names and IP addresses to guarantee trust. -
Generating Server-Side Certificates:
Producing certificates for the etcd server and node-specific certificates for kubelets to enable secure component-to-component communications.



