【问题标题】:How do I ssh to nodes in ACS Kubernetes cluster?如何通过 ssh 连接到 ACS Kubernetes 集群中的节点?
【发布时间】:2017-06-19 03:16:50
【问题描述】:
【问题讨论】:
标签:
azure
kubernetes
azure-container-service
【解决方案1】:
您可以将其中一个 k8s 主机用作“堡垒主机”,避免复制密钥。例如:
# 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
现在只需ssh user@agent1_private_ip
在此处查看更多信息:http://blog.scottlowe.org/2015/11/21/using-ssh-bastion-host/
PS:这里有一个快速检索代理私有 ips 的方法,格式为 /etc/hosts:
kubectl get nodes -o json | jq -r '.items[].status.addresses[].address' | paste - -
【解决方案2】:
您可以将私钥复制到您的主虚拟机。然后你可以使用ssh -i <path>/id_rsa user@<agent private IP> 到 k8s 代理虚拟机。
注意:代理的用户名和私钥与主虚拟机相同。