Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need to do ssh to Kubernetes pod

Tags:

kubernetes

Is it possible to take ssh to pod. eg: ssh pod_ip

I know we can do this with kubectl command. But I need to do ssh from my local linux machine where I doesn't have kubectl

Thanks

like image 593
Eswari Avatar asked Aug 16 '17 13:08

Eswari


People also ask

Can I ssh into a Kubernetes pod?

But, Is it possible to SSH into a K8 Pod from outside the cluster? Yes.

How do I ssh into containers in Kubernetes?

If your endgoal is to get remote SSH access to your private Kubernetes cluster nodes or pods, then you have 2 options: Option# 1: Install and run an OpenSSH server inside your docker container pod. SSH server listens on port 22 and you need to expose that to the outside network.

Can I ssh to Kubernetes node?

Kubernetes nodes can be accessed similar way how we ssh into other linux machines. Just try ssh with the external ip of that node and you can login into it that way.


1 Answers

Firstly, you have to ensure that the openssh-server has been installed and running in the pod. If not, you can use kubectl exec -it <pod-name> -n <namespace> -- bash to access the pod. If your pod are running Ubuntu, do apt-get install -y openssh-server.

Secondly, pods are running in a virtual IP subnet assigned by network service. They are accessible to any Master nodes and Worker nodes in the cluster. You can do ssh from any of the Host OS.

like image 158
ichbinblau Avatar answered Oct 12 '22 00:10

ichbinblau