<p>I'm trying to create a simple nginx service on GKE, but I'm running into strange problems. </p>

<p>Nginx runs on port 80 inside the Pod. The service is accessible on port 8080. (This works, I can do <code>curl myservice:8080</code> inside of the pod and see the nginx home screen)</p>

<p>But when I try to make it publicly accessible using an ingress, I'm running into trouble. Here are my deployment, service and ingress files.</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.7.9
        ports:
        - containerPort: 80


kind: Service
apiVersion: v1
metadata:
  name: my-service
spec:
  selector:
    app: nginx
  ports:
  - protocol: TCP
    port: 8080
    nodePort: 32111
    targetPort: 80
  type: NodePort


apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: test-ingress
spec:
  rules:
  - http:
      paths:
      # The * is needed so that all traffic gets redirected to nginx
      - path: /*
        backend:
          serviceName: my-service
          servicePort: 80
</code></pre>

<p>After a while, this is what my ingress status looks like:</p>

<pre><code>$ k describe ingress test-ingress
Name:             test-ingress
Namespace:        default
Address:          35.186.255.184
Default backend:  default-http-backend:80 (10.44.1.3:8080)
Rules:
  Host  Path  Backends
  ----  ----  --------
  *
        /*   my-service:32111 (&lt;none&gt;)
Annotations:
  backends:         {"k8s-be-30030--ecc76c47732c7f90":"HEALTHY"}
  forwarding-rule:  k8s-fw-default-test-ingress--ecc76c47732c7f90
  target-proxy:     k8s-tp-default-test-ingress--ecc76c47732c7f90
  url-map:          k8s-um-default-test-ingress--ecc76c47732c7f90
Events:
  Type     Reason   Age               From                     Message
  ----     ------   ----              ----                     -------
  Normal   ADD      18m               loadbalancer-controller  default/test-ingress
  Normal   CREATE   17m               loadbalancer-controller  ip: 35.186.255.184
  Warning  Service  1m (x5 over 17m)  loadbalancer-controller  Could not find nodeport for backend {ServiceName:my-service ServicePort:{Type:0 IntVal:32111 StrVal:}}: could not find matching nodeport from service
  Normal   Service  1m (x5 over 17m)  loadbalancer-controller  no user specified default backend, using system default
</code></pre>

<p>I don't understand why it's saying that it can't find nodeport - the service has nodePort defined and it is of type NodePort as well. Going to the actual IP results in <code>default backend - 404</code>. </p>

<p>Any ideas why?</p>

<p>The configuration is missing a health check endpoint, for the GKE loadbalancer to know whether the backend is healthy. The <code>containers</code> section for the <code>nginx</code> should also specify:</p>

<pre><code> livenessProbe:
   httpGet:
     path: /
     port: 80
</code></pre>

<p>The <code>GET /</code> on port 80 is the default configuration, and can be changed.</p>
