Problem: You have a running Kubernetes deployment, and you want to examine inside a container so you need to get shell access.
First find the pod that you are interested in.
NOTE: If you are running in a namespace, you need to include that as part of your listing with the -n flag, if not, you can skip -n. In this case, we'll name our namespace: namespace.
kubectl -n namespace get pods
This shows:
NAME READY STATUS RESTARTS AGE
fun-pod-0 1/1 Running 0 21h
To connect to fun-pod-0, we do:
kubectl exec -it pod/fun-pod-0 -n namespace -- sh
NOTE: That we use sh for our shell as it's found in most linux pods. But your milage may vary and you might want to use bash or even /bin/bash instead of sh depending upon what shell is installed and what path.