Defining a fallback service for Kubernetes ingress

9/25/2017

Is it possible to have a fallback service for Kubernetes ingresses in the event that none of the normal pods are live/ready? In other words, how would you go about presenting a friendly "website down" page to visitors if all pods crashed or went down somehow?

Right now, a page appears that says "default backend - 404" if that happens.

Here's what we tried, to no avail:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: example-ingress
spec:
  backend:
    serviceName: website-down-service
    servicePort: 80
  rules:
    - host: example.com
      http:
        paths:
          - path: /
            backend:
              serviceName: example-service
              servicePort: 80

For reference, we're testing locally with Minikube and deploying to the cloud on Google's Container Engine.

-- Wes Cossick
google-kubernetes-engine
kubernetes
minikube

1 Answer

9/26/2017

For the Nginx Ingress Controller there is a flag --default-backend-service, which currently points to the service showing the "default backend - 404" message. Just replace it with the service you want. See https://github.com/kubernetes/ingress/tree/master/controllers/nginx#command-line-arguments

If you're using another Ingress Controller, I expect it to have a similar option.

-- slintes
Source: StackOverflow