Wildcard sub-domain mapping in Ambassador API Gateway

11/29/2020

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?

-- Ha Doan
ambassador
google-kubernetes-engine
kubernetes
wildcard-mapping

1 Answer

12/5/2020

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
-- Yazen Nasr
Source: StackOverflow