我已经部署了Google云Kubernetes集群。集群只有内部 IP。
为了访问它,我创建了一个具有外部 IP 的虚拟机 bastion-1
。
结构:
My Machine -> bastion-1 -> Kubernetes cluster
与代理站的连接:
$ ssh bastion -D 1080
现在使用 kubectl
使用代理:
$ HTTPS_PROXY=socks5://127.0.0.1:1080 kubectl get pods
No resources found.
Kubernetes 主服务器正在响应,这是一个好兆头。
现在,尝试通过 ssh 连接 pod:
$ HTTPS_PROXY=socks5://127.0.0.1:1080 kubectl exec -it "my-pod" -- /bin/bash
error: error sending request: Post https://xxx.xxx.xxx.xxx/api/v1/namespaces/xxx/pods/pod-xxx/exec?command=%2Fbin%2Fbash&container=xxx&container=xxx&stdin=true&stdout=true&tty=true: EOF
问题: 如何允许通过 bastion ssh 连接到 pod?我做错了什么?
最佳答案
关于kubernetes - 使用 Bastion 通过 SSH 连接到 Kubernetes Pod,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54548736/