<p>Scenario 1: I am deploying an spring boot app in a physical machine in which it opens ssh connection on a port of the physical machine. Lets say 9889. So once the application starts, that physical machine will open connection on that port and listen for any incoming request. Any  client can connect to that port using command</p>
<pre><code>ssh admin@ipaddress -p 9889.
</code></pre>
<p>It returns the connection i expect.</p>
<p>Scenario 2: I am deploying that app into Kubernete cluster. I set external Ip of the service to the IP on master node. So when i type Kubectl get services i got something like</p>
<pre><code>NAME           TYPE                 CLUSTER-IP     EXTERNAL-IP          PORT
app-entry      LOADBALANCER         172.x.x.xx     172.x.x.x            3000:3552
</code></pre>
<p>How can i ssh to the app in the Kubernete Cluster using the externalIP and the port 3000. Since everytime i try to ssh using command above it returns connection refused</p>

kungho
<p>As @zerkms mentioned in the comment, you can use <code>kubectl exec</code> to connect the shell of a container running inside the Kubernetes cluster.</p>
<pre class="lang-sh prettyprint-override"><code>$ kubectl exec -it -n &lt;namespace&gt; &lt;pod_name&gt; -- /bin/bash
$ kubectl exec -it -n &lt;namespace&gt; &lt;pod_name&gt; -- /bin/sh

# if the pod has multiple containers
$ kubectl exec -it -n &lt;namespace&gt; &lt;pod_name&gt; -c &lt;container_name&gt; -- /bin/bash
</code></pre>
<p>If you have a running server on your pod which serves at a specific port,  you can use <code>kubectl port-forward</code> to connect it from the local machine (ie. <code>localhost:PORT</code>).</p>
<pre><code># Pods
$ kubectl port-forward -n &lt;namespace&gt; pods/&lt;pod_name&gt; &lt;local_port&gt;:&lt;container_port&gt;

# Services
$ kubectl port-forward -n &lt;namespace&gt; svc/&lt;service_name&gt; &lt;local_port&gt;:&lt;container_port&gt;
</code></pre>
