Wildcard sub-domain mapping in Ambassador API Gateway

1.6k views Asked by At

I am using Ambassador API Gateway in my GKE as below:

apiVersion: getambassador.io/v2
kind: Mapping
metadata:
  name: my-service
spec:
  host: app.mycompany.com
  prefix: /
  service: my-service

However, I would like to map all sub domains (*.mycompany.com) and route to my-service

apiVersion: getambassador.io/v2
kind: Mapping
metadata:
  name: my-service
spec:
  host: *.app.mycompany.com
  prefix: /
  service: my-service

How to map wildcard subdomain?

1

There are 1 answers

0
Yazen Nasr On

Based on this documentation, you have to set the host as a regex pattern to match against your subdomains.

So in your case, you'd want this:

apiVersion: getambassador.io/v2
kind: Mapping
metadata:
  name: my-service
spec:
  host: "[a-z]*\\.app\\.mycompany\\.com"
  host_regex: true
  prefix: /
  service: my-service