Bird
0
0

You want to switch to namespace analytics and then run a command to list pods in that namespace without specifying the namespace flag each time. Which sequence of commands achieves this?

hard📝 Workflow Q8 of 15
Kubernetes - Namespaces
You want to switch to namespace analytics and then run a command to list pods in that namespace without specifying the namespace flag each time. Which sequence of commands achieves this?
Akubectl config set-context --current --namespace=analytics kubectl get pods
Bkubectl namespace switch analytics kubectl get pods
Ckubectl config use-namespace analytics kubectl get pods
Dkubectl set namespace analytics kubectl get pods
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct command to switch namespace context

    The valid command is 'kubectl config set-context --current --namespace=analytics'.
  2. Step 2: Confirm subsequent commands use new namespace

    After switching, 'kubectl get pods' lists pods in 'analytics' without extra flags.
  3. Final Answer:

    kubectl config set-context --current --namespace=analytics kubectl get pods -> Option A
  4. Quick Check:

    Set context namespace once, then run commands normally [OK]
Quick Trick: Set namespace context once to avoid repeating --namespace flag [OK]
Common Mistakes:
  • Using non-existent commands like 'kubectl namespace switch'
  • Trying 'kubectl config use-namespace' which is invalid
  • Assuming 'kubectl set namespace' exists

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes