CKA Practice Question: Cluster Architecture, Installation and Configuration
You have a kubeconfig file with multiple contexts. You want to temporarily switch to a different context for a single kubectl command. Which flag should you use?
⚠ Common exam trap
Watch out — candidates often confuse `--context` with `--kubeconfig` or `--cluster`, thinking they need to specify the file or cluster directly, when the correct approach is to use the context name that bundles cluster, user, and namespace together.
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
✓
--context
The `--context` flag allows you to override the current context from the kubeconfig file for a single kubectl command. This is the correct way to temporarily switch contexts without modifying the kubeconfig file's current-context field. The flag accepts the context name as defined in the kubeconfig's contexts array.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
--context
Why this is correct
The `--context` flag allows you to temporarily override the active context defined in your kubeconfig for a single `kubectl` execution. This is highly useful for executing commands against a different environment (like production or staging) without permanently changing your active context via `kubectl config use-context`. It targets the specific combination of cluster, user, and namespace defined under that named context.
- ✗
--user
Why it's wrong here
The `--user` flag overrides only the authentication credentials (user) for the current command, rather than switching the entire context. While this allows you to execute a command with different RBAC permissions, it still targets the cluster and namespace defined in your currently active context. It does not allow you to seamlessly switch to a completely different cluster-user-namespace triplet.
- ✗
--cluster
Why it's wrong here
Using the `--cluster` flag instructs `kubectl` to send the API request to a specific cluster endpoint defined in your kubeconfig, but it does not modify the associated user credentials or default namespace. If the current active user does not have valid credentials or certificates mapped to the newly specified cluster, the command will fail with authentication or authorization errors. It is not a substitute for switching the unified context.
- ✗
--kubeconfig
Why it's wrong here
The `--kubeconfig` flag is used to point `kubectl` to an entirely different configuration file on your local filesystem, bypassing the default path at `~/.kube/config`. While this file may contain its own set of contexts, the flag itself does not select or switch between multiple contexts defined within a single, currently loaded configuration file.
Go deeper
Related to this question
About these practice questions
This CKA question is part of Courseiva's 726-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.