Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I ssh to nodes in ACS Kubernetes cluster?

I have created an ACS Kubernetes cluster following the instructions here: https://learn.microsoft.com/en-us/azure/container-service/container-service-kubernetes-walkthrough .

I see that master node has a public IP and I can ssh into the master node using azureuser. But regular nodes has no public IP and I don't see how I can ssh into regular nodes from master node.

How do I SSH into the regular nodes?

like image 433
codefx Avatar asked Dec 18 '22 06:12

codefx


1 Answers

You can use one of the k8s masters as a "bastion host" and avoid copying the keys over. Eg:

# In ~/.ssh/config

Host agent1_private_ip agent2_private_ip ....
  IdentityFile ~/.ssh/<your_k8s_cluster_key>
  ProxyCommand ssh user@master_public_ip -W %h:%p

Now just ssh user@agent1_private_ip

See more here: http://blog.scottlowe.org/2015/11/21/using-ssh-bastion-host/


PS: Here's a quickie to retrieve your agent private ips, in /etc/hosts format:

kubectl get nodes -o json | jq -r '.items[].status.addresses[].address' | paste - -
like image 57
Valer Avatar answered Jan 04 '23 00:01

Valer