Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Global static IP name on NGINX Ingress

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
like image 269
N. v Doorn Avatar asked Jan 04 '17 08:01

N. v Doorn


2 Answers

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.

like image 63
silgon Avatar answered Sep 20 '22 10:09

silgon


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.

like image 44
Anton Kostenko Avatar answered Sep 20 '22 10:09

Anton Kostenko