考虑此NodePort服务:
k describe service myservice
...
Type: NodePort
IP: 10.15.248.153
Port: myservice 8080/TCP
TargetPort: 8080/TCP
NodePort: myservice 30593/TCP
Endpoints: 10.12.223.56:8080
考虑一个耗时120秒的请求:
# time curl -vkH 'http://myservce:8080/test?timeout=120'
* Trying 10.15.248.153...
* TCP_NODELAY set
* Connected myservice (10.15.248.153) port 8080 (#0)
...
< HTTP/1.1 200
real 2m0.023s
user 0m0.009s
sys 0m0.009s
这很好。因此,我配置了nginx-inress超时:
nginx.ingress.kubernetes.io/proxy-send-timeout: "900"
nginx.ingress.kubernetes.io/proxy-read-timeout: "900"
nginx.ingress.kubernetes.io/proxy-connect-timeout: "60"
我可以确认它在nginx.conf中:
proxy_connect_timeout 60s;
proxy_send_timeout 900s;
proxy_read_timeout 900s;
所以现在,我尝试输入nginx入口pod并尝试通过nginx-ingress访问myservice:
time curl -vkH 'http://127.0.0.1/myservice/test?timeout=120'
但是这次我得到的答复是空的-有时在35s之后,有时在90s之后,但是它将到达那里:
* Curl_http_done: called premature == 0
* Empty reply from server
* Connection #0 to host 127.0.0.1 left intact
curl: (52) Empty reply from server
我不知道可能会发生什么。好像nginx随机重启了,我的连接掉了。
答案 0 :(得分:3)
由于某种原因,nginx进程会每30秒不断重新加载一次。每次重新加载时,所有连接均被删除。
解决方案是设置:
worker-shutdown-timeout: "900s"
在nginx元素config-map
中。