<p>I followed the load balancer tutorial:  <a href="https://cloud.google.com/container-engine/docs/tutorials/http-balancer" rel="noreferrer">https://cloud.google.com/container-engine/docs/tutorials/http-balancer</a> which is working fine when I use the Nginx image, when I try and use my own application image though the backend switches to unhealthy. </p>

<p>My application redirects on / (returns a 302) but I added a <code>livenessProbe</code> in the pod definition:</p>

<pre><code>    livenessProbe:
      httpGet:
        path: /ping
        port: 4001
        httpHeaders:
          - name: X-health-check
            value: kubernetes-healthcheck
          - name: X-Forwarded-Proto
            value: https
          - name: Host
            value: foo.bar.com
</code></pre>

<p>My ingress looks like:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: foo
spec:
  backend:
    serviceName: foo
    servicePort: 80
  rules:
  - host: foo.bar.com
</code></pre>

<p>Service configuration is:</p>

<pre><code>kind: Service
apiVersion: v1
metadata:
  name: foo
spec:
  type: NodePort
  selector:
    app: foo
  ports:
    - port: 80 
      targetPort: 4001
</code></pre>

<p>Backends health in <code>ingress describe ing</code> looks like:</p>

<pre><code>backends:       {"k8s-be-32180--5117658971cfc555":"UNHEALTHY"}
</code></pre>

<p>and the rules on the ingress look like:</p>

<pre><code>Rules:
  Host  Path    Backends
  ----  ----    --------
  * *   foo:80 (10.0.0.7:4001,10.0.1.6:4001)
</code></pre>

<p>Any pointers greatly received, I've been trying to work this out for hours with no luck.</p>

<p><strong>Update</strong></p>

<p>I have added the <code>readinessProbe</code> to my deployment but something still appears to hit / and the ingress is still unhealthy. My probe looks like:                </p>

<pre><code>    readinessProbe:
      httpGet:
        path: /ping
        port: 4001
        httpHeaders:
          - name: X-health-check
            value: kubernetes-healthcheck
          - name: X-Forwarded-Proto
            value: https
          - name: Host
            value: foo.com
</code></pre>

<p>I changed my service to: </p>

<pre><code>kind: Service
apiVersion: v1
metadata:
  name: foo
spec:
  type: NodePort
  selector:
    app: foo
  ports:
    - port: 4001
      targetPort: 4001
</code></pre>

<p><strong>Update2</strong></p>

<p>After I removed the custom headers from the <code>readinessProbe</code> it started working! Many thanks.</p>

<p>You need to add a readinessProbe (just copy your livenessProbe).</p>
<p>It's explained in the <a href="https://cloud.google.com/kubernetes-engine/docs/concepts/ingress" rel="noreferrer">GCE L7 Ingress Docs</a>.</p>
<blockquote>
<p>Health checks</p>
<p>Currently, all service backends must satisfy either of the following requirements to pass the HTTP health checks sent to it from the GCE loadbalancer: 1. Respond with a 200 on '/'. The content does not matter. 2. Expose an arbitrary url as a readiness probe on the pods backing the Service.</p>
</blockquote>
<p>Also make sure that the readinessProbe is pointing to the same port that you expose to the Ingress. In your case that's fine since you have only one port, if you add another one you may run into trouble.</p>
