What it means
kubectl checks the API server certificate against the CA in your kubeconfig. "Signed by unknown authority" means the CA doesn't match; "certificate is valid for X, not Y" means you connect by a name or IP that isn't in the certificate's SANs.
Causes and fixes
Most likely first. Run the check, and if it matches, apply the fix.
1. The kubeconfig has a different cluster's CA (copied from elsewhere, or the cluster was rebuilt)
Check:
kubectl config view --raw --minify | grep certificate-authority
Fix: Use the current admin kubeconfig from the control plane.
2. Connecting by a name or IP that's not in the API server certificate's SANs
Check:
openssl s_client -connect <host>:6443 </dev/null 2>/dev/null | openssl x509 -noout -ext subjectAltName
Fix: Use an address the certificate covers, or regenerate the certificate with the extra SAN.
Fix it yourself
A live machine in your browser with this problem already on it. The grader checks the result.
Open the labNo account needed for your first tries.
Related errors
- The connection to the server localhost:8080 was refused - did you specify the right host or port?
kubectl found no kubeconfig and fell back to localhost:8080.
- x509: certificate is valid for a.example.com, not b.example.com
The certificate's Subject Alternative Names don't include the hostname the client used.