Member-only story
How to SSH Into a Kubernetes Pod From Outside the Cluster
A Pod, by definition, is analogous to a virtual machine, so we can SSH in

Secure Socket Shell (SSH) is a UNIX-based protocol that is used to access a remote machine or a virtual machine (VM).
Pod, by definition, is analogous to VM as it allows the containers to behave as if they are running on isolated VMs. If you are inside the cluster — the simplest way is to use kubectl exec command
But, Is it possible to SSH into a K8 Pod from outside the cluster?

Yes. It’s possible! — But only after incrementally answering the below questions…
How to Reliably Access a K8 Pod?
By definition, Pods are ephemeral in nature and a service is a stable abstraction point for a set of pods. So, a K8 Pod can be reliably accessed through a service.
What is the appropriate service type to access the pod from outside the Kubernetes cluster?
ClusterIP
, NodePort
, and LoadBalancer
are the three possible service types.
However, the ClusterIP
service can never be accessed from outside the cluster and hence, it is not an option.
The NodePort
service provides a cluster-wide port that can be accessed through the cluster node. But given that the node is also ephemeral in nature, NodePort
is not a stable way to access the Pod.
The LoadBalancer
service is the only appropriate service type to access the Pod from outside the Kubernetes cluster, because this service type provides an external IP address that can be tied to a public load balancer like Google’s HTTPS load balancer.

Below is snippet of a LoadBalancer
service that opens the SSH port for communication.