'Resolve Kubernetes ingress subdomain to service with the same name

I want to automatically map the subdomain name to the service.

If the subdomain is serviceX.example.com it should be routed to the service name serviceX

Is there any way I can pass a regexp that automatically writes the name?

Something like this:

apiVersion: networking.k8s.io/v1
kind: Ingress
  name: serviceX-i
  namespace: examples
spec:
  rules:
  - host: /*/i.example.com
    http:
      paths:
      - backend:
          service:
            name: $i
            port:
              number: 3010
        path: /

Ingress example:

apiVersion: networking.k8s.io/v1
kind: Ingress
  name: serviceX-i
  namespace: examples
spec:
  rules:
  - host: serviceX.example.com
    http:
      paths:
      - backend:
          service:
            name: serviceX
            port:
              number: 3010
        path: /


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source