Hint: Use 'kubectl config set-context --current --namespace=' [OK]
Common Mistakes:
Using non-existent commands like 'kubectl switch namespace'
Omitting '--current' flag
Using wrong command verbs like 'change' or 'set' alone
3. What will be the output of the command kubectl config view --minify | grep namespace after running kubectl config set-context --current --namespace=testing?
medium
A. namespace: default
B. Error: namespace not found
C. No output
D. namespace: testing
Solution
Step 1: Understand what kubectl config set-context --current --namespace=testing does
This command sets the current context's namespace to testing.
This shows the current context's namespace setting, which should now be testing.
Final Answer:
namespace: testing -> Option D
Quick Check:
Namespace after set-context = testing [OK]
Hint: Check current namespace with 'kubectl config view --minify' [OK]
Common Mistakes:
Expecting default namespace after switching
Thinking command shows all namespaces
Assuming error if namespace does not exist yet
4. You ran kubectl config set-context --current --namespace=prod but your commands still affect the default namespace. What is the likely problem?
medium
A. You did not reload your shell or terminal
B. You used the wrong command to switch namespace
C. Your current context is not set correctly
D. The namespace prod does not exist
Solution
Step 1: Check if the current context is set correctly
If the current context is not the one you expect, switching namespace won't affect your commands.
Step 2: Understand that namespace switching affects only the current context
Switching namespace changes the namespace in the current context, so if the context is wrong, commands still use default namespace.
Final Answer:
Your current context is not set correctly -> Option C
Quick Check:
Namespace switch affects current context only [OK]
Hint: Verify current context with 'kubectl config current-context' [OK]
Common Mistakes:
Assuming shell reload is needed
Thinking namespace must exist before switching
Using wrong command syntax
5. 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
A. kubectl config set-context --current --namespace=staging
kubectl get pods
kubectl config view --minify | grep namespace
B. kubectl namespace staging
kubectl get pods
kubectl config current-context
C. kubectl switch namespace staging
kubectl get pods
kubectl config get-contexts
D. kubectl set namespace staging
kubectl get pods
kubectl config get-namespaces
Solution
Step 1: Set the current context's namespace to staging
Use kubectl config set-context --current --namespace=staging to switch namespace context.
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.
Final Answer:
kubectl config set-context --current --namespace=staging
kubectl get pods
kubectl config view --minify | grep namespace -> Option A
Quick Check:
Set context namespace then verify with config view [OK]
Hint: 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
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.