0
0
Kubernetesdevops~20 mins

kubectl get for listing resources in Kubernetes - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Kubectl Get Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Output of kubectl get pods with label filter
What is the output of the command kubectl get pods -l app=web if the cluster has three pods: web-1 (Running), web-2 (Pending), and db-1 (Running)?
Kubernetes
kubectl get pods -l app=web
A
NAME   READY   STATUS    RESTARTS   AGE
web-1  1/1     Running   0          5m
web-2  0/1     Pending   0          2m
B
NAME   READY   STATUS    RESTARTS   AGE
db-1   1/1     Running   0          10m
C
NAME   READY   STATUS    RESTARTS   AGE
web-1  1/1     Running   0          5m
db-1   1/1     Running   0          10m
DNo resources found.
Attempts:
2 left
💡 Hint
The label selector -l app=web filters pods with label app=web only.
🧠 Conceptual
intermediate
1:30remaining
Understanding kubectl get resource types
Which resource type will kubectl get svc list in a Kubernetes cluster?
APods
BServices
CDeployments
DNodes
Attempts:
2 left
💡 Hint
The abbreviation svc stands for a common Kubernetes resource that exposes an application.
Troubleshoot
advanced
2:00remaining
Troubleshooting kubectl get with namespace option
You run kubectl get pods --namespace=dev but get the error: error: the server doesn't have a resource type "pods". What is the most likely cause?
AThe cluster does not have any pods in the 'dev' namespace.
BThe namespace 'dev' does not exist in the cluster.
CThe kubectl version is incompatible with the cluster API.
DThe kubectl command is missing the resource type before the namespace flag.
Attempts:
2 left
💡 Hint
Check the command syntax and order of arguments.
🔀 Workflow
advanced
2:00remaining
Correct order to list all resources in all namespaces
Which command correctly lists all pods in all namespaces with wide output showing node names?
Akubectl get pods -A -o wide
Bkubectl get pods -o wide --all-namespaces
Ckubectl get pods -A --output=wide
Dkubectl get pods --all-namespaces -o wide
Attempts:
2 left
💡 Hint
Short flags can be combined and order matters for readability.
Best Practice
expert
2:30remaining
Choosing the best kubectl get command for resource monitoring
You want to monitor the status of all deployments in the 'production' namespace, refreshing every 5 seconds. Which command is best?
Akubectl get deployments -n production --watch --watch-interval=5s
Bkubectl get deployments -n production --watch -w 5
Ckubectl get deployments -n production --watch --interval=5
Dkubectl get deployments -n production --watch-only --interval=5s
Attempts:
2 left
💡 Hint
Check the official kubectl flags for watching resources.