Mateusz
Mateusz

Reputation: 1197

kubernetes gke multiple ingresses single global ip

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

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?

Upvotes: 7

Views: 6134

Answers (3)

Gabriel Koch
Gabriel Koch

Reputation: 169

GKE has recently added support for the new Kubernetes Gateway API. Both the GKE Gateway implementation as well as the Kubernetes Gateway API specification are still in alpha at this point.

The Kubernetes Gateway-API, is intended to support use cases, where you have a central Gateway (with a single IP), but want different Routes (with different hostnames or paths), managed in separate objects or even namespaces.

References:

Upvotes: 2

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/

Upvotes: 10

Jonah Benton
Jonah Benton

Reputation: 3708

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

Upvotes: 6

Related Questions