Shell (ssh) 进入 Azure AKS (Kubernetes) 集群工作节点
Shell (ssh) into Azure AKS (Kubernetes) cluster worker node
我在 Azure 中有一个使用 AKS 的 Kubernetes 集群,我想 'login' 到其中一个节点。节点没有 public IP。
有没有办法做到这一点?
这个 Gist and this page 对如何操作有很好的解释。 Sshing 到节点而不是 shelling 到 pods/containers.
该过程在 Azure 文档的一篇文章中有详细描述:
https://docs.microsoft.com/en-us/azure/aks/ssh。它包含 运行 一个 pod,您将其用作中继以通过 ssh 进入节点,并且它工作得非常好:
您可能在集群创建期间指定了 ssh 用户名和 public 密钥。如果没有,您必须配置您的节点以接受它们作为 ssh 凭据:
$ az vm user update \
--resource-group MC_myResourceGroup_myAKSCluster_region \
--name node-name \
--username theusername \
--ssh-key-value ~/.ssh/id_rsa.pub
要查找您的节点名称:
az vm list --resource-group MC_myResourceGroup_myAKSCluster_region -o table
完成后,运行集群上的一个 pod,里面有一个 ssh 客户端,这是您将用来通过 ssh 连接到您的节点的 pod:
kubectl run -it --rm my-ssh-pod --image=debian
# install ssh components, as their is none in the Debian image
apt-get update && apt-get install openssh-client -y
在您的工作站上,获取您刚创建的 pod 的名称:
$ kubectl get pods
将您的私钥添加到 pod 中:
$ kubectl cp ~/.ssh/id_rsa pod-name:/id_rsa
然后,在 pod 中,通过 ssh 连接到您的节点之一:
ssh -i /id_rsa theusername@10.240.0.4
(在您的工作站上查找节点 IP):
az vm list-ip-addresses --resource-group MC_myAKSCluster_myAKSCluster_region -o table
您可以使用它代替 SSH。这将创建一个微型 priv pod 并使用 nsenter 访问 noed。
https://github.com/mohatb/kubectl-wls
我在 Azure 中有一个使用 AKS 的 Kubernetes 集群,我想 'login' 到其中一个节点。节点没有 public IP。
有没有办法做到这一点?
这个 Gist and this page 对如何操作有很好的解释。 Sshing 到节点而不是 shelling 到 pods/containers.
该过程在 Azure 文档的一篇文章中有详细描述: https://docs.microsoft.com/en-us/azure/aks/ssh。它包含 运行 一个 pod,您将其用作中继以通过 ssh 进入节点,并且它工作得非常好:
您可能在集群创建期间指定了 ssh 用户名和 public 密钥。如果没有,您必须配置您的节点以接受它们作为 ssh 凭据:
$ az vm user update \
--resource-group MC_myResourceGroup_myAKSCluster_region \
--name node-name \
--username theusername \
--ssh-key-value ~/.ssh/id_rsa.pub
要查找您的节点名称:
az vm list --resource-group MC_myResourceGroup_myAKSCluster_region -o table
完成后,运行集群上的一个 pod,里面有一个 ssh 客户端,这是您将用来通过 ssh 连接到您的节点的 pod:
kubectl run -it --rm my-ssh-pod --image=debian
# install ssh components, as their is none in the Debian image
apt-get update && apt-get install openssh-client -y
在您的工作站上,获取您刚创建的 pod 的名称:
$ kubectl get pods
将您的私钥添加到 pod 中:
$ kubectl cp ~/.ssh/id_rsa pod-name:/id_rsa
然后,在 pod 中,通过 ssh 连接到您的节点之一:
ssh -i /id_rsa theusername@10.240.0.4
(在您的工作站上查找节点 IP):
az vm list-ip-addresses --resource-group MC_myAKSCluster_myAKSCluster_region -o table
您可以使用它代替 SSH。这将创建一个微型 priv pod 并使用 nsenter 访问 noed。 https://github.com/mohatb/kubectl-wls