kubernetes - Shell (ssh) 到 Azure AKS (Kubernetes) 群集工作节点

标签 kubernetes azure-aks

我在 Azure 中有一个使用 AKS 的 Kubernetes 集群,我想“登录”到其中一个节点。节点没有公共(public) IP。

有没有办法做到这一点?

最佳答案

Azure 文档的一篇文章中详细描述了该过程:
https://docs.microsoft.com/en-us/azure/aks/ssh .它由运行一个 pod 组成,您将其用作中继以 ssh 进入节点,并且它工作得非常好:

您可能在集群创建期间指定了 ssh 用户名和公钥。如果没有,您必须配置您的节点以接受它们作为 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

完成后,在您的集群上运行一个带有 ssh 客户端的 pod,这是您将用于 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

关于kubernetes - Shell (ssh) 到 Azure AKS (Kubernetes) 群集工作节点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53420532/

相关文章:

azure - 使用子网 ID 的引用创建 AKS 群集时出错

mongodb - 何时不使用 StatefulSet?

service - k8s-Kubernetes-服务更新-错误

azure - Terraform 状态与外部更改同步

azure - 无法访问 Azure kubernetes 的服务

azure - 如何使用containerd将图像导入azure容器寄存器

docker - 尝试使用 helm/docker 查找本地镜像时出现错误

Kubernetes 入口 nginx 重定向域,也适用于所有重定向域的子域

azure - 使用 terraform 在 AKS 中创建 PV 使用默认存储类

azure - 如果我在 Azure 云中使用 k8 集群,是否需要 minikube?