Is it possible to setup some kind of internal Nginx service/deployment that can redirect calls from one GCP-ingress to another GCP-Ingress

9/18/2019

I have a situation where on my GCP Cluster , I have two ingresses(A) and (B), which take me to my default-backend service (my UI). These ingresses are of type "gce" since I am hosting my applications on Google-cloud and letting it do the load balancing for me

The kind of situation I am in requires me to have two ingresses (taking in some factors for downtime and outage). I am trying to explore an option where I can setup some kind of internal k8s service/deployment, that can take my calls from my Ingress(A) and redirect to Ingress(B) where Ingress(B) will be taking me to my default backend-UI.

How do I go about solving this problem?

In the example below, how do I write my My-redirection-service-to-app-system-test. My end users will only have to type "system.test.com" in their browsers and that should take them to my UI

Its likely a Kubernetes service/deployment. Uncertain how to proceed

Thanks for the help in advance

Example Ingress(B)

  rules:
  - host: app.system.test.com
    http:
      paths:
      - path: /ui/*
        backend:
          serviceName:ui-frontend
          servicePort: 80

Example Ingress (A)

  rules:
  - host: system.test.com
    http:
      paths:
      - path: /ui/*
        backend:
          serviceName: My-redirection-service-to-app-system-test
          servicePort: 80
-- Shoaib Ahmed Nasir
google-cloud-platform
kubernetes
kubernetes-ingress
nginx
redirect

1 Answer

9/18/2019

I haven't tried this myself but I would consider using a Service of type ExternalName. Those services can map requests directed at itself to any DNS name.

Something like this should do the trick:

Service:

apiVersion: v1
kind: Service
metadata:
  name: my-service
  namespace: namespace
spec:
  type: ExternalName
  externalName: app.system.test.com

ingress A

  rules:
  - host: system.test.com
    http:
      paths:
      - path: /ui/*
        backend:
          serviceName: my-service
          servicePort: 80

Ingress B

rules:
- host: app.system.test.com
  http:
    paths:
    - path: /ui/*
      backend:
        serviceName:ui-frontend
        servicePort: 80
-- Alassane Ndiaye
Source: StackOverflow