Is it possible to perform ssh to a VM within a pod?

10/18/2019

I have a pod inside a Kubernetes cluster on GKE that remotely creates a Kubernetes cluster on Azure and I want to ssh into the master VM of the Azure cluster from the pod so I can remotely run some commands on it. However, I encountered a timeout problem whenever I run ssh / scp inside the pod:

ssh: connect to host port 22: Connection timed out

I already installed OpenSSH-client/server in my pod. I ensured that the VM has a public IP address and the pod also has access to the private key of the VM. I tried ssh into the Azure master VM on my laptop and it works just fine. Any ideas?

-- HKHKHKHKHK
kubernetes

2 Answers

10/18/2019

If you are running a private cluster in GKE, check their docs:

it says:

Private nodes do not have outbound Internet access because they don't have external IP addresses. Private Google Access provides private nodes and their workloads with limited outbound access to Google Cloud Platform APIs and services over Google's private network. For example, Private Google Access makes it possible for private nodes to pull container images from Google Container Registry, and to send logs to Stackdriver.

Check this other question => Kubernetes: Connect to the outside world from pod

-- Pedreiro
Source: StackOverflow

10/18/2019

Follow the below steps

  1. deploy a test pod that has ssh binary in azure cluster.
  2. update ssh certificates on the cluster nodes ( ignore if you already have certs )
  3. copy ssh certs into test pod using kubectl cp command
  4. get into test pod and ssh to any of the cluster nodes
  5. you should be able to run commands on cluster node
-- P Ekambaram
Source: StackOverflow