Is it possible to take ssh to pod?
Eg: ssh pod_ip
I know we can do this with the kubectl command. But I need to do ssh from my local linux machine which doesn't have kubectl.
Is it possible to take ssh to pod?
Eg: ssh pod_ip
I know we can do this with the kubectl command. But I need to do ssh from my local linux machine which doesn't have kubectl.
If you would like to login inside a particular container in the POD
kubectl exec -it <Pod_Name> -c <Container_Name> -- /bin/bash
If you would like to login to default container (or if there is only one container in POD) then just use
kubectl exec -it <Pod_Name> -- /bin/bash
PS:- If /bin/bash is not working try /bin/sh
for anyone looking for a one liner, this should do it.
Given:
Running, gets you bash in the first pod:
kubectl exec -i -t $(kubectl get pod --namespace cars --selector='app=hud' --output jsonpath='{.items[0].metadata.name}') -n cars -- /bin/bash
Where this extracts the 1st pod when listing pods:
$(kubectl get pod --namespace cars --selector='app=hud' --output jsonpath='{.items[0].metadata.name}')
I use:
kubectl exec -it deployments.apps/deployment-example bash -n namespace-example