Bird
0
0

Why does switching namespace context with kubectl config set-context --current --namespace=xyz not affect commands that specify --namespace explicitly?

hard📝 Conceptual Q10 of 15
Kubernetes - Namespaces
Why does switching namespace context with kubectl config set-context --current --namespace=xyz not affect commands that specify --namespace explicitly?
Akubectl caches namespace and ignores changes temporarily
BContext namespace is ignored by kubectl
CNamespace can only be set globally, not per command
DExplicit --namespace flag overrides context namespace setting
Step-by-Step Solution
Solution:
  1. Step 1: Understand namespace precedence in kubectl

    Kubectl uses explicit --namespace flag first if provided, overriding context namespace.
  2. Step 2: Effect on commands

    Commands with explicit --namespace run in that namespace regardless of context setting.
  3. Final Answer:

    Explicit --namespace flag overrides context namespace setting -> Option D
  4. Quick Check:

    Explicit namespace flag has highest priority [OK]
Quick Trick: Explicit --namespace flag always overrides context namespace [OK]
Common Mistakes:
  • Thinking context namespace overrides explicit flag
  • Believing context namespace is ignored
  • Assuming caching delays namespace changes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes