kubernetes gke multiple ingresses single global ip

2/27/2018

I have multiple MSA on k8s on GKE. Each is on separate subdomain like:

  • msa1.example.com
  • msa2.example.com

I have it in single ingress:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: main-ingress
  annotations:
    kubernetes.io/ingress.global-static-ip-name: lalala-ip-1
    kubernetes.io/ingress.allow-http: "false"
spec:
  tls:
  - hosts:
    - msa1.example.com
    secretName: msa1-tls
  backend:
    serviceName: sink
    servicePort: 80
  rules:
  - host: msa1.example.com
    http:
      paths:
      - path: /.well-known/*
        backend:
          serviceName: letsencrypt
          servicePort: 80
      - path: /*
        backend:
          serviceName: lalala
          servicePort: 80
  - host: msa2.example.com
    http:
      paths:
      - path: /*
        backend:
          serviceName: lalala2
          servicePort: 80

... and all is nice.

The thing is, that I want to have each MSA in separate file.

Problem is this kubernetes.io/ingress.global-static-ip-name: lalala-ip-1 line. If I have it in two ingresses only first started is bounded to IP, but other ones no.

Is there a way, to share IP on GKE ingress controller between two ingresses?

-- Mateusz
gcloud
google-kubernetes-engine
kubernetes
kubernetes-ingress

2 Answers

2/28/2018

A way around it could be to run your own nginx-ingress controller in your cluster and expose it via LoadBalancer service type. Then you would have 1 IP for your ingress and be able to serve all ingresses via nginx controller by adding annotation kubernetes.io/ingress.class: "nginx"

Reference: https://kubernetes.github.io/ingress-nginx/user-guide/multiple-ingress/

-- Radek 'Goblin' Pieczonka
Source: StackOverflow

2/28/2018

Confirmed my comment:

Only one resource at a time can use a static external IP address.

https://cloud.google.com/compute/docs/ip-addresses/reserve-static-external-ip-address

-- Jonah Benton
Source: StackOverflow