GKE Ingress - Simple nginx example yet getting error "Could not find nodeport for backend"

9/17/2018

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

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

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.

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

After a while, this is what my ingress status looks like:

$ 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 (<none>)
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

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 default backend - 404.

Any ideas why?

-- Nick
google-kubernetes-engine
kubernetes

1 Answer

9/20/2018

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

 livenessProbe:
   httpGet:
     path: /
     port: 80

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

-- Eric Platon
Source: StackOverflow