Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't connect static ip to Ingress on GKE

I am trying to connect my ingress to a static ip. I seem to be following all the tutorials, but still I cannot seem to attach my static ip to ingress. My ingress file is as follows (refering to the static ip "test-ip")

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress-web
  annotations:
    kubernetes.io/ingress.global-static-ip-name: "test-ip"
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/add-base-url: "true"
    nginx.ingress.kubernetes.io/ssl-redirect: "true"
spec:
  rules:
    - http:
        paths:
          - path: /api/
            backend:
              serviceName: api-cluster-ip-service
              servicePort: 5005
          - path: /
            backend:
              serviceName: web-cluster-ip-service
              servicePort: 80

However, when I run

kubectl get ingress ingress-web

it returns

kubectl get ingress ingress-web
NAME          HOSTS     ADDRESS   PORTS     AGE
ingress-web   *                   80        4m

without giving the address. In the VPC network [External IP addresses ] the static ip is there, it is global, but it keeps saying: In use by None

 gcloud compute addresses describe test-ip --global

gives

address: 34.240.xx.xxx
creationTimestamp: '2019-03-26T00:34:26.086-07:00'
description: ''
id: '536303927960423409'
kind: compute#address
name: test-ip
networkTier: PREMIUM
selfLink: https://www.googleapis.com/compute/v1/projects/my-project- adbc8/global/addresses/test-ip
status: RESERVED

What am I missing here?

like image 792
Mike Avatar asked Mar 26 '19 12:03

Mike


3 Answers

I ran into this issue. I believe it has been fixed by this pull request.

Changing

kubernetes.io/ingress.global-static-ip-name

to

kubernetes.io/ingress.regional-static-ip-name

Worked for me.

like image 179
Aaron Renoir Avatar answered Nov 10 '22 06:11

Aaron Renoir


I've spent hours trying to figure the issue out. It simply seems like a bug with GKE.

What solved it was:

  1. Starting ingress with no static ip
  2. Going to cloud console on the web under VPC Network > External IP addresses
  3. Waiting for the Ingress ip to show up
  4. Setting is as static, and giving it a name
  5. Adding kubernetes.io/ingress.global-static-ip-name: <ip name> Ingress yaml and applying it.
like image 24
Anton Avatar answered Nov 10 '22 07:11

Anton


You have to make sure the IP you created in GCP is Global and not Regional in order to use the following annotation in your ingress:

kubernetes.io/ingress.global-static-ip-name
like image 4
iji Avatar answered Nov 10 '22 08:11

iji