<p>How do I properly change the TCP keepalive time for node-proxy?</p>

<p>I am running Kubernetes in Google Container Engine and have set up an ingress backed by HTTP(S) Google Load Balancer. When I continuously make POST requests to the ingress, I get a 502 error exactly once every 80 seconds or so. <code>backend_connection_closed_before_data_sent_to_client</code> error in Cloud Logging, which is because GLB's tcp keepalive (600 seconds) is larger than node-proxy's keepalive (no clue what it is).</p>

<p>The logged error is detailed in <a href="https://cloud.google.com/compute/docs/load-balancing/http/" rel="noreferrer">https://cloud.google.com/compute/docs/load-balancing/http/</a>.</p>

<p>Thanks!</p>

<p>You can use the custom resource <code>BackendConfig</code> that exist on each GKE cluster to configure timeouts and other parameters like CDN <a href="https://cloud.google.com/kubernetes-engine/docs/concepts/backendconfig" rel="nofollow noreferrer">here</a> is the documentacion</p>

<p>An example from <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/configure-backend-service" rel="nofollow noreferrer">here</a> shows how to configure on the ingress</p>

<p>That is the <code>BackendConfig</code> definition:</p>

<pre><code>apiVersion: cloud.google.com/v1beta1
kind: BackendConfig
metadata:
  name: my-bsc-backendconfig
spec:
  timeoutSec: 40
  connectionDraining:
    drainingTimeoutSec: 60
</code></pre>

<p>And this is how to use on the ingress definition through annotations</p>

<pre><code>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
</code></pre>
