How to View the Active Kubeconfig Context
Which kubeconfig context is currently active?
Quick Answer
The answer is `kubectl config current-context`. This command directly queries your kubeconfig file and prints the name of the currently active context, which is the default cluster, user, and namespace combination that kubectl will use for all subsequent commands. On the Certified Kubernetes Administrator CKA exam, this is a foundational concept because misidentifying the active context is a common source of errors when managing multiple clusters—you might accidentally run destructive commands against the wrong environment. The exam often tests your ability to verify context before performing administrative tasks, and a frequent trap is confusing `kubectl config view` (which shows all contexts) with the specific command to show only the active one. Remember the memory tip: "current-context" is the only command that gives you the single, active answer—think of it as asking kubectl "who's in charge right now?"
⚠ Common exam trap
A common mix-up: candidates confuse `kubectl config get-contexts` (which shows all contexts with an asterisk on the active one) with a command that directly outputs only the active context, leading them to choose option C instead of the more precise 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 current-context
`kubectl config current-context` is the dedicated kubectl command that displays the name of the currently active context from the kubeconfig file. The active context determines which cluster, user, and namespace are used by default for kubectl commands, making this the precise way to identify the active context.
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 view
Why it's wrong here
Shows all contexts, not current.
- ✗
kubectl cluster-info
Why it's wrong here
Shows cluster info.
- ✗
kubectl config get-contexts
Why it's wrong here
Lists contexts with '*' for current.
- ✓
kubectl config current-context
Why this is correct
Directly shows current context.
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 →
Same concept, more angles
2 more ways this is tested on CKA
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. An admin wants to view the current context in their kubeconfig. Which command should they use?
medium- A.kubectl config get-contexts
- B.kubectl cluster-info
- ✓ C.kubectl config current-context
- D.kubectl config view
Why C: `kubectl config current-context` is the exact command to display the currently active context from the kubeconfig file. The context includes the cluster, namespace, and user that `kubectl` will use by default. This is a direct query of the `current-context` field in the kubeconfig YAML/JSON structure.
Variation 2. A cluster has multiple kubeconfig files. You want to set the current context to 'admin@production' for all future kubectl commands. Which command should you run?
medium- A.kubectl config set-context admin@production
- ✓ B.kubectl config use-context admin@production
- C.kubectl config set-cluster admin@production
- D.kubectl config get-contexts admin@production
Why B: The `kubectl config use-context` command is used to set the current context in a kubeconfig file, which determines the cluster, user, and namespace that kubectl will use by default for all subsequent commands. Option B correctly specifies `admin@production` as the context to switch to, making it the active context for future kubectl operations.
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.