Question 37
Domain 5: Observability, Troubleshooting, and MaintenanceWhich kubectl command opens an interactive shell in the running nginx pod?
Correct answer: A
Explanation
`kubectl exec` runs a command inside a running container, and `-it` allocates an interactive terminal. Using `-- /bin/sh` starts a shell in the `nginx` pod, which opens an interactive session inside that running container.
Why each option is right or wrong
A. kubectl exec -it nginx -- /bin/sh
`kubectl exec` is the command used to execute a process inside an already running container, and the `-i` and `-t` flags request stdin plus a TTY so the session behaves interactively. In this question, the target is the running `nginx` pod, and `/bin/sh` is the shell process launched inside it, which is why this exact form opens an interactive shell rather than merely printing output or creating a new pod.
B. kubectl run -it nginx -- /bin/sh
C. kubectl attach -it nginx
D. kubectl logs -f nginx