Question 25
Domain 5: Observability, Troubleshooting, and MaintenanceWhich kubectl command sequence is used to run a container image locally, inspect its status and logs, and then verify it responds as expected?
Correct answer: A
Explanation
`kubectl run <name> --image=<image>` starts a pod from the image, then `kubectl get pod <name>` checks its status and `kubectl logs <name>` shows its output. `kubectl exec <name> -- curl <service>` runs a command inside the container to verify the service responds as expected.
Why each option is right or wrong
A. kubectl run <name> --image=<image>; kubectl get pod <name>; kubectl logs <name>; kubectl exec <name> -- curl <service>
`kubectl run <name> --image=<image>` creates a Pod from the specified image, and `kubectl get pod <name>` is the standard status check to confirm it reached a Running/Ready state. `kubectl logs <name>` retrieves the container’s stdout/stderr, and `kubectl exec <name> -- curl <service>` executes `curl` inside that Pod to test in-cluster response from the running container rather than from the local machine.
B. kubectl apply -f <deployment.yaml>; kubectl describe deployment <name>; kubectl logs deployment/<name>; kubectl port-forward deployment/<name> 80:80
C. docker run <image>; kubectl get pods; kubectl describe pod <name>; kubectl exec <name> -- sh
D. kubectl create deployment <name> --image=<image>; kubectl get svc <name>; kubectl top pod <name>; kubectl test <name>