<p>I have several sites available at <code>http://service1/api</code> and <code>http://service2/api</code>
I want them to work on the same external address and routing occurs inside the kube</p>
<pre><code>http:/exturi/service1/api
http:/exturi/service2/api
</code></pre>
<p>Ingress configuration</p>
<pre><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: haproxy
  name: ingress-api
spec:
  rules:
  - host: api.sample.com
    http:
      paths:
      - backend:
          serviceName: edpcore-db-api
          servicePort: 13001
        path: /db-api/
        pathType: Prefix
  tls:
  - hosts:
    - api.sample.com
    secretName: tls-api-secret
</code></pre>
<p>how to configure ingress</p>

Nikolay Sulimov
<p>If you are using the Nginx ingress you can do routing using</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$2
  name: rewrite
  namespace: default
spec:
  rules:
  - host: rewrite.bar.com
    http:
      paths:
      - backend:
          serviceName: service-1
          servicePort: 80
        path: /service-1(/|$)(.*)
      - backend:
          serviceName: service-2
          servicePort: 80
        path: /service-2(/|$)(.*)
</code></pre>
<p>For example, the ingress definition above will result in the following rewrites:</p>
<pre><code>rewrite.bar.com/service1 rewrites to rewrite.bar.com/
rewrite.bar.com/service1/ rewrites to rewrite.bar.com/
rewrite.bar.com/service1/new rewrites to rewrite.bar.com/new
</code></pre>
<p>Refer : <a href="https://kubernetes.github.io/ingress-nginx/examples/rewrite/" rel="nofollow noreferrer">https://kubernetes.github.io/ingress-nginx/examples/rewrite/</a></p>
<p><strong>Extra</strong></p>
<p>If you don't want to remove service name or rewrite simple use this config</p>
<pre><code>    apiVersion: networking.k8s.io/v1
    kind: Ingress
    metadata:
      annotations:
        kubernetes.io/ingress.class: haproxy
      name: simple
      namespace: default
    spec:
      rules:
      - host: simple.bar.com
        http:
          paths:
          - backend:
              serviceName: service-1
              servicePort: 80
            path: /service-1
          - backend:
              serviceName: service-2
              servicePort: 80
            path: /service-2
</code></pre>
