CKA Practice Question: Cluster Architecture, Installation and Configuration
Which command allows you to view the current context in a kubeconfig file?
⚠ Common exam trap
Watch out — candidates often confuse `kubectl config get-contexts` (which lists all contexts) with `kubectl config current-context` (which shows only the active one), leading them to choose A because they see the current context listed with an asterisk, but the question specifically asks for the command that 'allows you to view the current context' — not all contexts.
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 currently active context from the kubeconfig file. It reads the `current-context` field from the kubeconfig (typically `~/.kube/config`) and outputs its name, making it the most direct way to view the current 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 get-contexts
Why it's wrong here
kubectl config get-contexts lists every context defined in your kubeconfig in a table, with the current context marked by an asterisk in the CURRENT column. It is useful for enumerating available contexts, but it does not single out the current context; you still have to visually scan the output, which makes it the wrong tools when you need the current context name programmatically.
- ✗
kubectl cluster-info
Why it's wrong here
kubectl cluster-info retrieves and prints the URLs of the Kubernetes control-plane components (e.g., kube-apiserver, kube-dns, metrics-server) from the live cluster. It has nothing to do with the local kubeconfig context selection mechanism, so it cannot show you the context name currently in use; it operates against whichever cluster the current context already points to.
- ✗
kubectl config view
Why it's wrong here
kubectl config view dumps the contents of your kubeconfig file(s), including the current-context field, all contexts, clusters, users, and other settings. It is a broad configuration inspection command, not a focused way to retrieve just the current context; parsing its output to extract that one value is unnecessary and error-prone compared to the dedicated subcommand.
- ✓
kubectl config current-context
Why this is correct
kubectl config current-context is the dedicated kubectl subcommand that prints exactly the name of the context currently selected for use, reading the current-context field from your kubeconfig. It is the most direct, script-friendly way to determine which cluster and user your kubectl commands will target, and it returns a nonzero exit status if no current context is set.
Go deeper
Related to this question
About these practice questions
Courseiva writes every CKA question from scratch — 302 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
Same concept, more angles
1 more way 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. Which command creates a kubeconfig file that can be used to authenticate as a specific user?
easy- A.kubectl config set-context
- ✓ B.kubectl config set-credentials
- C.kubectl config create-user
- D.kubectl config set-cluster
Why B: The `kubectl config set-credentials` command creates or updates a user entry in a kubeconfig file, allowing you to specify authentication credentials such as a client certificate, token, or username/password for a specific user. This is the correct way to define a user identity that can later be associated with a context via `kubectl config set-context`.
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.