<p>I have a Service on GKE of type LoadBalancer that points to a GKE deployment running nginx. My nginx has all of the timeouts set to 10 minutes, yet HTTP/HTTPS requests that have to wait on processing before receiving a response get cutoff with 500 errors after 30 seconds. My settings:</p>

<pre><code>http {
    proxy_read_timeout 600s;
    proxy_connect_timeout 600s;
    keepalive_timeout 600s;
    send_timeout 600s;
}
</code></pre>

<p>Apparently there are default settings of 30 seconds in the LoadBalancer somewhere.</p>

<p>After pouring through documentation, I've only found a step-through at Google that outlines setting an Ingress with back-end service Load Balancer with a timeout but can't find how to do that on a Service that's Type=LoadBalancer for use with GKE. I've also reviewed all of the Kubernetes documentation for versions 1.7+ (we're on 1.8.7-gke.1) and nothing about setting a timeout. Is there a setting I can add to my yaml file to do this?</p>

<p>If it helps I found the following for AWS, which appears to be what I would need to have on GKE:</p>

<pre><code>  annotations:
    service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout: "60"
</code></pre>

<p>As of April 2021 you can do this via GKE/GCE configuration.  <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/ingress-features#create_backendconfig" rel="nofollow noreferrer">Here</a> are the instructions.
Essentially you create a <code>BackendConfig</code> resource similar to this:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: cloud.google.com/v1
kind: BackendConfig
metadata:
  name: my-backendconfig
spec:
  timeoutSec: 40
  connectionDraining:
    drainingTimeoutSec: 60
</code></pre>
<p>(<code>kubectl apply -f my-backendconfig.yaml</code>)</p>
<p>and then connect it to your GKE service resource with an annotation:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Service
metadata:
  name: my-service
  labels:
    purpose: bsc-config-demo
  annotations:
    cloud.google.com/backend-config: '{&quot;ports&quot;: {&quot;80&quot;:&quot;my-backendconfig&quot;}}'
    cloud.google.com/neg: '{&quot;ingress&quot;: true}'
spec:
  type: ClusterIP
  selector:
    purpose: bsc-config-demo
  ports:
  - port: 80
    protocol: TCP
    targetPort: 8080
</code></pre>
<p>(<code>kubectl apply -f my-service.yaml</code>)</p>
<p>If you prefer, the BackendConfig resource (and Service) can be placed in a namespace with a metadata namespace designation in your yaml.</p>
<pre class="lang-yaml prettyprint-override"><code>metadata:
  namespace: my-namespace
</code></pre>
