【发布时间】:2018-04-08 16:16:16
【问题描述】:
我正在尝试根据此 SO 帖子中给出的建议设置与 Kubernetes Pod Exec API 的 websocket 连接:How to execute command in a pod (kubernetes) using API?。 这是我到目前为止所做的 -
- 在 Chrome 中安装了 Simple Web Socket Client 扩展。
- 已启动
kubectl proxy --disable-filter=true以运行允许 WS 连接的代理。kubectl.exe版本为 1.8。 - 使用 Chrome 扩展程序中的地址
ws://localhost:8001/api/v1/namespaces/default/pods/nginx-3580832997-26zcn/exec?container=nginx&stdin=1&stdout=1&stderr=1&tty=1&command=%2Fbin%2Fsh连接到execapi。
当我点击连接时,Chrome 会报告错误消息 -
Error during WebSocket handshake: Response must not include 'Sec-WebSocket-Protocol' header if not present in request
显然,kubectl 在响应中发回了空的 Sec-WebSocket-Protocol 标头,Chrome 对此感到不满。
我尝试更改 Simple Web Socket Client open 方法的代码以将空协议参数发送到 Websocket 客户端创建调用,例如 - ws = new WebSocket(url, []); 以诱使 Chrome 在请求中发送空标头,但 Chrome 不发送空标题。
那么如何在Chrome中直接连接exec呢?
【问题讨论】:
标签: google-chrome websocket kubernetes kubectl