CKA Practice Question: Cluster Architecture, Installation and Configuration
You run `kubectl get pods` and get an error: 'error: You must be logged in to the server (Unauthorized)'. What is the most likely cause?
⚠ Common exam trap
Many exam-takers confuse authentication errors (401 Unauthorized) with connectivity errors (connection refused) or authorization errors (403 Forbidden), leading them to incorrectly suspect the API server is down or a resource is missing.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
The kubeconfig file is missing or invalid.
The error 'You must be logged in to the server (Unauthorized)' indicates that the kubectl client successfully reached the API server, but the request was rejected because the client's credentials (typically from the kubeconfig file) are missing, expired, or invalid. The kubeconfig file contains the cluster, user, and context information required for authentication; if it is misconfigured or not present, kubectl cannot authenticate and returns this specific HTTP 401 Unauthorized error.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
The kubeconfig file is missing or invalid.
Why this is correct
The error "error you must be logged in to the server (Unauthorized)" or similar, which is implied by the truncated prompt, directly indicates an authentication failure. This occurs when kubectl cannot successfully present valid credentials to the Kubernetes API server, most commonly because the kubeconfig file is either missing, corrupted, or contains incorrect cluster addresses, user certificates, or authentication tokens. Without a valid kubeconfig, the client cannot establish an authenticated session.
- ✗
The API server is not running.
Why it's wrong here
If the Kubernetes API server were not running or unreachable, kubectl would encounter a network-level error rather than an authentication issue. Typical error messages in such scenarios include "The connection to the server <server-address> was refused - did you specify the right host or port?" or "connection refused." The implied error in the prompt suggests a successful connection attempt but a subsequent failure in authentication.
- ✗
The pod does not exist.
Why it's wrong here
When `kubectl get pods` is executed and no pods exist in the current or specified namespace, the API server successfully processes the request and returns an empty list of resources. The kubectl client then displays a user-friendly message such as "No resources found in <namespace> namespace." This is fundamentally different from an authentication error, as the client successfully communicated with an authenticated API server.
- ✗
The namespace does not exist.
Why it's wrong here
If a `kubectl get pods` command specifies a namespace that does not exist (e.g., `kubectl get pods -n non-existent-namespace`), the API server would respond with a "NotFound" error. The precise message would typically be "Error from server (NotFound): namespaces "non-existent-namespace" not found." This indicates that the API server was successfully contacted and authenticated, but it could not locate the requested resource (the namespace itself).
Go deeper
Related to this question
About these practice questions
This CKA question is part of Courseiva's 302-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This CKA practice question is part of Courseiva's free CNCF certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the CKA exam.