0

Is there a way to set different request timeouts per route for a GCP Loadbalancer (created via a kubernetes ingress) ? These routes would go to the same backend service(s) -- i.e., same pod/port combinations

Thanks

phatkdawg
  • 1
  • 1
  • Why would you want to do this? Are you trying to use timeouts as a bandaid to solve a problem? – John Hanley Mar 08 '22 at 16:58
  • We have a single route for long running API calls, and the rest of the routes have quickly finishing API calls. All the routes go to the same port of the same set of pods. – phatkdawg Mar 09 '22 at 13:54

1 Answers1

1

There's no "direct" way to do this, but you could do this using separate Services and BackendConfigs.

In order to set the backend timeout for a Service exposed via Ingress, you need to associate a BackendConfig resource with the Service:

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

-------------------

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

Since you can expose multiple services via a single GKE Ingress, you can have different backend timeouts per Service as each Service can have its own BackendConfig.

If you only have a single Deployment, you should technically be able to create multiple Services each pointing to the same Deployment. You could then set a separate timeout for each of those Services and then expose all of the Services via a single Ingress using paths.

Gari Singh
  • 11,418
  • 2
  • 18
  • 41