1. Certificate Files for the Kube API Server
The Kube API Server manifest—typically located at/etc/kubernetes/manifests/kube-apiserver.yaml—specifies various TLS parameters. The following excerpt demonstrates the configuration and certificate file usage:
- The API server’s serving credentials are provided by files such as
/etc/kubernetes/pki/apiserver.crtand/etc/kubernetes/pki/apiserver.key(demonstrated in later snippets). - A dedicated certificate and key pair is used for secure communication with the ETCD server (specified with the
--etcd-certfileand--etcd-keyfileflags). - A separate certificate is set for authenticating the Kubelet using the flags
--kubelet-client-certificateand--kubelet-client-key.
2. The API Server Serving Certificate
The subsequent snippet confirms the certificate and key utilized by the Kube API server to serve HTTPS traffic:--tls-cert-file and --tls-private-key-file flags, which designate the locations of the certificate file /etc/kubernetes/pki/apiserver.crt and its matching private key /etc/kubernetes/pki/apiserver.key used for HTTPS communications with clients.
3. The ETCD Server Certificate
Understanding ETCD server configuration is critical for troubleshooting certificate-related issues in the control plane. The ETCD pod mounts the PKI directory and specifies its certificate files as demonstrated below:- The ETCD server’s serving certificate is
/etc/kubernetes/pki/etcd/server.crt. - Its matching private key is
/etc/kubernetes/pki/etcd/server.key. - The trusted CA for authenticating clients and establishing peer connections is provided via
/etc/kubernetes/pki/etcd/ca.crt.
4. Analyzing Certificate Details
A closer examination of certificate details using OpenSSL can help confirm that each component is configured correctly.a. Kube API Server Certificate Common Name and Issuer
Run the following OpenSSL command to inspect the API server certificate:- Issuer: CN = kubernetes
- Subject: CN = kube-apiserver
b. Alternate Names Verification
Alternate names in the certificate’s Subject Alternative Name (SAN) list generally include:- controlplane.kubernetes
- kubernetes.default
- kubernetes.default.svc
- kubernetes.default.svc.cluster.local
- IP addresses (e.g., 10.46.98.9)
c. ETCD Server Certificate Common Name
For the ETCD server, inspect the certificate using this command:- Issuer: CN = etcd-ca
- Subject: CN = controlplane
5. Certificate Validity Durations
The validity period of your certificates is crucial to maintaining secure operations.a. Kube API Server Certificate Validity
When you run the OpenSSL command on/etc/kubernetes/pki/apiserver.crt, you may see that the certificate is valid from April 17, 2022, to April 17, 2023—a one-year duration.
b. Root CA Certificate Validity
Inspecting the root CA certificate (e.g.,/etc/kubernetes/pki/ca.crt) reveals a validity period of approximately 10 years (from April 17, 2022, to April 14, 2032).
6. Troubleshooting kubectl Connection and ETCD Certificate Issues
After updating control plane configurations, you might encounter errors such as:server-certificate.crt instead of server.crt). To resolve such issues:
- Ensure the certificate file exists on the host at
/etc/kubernetes/pki/etcd/(typically asserver.crtandserver.key). - Update the ETCD manifest file to use the correct certificate file path.
- Save the changes and allow time for the container to restart.
If you encounter TLS handshake errors (e.g., “certificate signed by unknown authority”) in the API server logs, verify that the ETCD connection references the correct CA file. The ETCD trusted CA should be
/etc/kubernetes/pki/etcd/ca.crt, and the client certificate parameters (--etcd-certfile and --etcd-keyfile) should be consistent with ETCD requirements.7. Final Verification
After resolving certificate configuration issues, verify that communication between components is restored. For example, running:Certificate Overview
This article underscores the importance of verifying certificate and key configurations in your Kubernetes manifests. By ensuring proper file paths and matching certificate data across the API server, ETCD, and Kubelet, you can maintain a secure and reliable control plane environment.