Google Cloud Kubernetes Ingress Static IP address not reflected and different from setup

8/4/2020

I am trying to deploy a complete web application using GKE on Google Cloud (backend as nodejs, and frontend angular). Then enable SSL for it afterward.

I created a global IP address (And saw it in the list afterward): gcloud compute addresses create mathbux-static-ip --global

After that I have deployed both my backend and frontend - containers and yaml files.

How it looks like in Google Cloud

The problem here is that the IP address reflected on the ingress controller comes from nowhere, and is different from what I set it to (the static IP address I just made above).

I have followed the guidelines of how to install Nginx-ingress setup on GKE by following this: https://kubernetes.github.io/ingress-nginx/deploy/#gce-gke

kubectl create clusterrolebinding cluster-admin-binding \
  --clusterrole cluster-admin \
  --user $(gcloud config get-value account)

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.34.1/deploy/static/provider/cloud/deploy.yaml

Here is a snippet part of my ingress.yaml:

.... truncated . . .
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: mathbux-ingress-frontend
  namespace: default
  annotations:
    kubernetes.io/ingress.class: nginx
    kubernetes.io/ingress.global-static-ip-name: "mathbux-static-ip"
    networking.gke.io/managed-certificates: mathbux-ssl
    nginx.ingress.kubernetes.io/rewrite-target: /

And here's a snippet of my managed certificate file as in Google Documentation:

apiVersion: networking.gke.io/v1beta2
kind: ManagedCertificate
metadata:
  name: mathbux-ssl
spec:
  domains:
    - mathbux.com
    - www.mathbux.com

The whole application works perfectly when I go to the generated IP address, and works as intended only that:

1.) The IP address is not the specific static global IP address I created and supposedly set on my ingress.yaml

2.) Respectively, SSL also fails. (Do note I have already pointed my Domain Names to the Static IP address I manually made)

-- Raven
devops
docker
google-cloud-platform
google-kubernetes-engine
kubernetes

1 Answer

8/5/2020

The annotation that you are using - kubernetes.io/ingress.global-static-ip-name - is available for default GKE ingress, which is essentially a google load balancer - see documentation here - https://cloud.google.com/kubernetes-engine/docs/tutorials/http-balancer.

However, what you did instead is you deployed ingress-nginx (which is a different ingress provider) and assigned your ingress resource to it via kubernetes.io/ingress.class: nginx which essentially makes your static ip annotation meaningless.

So, you need to decide which ingress you want to use. If you want to use GKE's load balancer, remove ingress nginx and follow documentation for default GKE ingress that I linked above.

If instead you want to use ingress nginx, you can find its documentation, including ssl configuration, here - https://kubernetes.github.io/ingress-nginx/.

-- taleodor
Source: StackOverflow