how can I change the default TCP service proxy_timeout in Kubernetes maintained nginx ingress?

8/31/2020

I've tried to change the default proxy_timeout(600s) to 3600s for tcp services in k8s maintained nginx-ingress.But its not working.

I have exec the nginx-controller pods and got the following in nginx.conf.

# TCP services

server {
        preread_by_lua_block {
                ngx.var.proxy_upstream_name="tcp-test-test-db-test-lb-dev-7687";
        }

        listen                  7687;

        proxy_timeout           600s;
        proxy_pass              upstream_balancer;

}

i have used following configmap and found not working.I'm getting still 600s timeout.

apiVersion: v1
kind: ConfigMap
metadata:
  name: tcp-services
  namespace: ingress-nginx
  annotations:
    ingress.kubernetes.io/proxyTimeout: 3600s
    ingress.kubernetes.io/proxy-stream-timeout: 3600s
    ingress.kubernetes.io/proxy-connect-timeout: 3600s
    ingress.kubernetes.io/proxy-read-timeout: 3600s
    ingress.kubernetes.io/proxy-send-timeout: 3600s
    ingress.kubernetes.io/proxy_timeout: 3600s
data:
   7687: "test-test-db/test-lb-dev:7687"
   8687: "test-test-db/test-lb-test:8687"

Anyone please help me to short this issue out.

-- Taybur Rahaman
kubernetes
nginx
nginx-ingress

3 Answers

4/7/2021

Its not correct. Not in the tcp-cm and not as annotation. Add as Data --> proxy-stream-timeout: 3600 to the other configmap.

-- Daniel Meier
Source: StackOverflow

4/27/2021

Annotations does not work in tcp-services for updating proxy_timeout parameter in nginx. You need to update the configmap ingress-nginx-controller and add the proxy-stream-timeout: "3600s" under data. (A sample below)

apiVersion: v1
kind: ConfigMap
metadata:
  name: ingress-nginx-controller
  namespace: ingress-nginx
  labels:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
data:
  proxy-connect-timeout: "10"
  proxy-read-timeout: "120"
  proxy-send-timeout: "120"
  proxy-stream-timeout: "3600s"
-- Samit
Source: StackOverflow

9/1/2020

When using these annotations you have to set them to number (integer) values. For example:

 ingress.kubernetes.io/proxy-stream-timeout: "3600"

instead of:

ingress.kubernetes.io/proxy-stream-timeout: 3600s

If you need more details regarding the timeout options than please check the official docs.

-- WytrzymaƂy Wiktor
Source: StackOverflow