In this article we will go through how you can point multiple domains to Single ingress on Google Cloud.
For this article we are going to assume that you already understand how to host a website or service on GKE. You can also follow our one of the older post on it.
Step 1: Reserve static ip address
You should reserve an static ip address for your ingress. Follow official doc
gcloud compute addresses create ADDRESS_NAME \
--ip-version [IPV4 | IPV6]
Step 2: Generate Google managed certificates for each domain
You should create certificates for each domain. Follow the official document
- domain-name1kubectl apply -f certificate-name.yaml
Step 3: Define the ingress with the domains and certificates
In the below we have used example-ip-address as the static ip address of the ingress.
Three certificates for three domains which we are going to host on this ingress.
And finally we map these domains to a backend service.
In the above example i am using same service as a backend for all the domains. You can change them to different backend services. Also you can change the port information to the values which you are using.
Once you apply your ingress changes. You can see your ingress showing 3 endpoints in the GKE console.
There could be multiple reasons when you would like to have multiple domains pointing to same backend service. An example would be having a single service to different country specific domains etc.
Let me know if this was helpful. You can follow us on twitter