Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How come GKE gives me different IPs for each ingress that I create?

I am using multiple ingresses resource on my GKE, say I have 2 ingress in different namespaces. I create the ingress resource as shown in the yaml below. With the annotations used in the below yaml, I clearly mention that I am using the GCE controller that comes with GKE(https://github.com/kubernetes/ingress-gce). But every time I create an ingress I get different IPs, For instance sometimes I get 133.133.133.133 and for the other times I get 133.133.133.134. And it alternates between only these two IPs (it's probably between only two IPs because of quotas limit). This is a problem when I just want to reserve one IP and load balance/terminate multiple apps on this IP only.

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: gce
  name: http-ingress
spec:
  backend:
    serviceName: http-svc
    servicePort: 80
like image 951
Suhas Chikkanna Avatar asked Dec 01 '25 06:12

Suhas Chikkanna


1 Answers

In your Ingress resource you can specify you need the Load Balancer to use a specific IP address with the kubernetes.io/ingress.global-static-ip-name annotation like so:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: gce
    kubernetes.io/ingress.global-static-ip-name: static-ip-name
  name: http-ingress
spec:
  backend:
    serviceName: http-svc
    servicePort: 80

You will need to create a global static IP first using the gcloud tool. See step 2(b) here: https://cloud.google.com/kubernetes-engine/docs/tutorials/configuring-domain-name-static-ip.

like image 99
Carlos Gomez Avatar answered Dec 04 '25 15:12

Carlos Gomez



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!