【问题标题】:Nginx Ingress timeouts / connection dropsNginx 入口超时/连接断开
【发布时间】:2018-08-24 16:57:16
【问题描述】:

考虑一下这个 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-ingress 超时:

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 ingress pod 并尝试通过 nginx-ingress 访问 myservice:

time curl -vkH 'http://127.0.0.1/myservice/test?timeout=120'

但这一次我得到了空洞的回应——有时在 35 秒之后,有时在 90 秒之后,但它会到达那里:

* 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 被随机重新启动并且我的连接被丢弃了。

【问题讨论】:

    标签: nginx kubernetes-ingress nginx-ingress


    【解决方案1】:

    由于某种原因,nginx 进程不断重新加载 - 每 30 秒一次。每次重新加载时,所有连接都会断开。

    解决办法是设置:

    worker-shutdown-timeout: "900s"
    

    在 nginx-ingress config-map.

    【讨论】:

    • 对不起,你能指定 nginx-ingress config-map 的位置吗?
    • k get config-map 然后k edit config-map(或更短的k edit cm
    猜你喜欢
    • 2012-12-04
    • 2015-09-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-23
    • 1970-01-01
    • 2014-10-09
    • 2014-11-21
    相关资源
    最近更新 更多