Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

kubernetes gke multiple ingresses single global ip

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?

like image 810
Mateusz Avatar asked Feb 27 '18 21:02

Mateusz


People also ask

Can a Kubernetes cluster have multiple ingress controllers?

You may deploy any number of ingress controllers using ingress class within a cluster. Note the . metadata.name of your ingress class resource.

How do you make multiple ingress in Kubernetes?

First, ensure the --controller-class= and --ingress-class are set to something different on each ingress controller, If your additional ingress controller is to be installed in a namespace, where there is/are one/more-than-one ingress-nginx-controller(s) already installed, then you need to specify a different unique -- ...

Which ingress is used to route traffic from single IP to multiple services?

Kubernetes ingress resources are used to configure the ingress rules and routes for individual Kubernetes services. When you use an ingress controller and ingress rules, a single IP address can be used to route traffic to multiple services in a Kubernetes cluster.

Is Kubemci deprecated?

[DEPRECATED] This has now been deprecated in favor of Ingress for Anthos. Ingress for Anthos is the recommended way to deploy multi-cluster ingress. kubemci is a tool to configure Kubernetes ingress to load balance traffic across multiple Kubernetes clusters.


2 Answers

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/

like image 79
Radek 'Goblin' Pieczonka Avatar answered Nov 03 '22 00:11

Radek 'Goblin' Pieczonka


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

like image 27
Jonah Benton Avatar answered Nov 03 '22 00:11

Jonah Benton