How do I connect to a container?

To connect to a pod within a container, use the kubectl exec command line, replacing <namespace>, <pod_name>, <container_name>, and <command> with your values:

kubectl -n <namespace> exec {-it} <pod_name> -c <container_name> <command>

-it is an optional setting that launches an interactive mode allowing you to work directly from your terminal. It works only if your command allows it.

For example, the following command line allows you to connect to the auth container from the saagie-common-auth-7df644756-6hbzm pod, which allows you to run bash commands in the container.

kubectl exec -it saagie-common-auth-7df644756-6hbzm -c auth bash