Kubernetes pods are not virtual machines, so they're not something you can typically log in to. However, you can execute a command in a container using the following command:
kubectl exec <pod-name> -- <command>
Make sure that your container contains the binary for <command>
, otherwise this will fail.
You can also refer to the Kubernetes documentation on Getting a shell to a container for more information.
If you have multiple namespaces, you need to specify the namespace your pod is using. For example:
kubectl exec -n <namespace> <pod-name> -it -- /bin/sh
Once you have successfully accessed your pod, you can navigate through your container.
Another way to access the container inside a pod is using this command:
kubectl exec -it < your pod name which you want to access> /bin/bash