<p>Below is an example <code>IngressRoute</code>.</p>
<p>I would like to have something like this where the first part of the domain would map to a Kubernetes service without having to statically define the service name.</p>
<p>service1.api.test.com -&gt; service1</p>
<p>service2.api.test.com -&gt; service1</p>
<pre><code>apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: ingressroute
  namespace: default
spec:
  entryPoints:
    - web
  routes:
  - match: &quot;HostRegexp(`{subdomain:[a-z]+}.api.test.com`)&quot;
    kind: Rule
    services:
    - name: whoami  # can this be dynamic?
      port: 80
</code></pre>

<p>No it's not possible. Because even if you are able to match the host regular expression it will not know under the hood which service the request needs to go to.</p>
<p>So you will need create two separate matches for different services in the same ingressRoute</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: ingressroute
  namespace: default
spec:
  entryPoints:
    - web
  routes:
  - match: &quot;HostRegexp(`someservice.yourdomain.com`) &amp;&amp; PathPrefix(`/`)&quot;
    kind: Rule
    services:
    - name: whoamiV1
      port: 80
  - match: &quot;HostRegexp(`yourdomain.com`,`{subdomain:[a-zA-Z0-9-]+}.yourdomain.com`) &amp;&amp;PathPrefix(`/api/someservice/`)&quot;
    kind: Rule
    services:
    - name: whoamiV2
      port: 80
</code></pre>
<p>For more details you can refer the <a href="https://doc.traefik.io/traefik/providers/kubernetes-crd/" rel="nofollow noreferrer">docs</a></p>
