How to configure Ingress request timeouts on GKE

When creating an ingress on GKE the default setup is that a GLBC HTTP load balancer will be created with the backends that you supplied. Default it is configured at a 30 second timeout for your application to handle the request.

If you need a longer timeout you have to edit this manually after setup in the backends of your HTTP Load balancer in the google cloud console.

enter image description here


Beginning with 1.11.3-gke.18, it is possible to configure timeout settings in kubernetes directly.

First add a backendConfig:

apiVersion: cloud.google.com/v1beta1
kind: BackendConfig
metadata:
  name: my-bsc-backendconfig
spec:
  timeoutSec: 40

Then add an annotation in Service to use this backendConfig:

apiVersion: v1
kind: Service
metadata:
  name: my-bsc-service
  labels:
    purpose: bsc-config-demo
  annotations:
    beta.cloud.google.com/backend-config: '{"ports": {"80":"my-bsc-backendconfig"}}'
spec:
  type: NodePort
  selector:
    purpose: bsc-config-demo
  ports:
  - port: 80
    protocol: TCP
    targetPort: 8080

And viola, your ingress load balancer now has a timeout of 40 second instead of the default 30 seconds.

See https://cloud.google.com/kubernetes-engine/docs/how-to/configure-backend-service#creating_a_backendconfig