0
0
Kubernetesdevops~10 mins

Switching namespace context in Kubernetes - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the command to switch the current namespace context in kubectl.

Kubernetes
kubectl config set-context --current --namespace=[1]
Drag options to blanks, or click blank then click option'
Aconfig
Bcontext
Cproduction
Ddefault
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'config' or 'context' as namespace names, which are invalid.
2fill in blank
medium

Complete the command to view the current namespace in kubectl context.

Kubernetes
kubectl config view --minify [1]
Drag options to blanks, or click blank then click option'
A-A
B-o jsonpath='{.contexts[0].context.namespace}'
C-o yaml
D-v
Attempts:
3 left
💡 Hint
Common Mistakes
Using grep without proper output formatting, causing no output.
3fill in blank
hard

Fix the error in the command to switch namespace context.

Kubernetes
kubectl config set-context [1] --namespace=staging
Drag options to blanks, or click blank then click option'
A--current
Bcurrent
C--context
Dcontext
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'current' without dashes or '--context' which changes a named context.
4fill in blank
hard

Fill both blanks to create a command that switches to the 'dev' namespace and then lists pods.

Kubernetes
kubectl config set-context [1] --namespace=[2] && kubectl get pods
Drag options to blanks, or click blank then click option'
A--current
Bdev
Cdefault
D--namespace
Attempts:
3 left
💡 Hint
Common Mistakes
Using '--namespace' as the first blank or 'default' instead of 'dev'.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps pod names to their statuses for pods in the current namespace.

Kubernetes
pods_status = { [1]: [2].status.phase for [3] in pods.items() }
Drag options to blanks, or click blank then click option'
Apod.metadata.name
Bpod
D{
Attempts:
3 left
💡 Hint
Common Mistakes
Not starting with '{', or using wrong variable names.