A few things:
- You will need to reserve a global static IP address.
- You will need to create/update your DNS record to point to that IP address.
- There is a 1-1 mapping between GKE Ingress and a GCP external load balancer. This means that you cannot have multiple Ingress resources mapped to the same external IP.
- If you want to have multiple applications behind the same Ingress, you can configure your Ingress resource to use path based or name based virtual hosting to route to multiple backend applications.
Reserve a static IP address:
gcloud compute addresses create ${ADDRESS} --global
Replace ${ADDRESS} with any name you like.
Annotate your Ingress resource to tell the load balancer to use the static IP created above
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: helloweb
annotations:
kubernetes.io/ingress.global-static-ip-name: ${ADDRESS}
Replace ${ADDRESS} with the name of the static IP created in the previous step
Configure multiple backend apps
Path-based:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: multi-app-fanout
annotations:
kubernetes.io/ingress.global-static-ip-name: ${ADDRESS}
spec:
rules:
- http:
paths:
- path: /*
pathType: ImplementationSpecific
backend:
service:
name: app1
port:
number: 8080
- path: /app2/*
pathType: ImplementationSpecific
backend:
service:
name: app2
port:
number: 8080
- path: /app3/*
pathType: ImplementationSpecific
backend:
service:
name: app3
port:
number: 8080
You would access your apps as follows:
- app-dev.company.com
- app-dev.company.com/app2
- app-dev.company.com/app3
Name-based virtual hosting:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: multi-app-virtual
annotations:
kubernetes.io/ingress.global-static-ip-name: ${ADDRESS}
spec:
rules:
- host: app1.app-dev.company.com
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: app1
port:
number: 8080
- host: app2.app-dev.company.com
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: app2
port:
number: 8080
- host: ap32.app-dev.company.com
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: app3
port:
number: 8080
You would access your apps as follows:
- app1.app-dev.company.com
- app2.app-dev.company.com
- app3.app-dev.company.com
Configure DNS records
If you choose to do path-based routing, then you just need to add a single DNS A record which maps app-dev.company.com to the global IP address created above.
If you choose name-based virtual hosting, you'll need to create a wildcard record mapping *.app-dev.company.com to the global IP address.
See https://cloud.google.com/kubernetes-engine/docs/tutorials/configuring-domain-name-static-ip for more info.