Bird
0
0

You want to run multiple commands in the staging namespace without typing --namespace=staging each time. Which sequence of commands correctly sets this up and verifies it?

hard📝 Workflow Q15 of 15
Kubernetes - Namespaces
You want to run multiple commands in the staging namespace without typing --namespace=staging each time. Which sequence of commands correctly sets this up and verifies it?
Akubectl config set-context --current --namespace=staging kubectl get pods kubectl config view --minify | grep namespace
Bkubectl namespace staging kubectl get pods kubectl config current-context
Ckubectl switch namespace staging kubectl get pods kubectl config get-contexts
Dkubectl set namespace staging kubectl get pods kubectl config get-namespaces
Step-by-Step Solution
Solution:
  1. Step 1: Set the current context's namespace to staging

    Use kubectl config set-context --current --namespace=staging to switch namespace context.
  2. Step 2: Verify by listing pods and checking namespace in current context

    Running kubectl get pods uses the new namespace by default. Checking with kubectl config view --minify | grep namespace confirms the namespace is set.
  3. Final Answer:

    kubectl config set-context --current --namespace=staging kubectl get pods kubectl config view --minify | grep namespace -> Option A
  4. Quick Check:

    Set context namespace then verify with config view [OK]
Quick Trick: Set namespace once with config set-context, then run commands [OK]
Common Mistakes:
  • Using non-existent commands like 'kubectl switch namespace'
  • Not verifying namespace change
  • Confusing context commands with namespace commands

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes