phatkdawg
phatkdawg

Reputation: 1

Ingress (GCP Load balancer) - how do I set different request timeouts per route

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

Upvotes: 0

Views: 944

Answers (1)

Gari Singh
Gari Singh

Reputation: 12033

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.

Upvotes: 1

Related Questions