2. Which of the following is the correct syntax to list all pods in the current Kubernetes namespace using kubectl?
easy
A. kubectl get pods
B. kubectl list pods
C. kubectl show pods
D. kubectl describe pods
Solution
Step 1: Recall kubectl commands for listing resources
The command to list resources is kubectl get, followed by the resource type.
Step 2: Evaluate options
Only kubectl get pods uses the correct syntax kubectl get pods. Options A and B are invalid commands, and D shows detailed info, not a simple list.
Final Answer:
kubectl get pods -> Option A
Quick Check:
List pods = kubectl get pods [OK]
Hint: Use 'kubectl get' to list Kubernetes resources [OK]
Common Mistakes:
Using 'list' or 'show' instead of 'get'
Confusing 'describe' with listing
Adding extra words after 'pods'
3. Given the command kubectl get pods -o wide, what extra information will you see compared to kubectl get pods?
medium
A. Detailed pod logs
B. Extended pod information including node and IP
C. Only pod names without status
D. List of services instead of pods
Solution
Step 1: Understand the '-o wide' option
The -o wide flag shows additional columns like node name and pod IP address.
Step 2: Compare output differences
Extended pod information including node and IP correctly describes the extra info. Detailed pod logs is about logs, not shown here. Only pod names without status is incorrect as status is shown by default. List of services instead of pods is unrelated.
Final Answer:
Extended pod information including node and IP -> Option B
Quick Check:
-o wide = more pod details [OK]
Hint: Use '-o wide' to see node and IP info for pods [OK]
Common Mistakes:
Thinking '-o wide' shows logs
Assuming it hides status info
Confusing pods with services
4. You run kubectl get pod mypod but get an error saying the pod does not exist. What is the most likely cause?
medium
A. You are in the wrong namespace
B. The pod name is misspelled
C. The pod has already been deleted
D. All of the above
Solution
Step 1: Check common reasons for pod not found error
The error can happen if the pod name is wrong, the pod was deleted, or you are looking in the wrong namespace.
Step 2: Evaluate options
All options B, C, and D are valid causes. Therefore, All of the above which includes all is correct.
Final Answer:
All of the above -> Option D
Quick Check:
Pod not found = wrong namespace, name, or deleted [OK]
Hint: Check namespace, spelling, and pod existence [OK]
Common Mistakes:
Ignoring namespace context
Assuming pod always exists
Not verifying pod name spelling
5. You want to update the image of a deployment named webapp to version v2 using kubectl. Which command correctly performs this update?
hard
A. kubectl update deployment webapp --image=webapp:v2
B. kubectl edit deployment webapp image=webapp:v2
C. kubectl set image deployment/webapp webapp=webapp:v2
D. kubectl change image webapp webapp:v2
Solution
Step 1: Identify the correct kubectl command to update deployment image
The command kubectl set image is used to update container images in deployments.
Step 2: Analyze each option
kubectl set image deployment/webapp webapp=webapp:v2 uses correct syntax: kubectl set image deployment/webapp webapp=webapp:v2. Options A, C, and D use invalid or incorrect commands.
Final Answer:
kubectl set image deployment/webapp webapp=webapp:v2 -> Option C
Quick Check:
Update image = kubectl set image [OK]
Hint: Use 'kubectl set image' to update deployment containers [OK]