
Answer-first summary for fast verification
Answer: Utilize `kubectl exec -it msg-translator-22 -- /bin/bash` to launch a shell session in the container.
The correct approach is to use `kubectl exec -it msg-translator-22 -- /bin/bash`. This command allows you to execute a command directly in a specified container, in this case, 'msg-translator-22', by starting a shell session. The other options are incorrect for the following reasons: - `kubectl run` is used to create and manage deployments or jobs, not to connect to existing containers. - Omitting the container name in `kubectl exec` commands prevents the command from targeting the specific container you wish to inspect. For more details, refer to the Kubernetes documentation on [kubectl exec](https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#exec) and [kubectl run](https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#run).
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
Your company operates a web application where users can share their travel stories. Recently, you've observed errors in the logs specifically for a Deployment tasked with translating posts from one language to another. The issue has been traced to a container named 'msg-translator-22', which is the only one experiencing these errors across all environments. To investigate the root cause, you need to execute commands within this container. Which of the following steps will enable you to run commands inside 'msg-translator-22'?
A
Execute kubectl run msg-translator-22 /bin/bash to initiate a shell session in the container.
B
Use kubectl exec -it -- /bin/bash to start a shell session in the container.
C
Run kubectl run to create a shell session in the container.
D
Utilize kubectl exec -it msg-translator-22 -- /bin/bash to launch a shell session in the container.
No comments yet.