Search code examples
kuberneteskubectlkubernetes-pod

How to login/enter in kubernetes pod


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?


Solution

  • 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.