4

I have kubernetes pods running as shown in command "kubectl get all -A" :

enter image description here

and same pods are shown in command "kubectl get pod -A" : enter image description here

I want to enter/login to any of these pod (all are in Running state). How can I do that please let me know the command?

David Maze
  • 94,671
  • 18
  • 109
  • 144
solveit
  • 589
  • 2
  • 6
  • 20

2 Answers2

7

Kubernetes Pods are not Virtual Machines, so not something you typically can "log in" to.

But you might be able to execute a command in a container. e.g. with:

kubectl exec <pod-name> -- <command>

Note that your container need to contain the binary for <command>, otherwise this will fail.

See also Getting a shell to a container.

Jonas
  • 109,920
  • 93
  • 295
  • 369
3

In addition to Jonas' answer above; If you have more than one namespace, you need to specify the namespace your pod is currently using i.e kubectl exec -n <name space here> <pod-name> -it -- /bin/sh

After successfully accessing your pod, you can go ahead and navigate through your container.

Umar Kayondo
  • 196
  • 1
  • 5