Does GKE support nginx-ingress with static ip?

2/13/2018

I have been using the Google Cloud ingress. Also deployed the nginx-ingress and trying to setup using static-ip address in GKE.

  • Can we use both Google Cloud ingress and nginx-ingress in same cluster?
  • How can we use the nginx-ingress with static-ip?

Thanks

-- John
google-cloud-platform
google-kubernetes-engine
kubernetes
kubernetes-ingress

4 Answers

7/24/2019

In case you're using helm to deploy nginx-ingress.

First create a static IP address. In google the Network Loadbalancers (NLBs) only support regional static IPs:

gcloud compute addresses create my-static-ip-address --region us-east4

Then install nginx-helm with the ip address as a loadBalancerIP parameter

helm install --name nginx-ingress stable/nginx-ingress --namespace my-namespace --set controller.service.loadBalancerIP=35.186.172.1
-- Bernie Lenz
Source: StackOverflow

2/13/2018

First question

As Radek 'Goblin' Pieczonka already pointed you out it is possible to do so. I just wanted to link you to the official documentation regarding this matter:

If you have multiple Ingress controllers in a single cluster, you can pick one by specifying the ingress.class annotation, eg creating an Ingress with an annotation like

metadata:
  name: foo
  annotations:
    kubernetes.io/ingress.class: "gce"

will target the GCE controller, forcing the nginx controller to ignore it, while an annotation like

metadata:
  name: foo
  annotations:
    kubernetes.io/ingress.class: "nginx"

Second question

Since you are making use of the Google Cloud Platform I can give you further details regarding this implementation of Kubernetes in Google.

Consider that:

By default, Kubernetes Engine allocates ephemeral external IP addresses for HTTP applications exposed through an Ingress.

However of course you can use static IP addressed for your ingress resource, there is an official step to step guide showing you how to create a HTTP Load Balancing with Ingress making use of a ingress resource and to link to it a static IP or how to promote an "ephemeral" already in use IP to be static.

Try to go through it and if you face some issue update the question and ask!

-- GalloCedrone
Source: StackOverflow

2/13/2018

For the nginx-ingress controller you have to set the external IP on the service:

spec:
  loadBalancerIP: "42.42.42.42"
  externalTrafficPolicy: "Local"
-- unguiculus
Source: StackOverflow

2/13/2018

It is perfectly fine to run multiple ingress controllers inside kubernetes, but they need to be aware which Ingress objects they are supposed to instantiate. That is done with a special annotation like :

kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: "nginx"

which tells that this ingress is expected to be provided by and only by nginx ingress controller.

As for IP, Some cloud providers allow the loadBalancerIP to be specified. with this you can controll the public IP of a service.

-- Radek 'Goblin' Pieczonka
Source: StackOverflow