使用堡垒通过SSH到Kubenetes Pod

时间:2019-02-06 07:42:47

标签: kubernetes kubectl google-kubernetes-engine

我已经部署了Google Cloud 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.

Kubenetes主服务器正在响应,这是一个好兆头。

现在,尝试建立一个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

问题: 如何允许ssh通过堡垒连接到Pod?我在做什么错了?

1 个答案:

答案 0 :(得分:1)

您现在不能执行此操作。

原因是因为用于exec和proxy之类的命令的连接使用SPDY2。

有一个错误报告here,其中包含更多信息。

您必须切换为使用HTTP代理

相关问题