openssl, and follow two real troubleshooting scenarios where kube-apiserver lost connectivity because of certificate path or CA mismatches — including diagnosis and remediation steps.
Key topics: kube-apiserver TLS, etcd TLS, certificate paths, openssl inspection, kube-apiserver ↔ etcd mTLS troubleshooting, kubectl connection errors.
1) Locate the kube-apiserver manifest and certificate paths
Static pod manifests live under/etc/kubernetes/manifests. Open the kube-apiserver manifest to discover which certificate and key files the API server uses.
Note: These files typically live under
/etc/kubernetes/pki and subdirectories. If any path in the manifest points to a non-existent file, the static pod will fail to start and kubelet logs (or the container logs) will show the error.
2) etcd manifest and its server/peer certificates
Open the etcd static pod manifest (for example/etc/kubernetes/manifests/etcd.yaml) to see how etcd is configured for server and peer TLS:
Anything related to etcd server/peer TLS should be under
/etc/kubernetes/pki/etcd. If etcd logs reference missing files, verify the directory listing with ls /etc/kubernetes/pki/etcd.
3) Inspect certificate details with openssl
Useopenssl x509 to inspect certificate Subject (CN), Issuer (CA), SAN entries, and validity.
- To inspect the kube-apiserver certificate:
-
Subject CN:
kube-apiserver. -
Issuer (signing CA):
kubernetes. -
SANs: hostnames and IPs the cert is valid for. If a client name (e.g.
kube-master) is not in the SANs, TLS will not validate that name. - To inspect the etcd server certificate:
- Subject CN:
controlplane. - Issuer (signing CA):
etcd-ca.
- API server certs are often short-lived (1 year in the example).
- Root CAs (e.g.
kubernetes CA) often have long lifetimes (e.g. ~10 years).
If you need to inspect certificates, use
openssl x509 -in <path-to-crt> -text -noout. Always check both the Subject and Issuer fields and the SANs to ensure identity and trust chains match the configuration.4) Troubleshooting: kubectl stops responding after a change window
Symptom:crictl, ctr, docker):
4.1 Symptom: kube-apiserver logs show repeated connection errors to etcd
Example kube-apiserver log lines:127.0.0.1:2379 (connection refused). Inspect etcd container logs and the etcd manifest.
4.2 Root cause example #1: etcd manifest references a nonexistent certificate file
etcd logs might include:/etc/kubernetes/pki/etcd/server-certificate.crt which does not exist; the correct file is /etc/kubernetes/pki/etcd/server.crt.
Fix:
- Edit
/etc/kubernetes/manifests/etcd.yaml. - Correct the
--cert-fileargument to/etc/kubernetes/pki/etcd/server.crt. - Save the manifest — kubelet will detect the change and restart the static pod automatically.
- etcd should start and bind to
127.0.0.1:2379and10.46.98.9:2379. - kube-apiserver reconnects to etcd and kubectl begins working again.
5) Troubleshooting: TLS handshake timeout / “certificate signed by unknown authority”
Another outage symptom:5.1 Root cause example #2: kube-apiserver configured to trust the wrong CA for etcd
Inspect the kube-apiserver manifest and confirm the--etcd-cafile setting. An incorrect setting looks like:
/etc/kubernetes/pki/ca.crt may be the Kubernetes cluster CA (which issued API server certs), not the etcd CA (/etc/kubernetes/pki/etcd/ca.crt). If kube-apiserver is not using the CA that signed etcd’s server certificate, or if etcd is not trusting the CA that signed kube-apiserver’s client cert, TLS handshakes will fail.
Correct configuration should look like:
- Edit
/etc/kubernetes/manifests/kube-apiserver.yaml. - Point
--etcd-cafileto the etcd CA:/etc/kubernetes/pki/etcd/ca.crt. - Ensure
--etcd-certfile/--etcd-keyfilerefer to the apiserver-etcd client credentials. - Save the manifest — kubelet will restart the kube-apiserver static pod with the new flags.
5.2 Result
- Once
--etcd-cafileis corrected and the apiserver client cert/key are valid and signed by the etcd CA (or vice versa), TLS handshakes succeed. - etcd stops rejecting connections and kube-apiserver resumes normal operation, restoring kubectl access.
6) Checklist and quick-reference when debugging kube-apiserver ↔ etcd TLS issues
- Verify static pod manifests: check
/etc/kubernetes/manifests/kube-apiserver.yamland/etc/kubernetes/manifests/etcd.yaml. - Confirm file paths in the manifests exist on disk (
ls /etc/kubernetes/pkiand/etc/kubernetes/pki/etcd). - Ensure mutual TLS alignment:
- etcd server certs and CA are under
/etc/kubernetes/pki/etcd/(e.g.server.crt,server.key,ca.crt). - kube-apiserver should use
--etcd-cafile=/etc/kubernetes/pki/etcd/ca.crt. - kube-apiserver should present the client cert/key set via
--etcd-certfile&--etcd-keyfile.
- etcd server certs and CA are under
- Use openssl to inspect certificates:
openssl x509 -in <cert> -text -noout. - Typical log indicators:
- Connection refused to
127.0.0.1:2379→ etcd not listening; check etcd logs and manifest file paths. - TLS handshake timeout /
tls: bad certificate→ CA mismatch or invalid client cert; compare issuers and CA files.
- Connection refused to
- Editing static pod manifests triggers kubelet to restart the corresponding static pod automatically.
When debugging TLS issues, always compare the
Issuer: field from openssl x509 -in <cert> -text -noout with the CA file path configured in the other component. Mismatched CAs are a common source of TLS handshake failures.Links and references
- Kubernetes concepts: https://kubernetes.io/docs/concepts/
- Kubernetes static pods: https://kubernetes.io/docs/tasks/configure-pod-container/static-pod/
- etcd security and SSL/TLS: https://etcd.io/docs/v3.4/op-guide/security/
- OpenSSL x509 manual: https://www.openssl.org/docs/man1.1.1/man1/openssl-x509.html
This completes the walkthrough for viewing certificate details and troubleshooting kube-apiserver ↔ etcd TLS issues.