CKA Practice Question: Cluster Architecture, Installation and Configuration
You have a kubeconfig file with multiple contexts. How do you switch to the context named 'prod-cluster'?
⚠ Common exam trap
Many candidates confuse `set-context` (which defines a context) with `use-context` (which activates it), leading them to pick option B instead of D.
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
✓
kubectl config use-context prod-cluster
`kubectl config use-context` is the command specifically designed to switch the current context in a kubeconfig file. It updates the `current-context` field in the kubeconfig to point to the specified context, which then determines which cluster, user, and namespace are used by default for subsequent `kubectl` commands.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
kubectl config set-cluster prod-cluster
Why it's wrong here
kubectl config set-cluster prod-cluster updates the cluster entry named prod-cluster in the kubeconfig — for example, changing its server URL or certificate-authority data. It does not touch the current-context field, so even if a context named prod-cluster exists, the active cluster remains unchanged. The command is for configuring connection details, not for runtime context switching.
- ✗
kubectl config set-context prod-cluster
Why it's wrong here
kubectl config set-context prod-cluster modifies the context definition named prod-cluster, such as which cluster, user, and namespace it references. However, modifying a context's properties does not make it active; it only writes to the contexts section of the kubeconfig. To actually switch the current context, you must run kubectl config use-context, which updates the current-context field.
- ✗
kubectl config view prod-cluster
Why it's wrong here
kubectl config view prod-cluster prints the merged kubeconfig contents, and if a context name is supplied, it restricts the display to that context's definition (although the positional argument is not standard; the command expects flags like --output). This is a read-only operation — it shows configuration data from disk or in-cluster sources but never modifies or selects which context is active. Running view cannot change the context kubectl will use for subsequent commands.
- ✓
kubectl config use-context prod-cluster
Why this is correct
kubectl config use-context prod-cluster is the correct command because it explicitly writes the name prod-cluster to the current-context field in the kubeconfig file. After this runs, kubectl commands resolve the current context to prod-cluster and load its associated cluster and user credentials. It is the direct counterpart to the question's intent of switching the active context.
Go deeper
Related to this question
About these practice questions
One of 302 original CKA practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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.