How to map unmatched routes with ingress on GKE

8/19/2018

I'm trying to automatically provision a loadbalancer on GCP by using the ingress object with our GKE cluster.

I have three GKE deployments and each is available with a service on port 8080 with a unique nodePort.

When using ingress-fanout.yaml, it creates 4 backend services instead of the 3 specified in the yaml. The 4th service defaults to all unmatched routes. I assume the 4th service is because we don't match unmapped routes in the yaml.

How can one map unmatched routes to one of the services? Is that possible?

Here's ingress-fanout.yaml

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: fanout-ingress
  annotations:
    kubernetes.io/ingress.global-static-ip-name: "our-static-ip"
    ingress.gcp.kubernetes.io/pre-shared-cert: "our-ssl-cert"
    kubernetes.io/ingress.allow-http: "false"
    nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
spec:
  rules:
  - host: our-website.com
    http:
      paths:
      - path: /*
        backend:
          serviceName: li-frontend
          servicePort: 8080
      - path: /backend/*
        backend:
          serviceName: li-django
          servicePort: 8080
      - path: /notifications/*
        backend:
          serviceName: li-notifications
          servicePort: 8080

Update: I removed many of the original questions and narrowed the scope of the question. When health checks started succeeding, that cleared the old issues.

-- Mike
google-cloud-platform
google-kubernetes-engine
kubernetes
load-balancing

1 Answer

8/23/2018

First of all, "backends" have nothing to do with the "paths" you specified. "backends" on GCP Console are pointing to your GKE node pools.

Ingress supports adding a default backend. You could have tried just searching for "ingress default backend". You can find documentation about this here: https://kubernetes.io/docs/concepts/services-networking/ingress/#single-service-ingress

Basically doing this will set a default backend when nothing else is matched:

spec:
  backend:
    serviceName: testsvc
    servicePort: 80
rules:
  [...your stuff here...]
-- AhmetB - Google
Source: StackOverflow