Hosting multiple domains in GKE Ingress

k8scale.io
2 min readSep 27, 2020

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 \
--global \
--ip-version [IPV4 | IPV6]

Step 2: Generate Google managed certificates for each domain

You should create certificates for each domain. Follow the official document

apiVersion: networking.gke.io/v1beta2
kind: ManagedCertificate
metadata:
name: certificate-name
spec:
domains:
- domain-name1
kubectl 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.

example-domain1-cert,example-domain2-cert,example-domain3-cert”

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

https://twitter.com/k8scaleio

--

--