Global static IP name on NGINX Ingress
Asked Answered
F

3

18

I'm having difficulties getting my Ingress controller running on Google Container Engine. I want to use an NGINX Ingress Controller with Basic Auth and use a reserved global static ip name (this can be made in the External IP addresses section in the Google Cloud Admin interface). When I use the gce class everything works fine except for the Basic Auth (which I think is not supported on the gce class), anenter code hered when I try to use the nginx class the Ingress Controller launches but the IP address that I reserved in the Google Cloud Admin interface will not be attached to the Ingress Controller. Does anyone know how to get this working? Here is my config file:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: webserver
  annotations:
    kubernetes.io/ingress.global-static-ip-name: "myreservedipname"
    kubernetes.io/ingress.class: "nginx"
    ingress.kubernetes.io/auth-type: basic
    ingress.kubernetes.io/auth-realm: "Auth required"
    ingress.kubernetes.io/auth-secret: htpasswd
spec:
  tls:
    - secretName: tls
  backend:
    serviceName: webserver
    servicePort: 80
Fonsie answered 4/1, 2017 at 8:48 Comment(4)
I guess you might want to have a look at this one : https://mcmap.net/q/742331/-gcloud-ingress-loadbalancer-static-ipWilkes
Possible duplicate of gcloud ingress loadbalancer / static ipGamut
The answer in your links does not work propertly. The image cannot be downloaded now. I also tried this link with no luck.Comply
Sheesh, over a year ago and still no answer!Colloid
C
6

I found a solution with helm.

helm install --name nginx-ingress stable/nginx-ingress \
      --set controller.service.loadBalancerIP=<YOUR_EXTERNAL_IP>

You should use the external-ip and not the name you gave with gcloud.

Also, in my case I also added --set rbac.create=true for permissions.

Comply answered 9/9, 2018 at 7:21 Comment(1)
As a comment to my answer, this seems to be the analogous helm code for @Anton_Kostenko code. However, for some reason at the time his answer didn't work for me which might not be the case for you if you want to use directly the kubernetes yaml file.Comply
E
4

External IP address can be attached to the Load Balancer which you can point to your Ingress controller.

One major remark - the External IP address should be reserved in the same region as the Kubernetes cluster.

To do it, you just need to deploy your Nginx-ingress service with type: LoadBalancer and set ExternalIP value, like this:

kind: Service
apiVersion: v1
metadata:
  name: ingress-nginx
  namespace: ingress-nginx
  labels:
    app: ingress-nginx
spec:
  loadBalancerIP: <YOUR_EXTERNAL_IP>
  type: LoadBalancer
  selector:
    app: ingress-nginx
  ports:
  - name: http
    port: 80
    targetPort: http
  - name: https
    port: 443
    targetPort: https

After deployment, Kubernetes will create a new Load Balancer with desired static IP which will be an entry-point for your Ingress.

@silgon, as I see, you already tried to do it, but without a positive result. But, it should work. If not - check the region of IP address and configuration once again.

Emlen answered 6/4, 2018 at 11:4 Comment(3)
I'll check it again on monday and I'll let you know what happens, I could have missed something. Thanks.Comply
also found docs for this: kubernetes.github.io/ingress-nginx/examples/static-ip/READMESlew
Thanks for the answer. I ended up using helm which worked fine for me. At the time I tested your implementation it didn't work. I don't know why since as you said the syntax seems correct.Comply
T
-4

Here's an example that I know works, could be an issue around your syntax:

kind: Ingress
metadata:
name: nginx
spec:
rules:
- host: nginx.192.168.99.100.nip.io
http:
paths:
- backend:
serviceName: nginx
servicePort: 80
Tidings answered 3/11, 2017 at 21:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.