You can connect to a pod using kubectl exec
command. For example,
kubectl exec -it nginx-776567f984-vxdzw -- bash
This will connect you to one of the pods with bash
enabled.
root@nginx-776567f984-vxdzw:/# whoami
root
root@nginx-776567f984-vxdzw:/# hostname
nginx-776567f984-vxdzw
A pod can run multiple containers and you need to specify which container you want to connect to. You can find the container name using kubectl describe pod nginx-776567f984-vxdzw | grep -i container
command.
Top comments (0)