在K8s中安装了gitlab agent,用于CD业务。
使用官方推荐的helm
方式安装后gitlab显示已连接
但是agent pod中一直报错:
kubectl logs -f -l=app=gitlab-agent -n gitlab-agent
{"level":"error","time":"2022-09-20T06:45:10.371Z","msg":"Error handling a connection","mod_name":"reverse_tunnel","error":"rpc error: code = Unavailable desc = error reading from server: failed to get reader: failed to read frame header: EOF"}
这是nginx未设置或者设置的timeout过短导致的
wss的location配置中加上
proxy_read_timeout 86400s;
proxy_send_timeout 86400s;
即可
推荐的完整的gitlab agent wss反代配置:
location /-/kubernetes-agent/ {
proxy_set_header Host $host;
proxy_set_header Sec-WebSocket-Protocol $http_sec_websocket_protocol;
proxy_set_header Sec-WebSocket-Extensions $http_sec_websocket_extensions;
proxy_set_header Sec-WebSocket-Key $http_sec_websocket_key;
proxy_set_header Sec-WebSocket-Version $http_sec_websocket_version;
proxy_read_timeout 86400s;
proxy_send_timeout 86400s;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass https://gitlab;
}
参考:
[stack overflow] getting the reason why websockets closed with close code 1006
冶心·练体·得技