What will kubectl get pods myapp-pod show after creation?
medium
A. NAME READY STATUS RESTARTS AGE
myapp-pod 1/1 Completed 0 0s
B. Error: pod not found
C. NAME READY STATUS RESTARTS AGE
myapp-pod 0/1 Pending 0 0s
D. NAME READY STATUS RESTARTS AGE
myapp-pod 1/1 Running 0 0s
Solution
Step 1: Understand pod creation from YAML
The YAML defines a pod with one container running nginx, exposing port 80.
Step 2: Predict pod status after creation
Immediately after creation, the pod should be running with 1 container ready, so status is Running and READY is 1/1.
Final Answer:
NAME READY STATUS RESTARTS AGE
myapp-pod 1/1 Running 0 0s -> Option D
Quick Check:
Pod created and running = READY 1/1 Running [OK]
Hint: New pod with valid image shows READY 1/1 Running [OK]
Common Mistakes:
Expecting Pending status without reason
Confusing Completed with Running
Assuming pod not found immediately after creation
4. You run kubectl apply -f pod.yaml but get an error: "error: unable to recognize \"pod.yaml\": no matches for kind \"Pod\" in version \"v2\"". What is the likely fix?
medium
A. Delete the pod.yaml and recreate it
B. Rename the file to pod.yml
C. Change apiVersion from v2 to v1 in pod.yaml
D. Run the command with sudo
Solution
Step 1: Analyze the error message
The error says no matches for kind "Pod" in version "v2", meaning the apiVersion is invalid.
Step 2: Correct the apiVersion in YAML
The correct apiVersion for Pod is "v1", so changing from "v2" to "v1" fixes the issue.
Final Answer:
Change apiVersion from v2 to v1 in pod.yaml -> Option C
Quick Check:
apiVersion must be valid (v1 for Pod) [OK]
Hint: Check apiVersion spelling and value in YAML [OK]
Common Mistakes:
Changing file extension instead of apiVersion
Running with sudo unnecessarily
Deleting file without fixing content
5. You want to update a running pod's container image from nginx:1.19 to nginx:1.21 without downtime. Which Kubernetes resource and method should you use?
hard
A. Create a Deployment and update its image with kubectl set image
B. Directly edit the pod with kubectl edit pod to change the image
C. Delete the pod and create a new one with the new image
D. Use kubectl scale pod to increase replicas
Solution
Step 1: Understand pod immutability and updates
Pods are immutable; you cannot update container images directly on running pods without recreating them.
Step 2: Use Deployment for zero downtime updates
Deployments manage pods and allow rolling updates to change images without downtime using kubectl set image.
Final Answer:
Create a Deployment and update its image with kubectl set image -> Option A
Quick Check:
Use Deployment + set image for smooth updates [OK]
Hint: Use Deployment and set image for zero downtime update [OK]