<p>I have an issue at work with K8s Ingress and I will use fake examples here to illustrate my point.
Assume I have an app called Tweeta and my company is called ABC. My app currently sits on tweeta.abc.com.
But we want to migrate our app to app.abc.com/tweeta.</p>
<p>My current ingress in K8s is as belows:</p>
<pre><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: tweeta-ingress
spec:
  rules:
  - host: tweeta.abc.com
    http:
      paths:
      - path: /
        backend:
          serviceName: tweeta-frontend
          servicePort: 80
      - path: /api
        backend:
          serviceName: tweeta-backend
          servicePort: 80
</code></pre>
<p>For migration, I added a second ingress:</p>
<pre><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: tweeta-ingress-v2
spec:
  rules:
  - host: app.abc.com
    http:
      paths:
      - path: /tweeta
        backend:
          serviceName: tweeta-frontend
          servicePort: 80
      - path: /tweeta/api
        backend:
          serviceName: tweeta-backend
          servicePort: 80

</code></pre>
<p>For sake of continuity, I would like to have 2 ingresses pointing to my services at the same time. When the new domain is ready and working, I would just need to tear down the old ingress.</p>
<p>However, I am not getting any luck with the new domain with this ingress. Is it because it is hosted on a path and the k8s ingress needs to host on root? Or is it a configuration I would need to do on the nginx side?</p>

aijnij
<p>As far as I tried, I couldn't reproduce your problem. So I decided to describe how I tried to reproduce it, so you can follow the same steps and depending on where/if you fail, we can find what is causing the issue.</p>
<p>First of all, make sure you are using a <a href="https://kubernetes.github.io/ingress-nginx/deploy/" rel="nofollow noreferrer">NGINX Ingress</a> as it's more powerful.</p>
<p>I installed my NGINX Ingress using Helm following these steps:</p>
<pre><code>$ curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
$ helm repo add stable https://kubernetes-charts.storage.googleapis.com
$ helm repo update
$ helm install nginx-ingress stable/nginx-ingress
</code></pre>
<p>For the deployment, we are going to use an example from <a href="https://kubernetes.io/docs/tasks/access-application-cluster/ingress-minikube/" rel="nofollow noreferrer">here</a>.</p>
<p>Deploy a hello, world app</p>
<ol>
<li><p>Create a Deployment using the following command:</p>
<pre class="lang-sh prettyprint-override"><code>kubectl create deployment web --image=gcr.io/google-samples/hello-app:1.0
</code></pre>
<p>Output:</p>
<pre class="lang-sh prettyprint-override"><code>deployment.apps/web created
</code></pre>
</li>
<li><p>Expose the Deployment:</p>
<pre class="lang-sh prettyprint-override"><code>kubectl expose deployment web --type=NodePort --port=8080
</code></pre>
<p>Output:</p>
<pre class="lang-sh prettyprint-override"><code>service/web exposed
</code></pre>
</li>
</ol>
<p>Create Second Deployment</p>
<ol>
<li><p>Create a v2 Deployment using the following command:</p>
<pre class="lang-sh prettyprint-override"><code>kubectl create deployment web2 --image=gcr.io/google-samples/hello-app:2.0
</code></pre>
<p>Output:</p>
<pre class="lang-sh prettyprint-override"><code>deployment.apps/web2 created
</code></pre>
</li>
<li><p>Expose the Deployment:</p>
<pre class="lang-sh prettyprint-override"><code>kubectl expose deployment web2 --port=8080 --type=NodePort
</code></pre>
<p>Output:</p>
<pre class="lang-sh prettyprint-override"><code>service/web2 exposed
</code></pre>
</li>
</ol>
<p>It this point we have the Deployments and Services running:</p>
<pre><code>$ kubectl get deployments.apps 
NAME                            READY   UP-TO-DATE   AVAILABLE   AGE
web                             1/1     1            1           24m
web2                            1/1     1            1           22m
</code></pre>
<pre><code>$ kubectl get service
NAME                            TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)                      AGE
kubernetes                      ClusterIP      10.96.0.1        &lt;none&gt;        443/TCP                      5d5h
nginx-ingress-controller        LoadBalancer   10.111.183.151   &lt;pending&gt;     80:31974/TCP,443:32396/TCP   54m
nginx-ingress-default-backend   ClusterIP      10.104.30.84     &lt;none&gt;        80/TCP                       54m
web                             NodePort       10.102.38.233    &lt;none&gt;        8080:31887/TCP               24m
web2                            NodePort       10.108.203.191   &lt;none&gt;        8080:32405/TCP               23m
</code></pre>
<p>For the ingress, we are going to use the one provided in the question but we have to change the backends:</p>
<pre><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: tweeta-ingress
spec:
  rules:
  - host: tweeta.abc.com
    http:
      paths:
      - path: /
        backend:
          serviceName: web
          servicePort: 8080
      - path: /api
        backend:
          serviceName: web2
          servicePort: 8080          
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: tweeta-ingress-v2
spec:
  rules:
  - host: app.abc.com
    http:
      paths:
      - path: /tweeta
        backend:
          serviceName: web
          servicePort: 8080
      - path: /tweeta/api
        backend:
          serviceName: web2
          servicePort: 8080     
</code></pre>
<p>Now let's test our ingresses:</p>
<pre><code>$ curl tweeta.abc.com
Hello, world!
Version: 1.0.0
Hostname: web-6785d44d5-j8bgk

$ curl tweeta.abc.com/api
Hello, world!
Version: 2.0.0
Hostname: web2-8474c56fd-lx55n

$ curl app.abc.com/tweeta
Hello, world!
Version: 1.0.0
Hostname: web-6785d44d5-j8bgk

$ curl app.abc.com/tweeta/api
Hello, world!
Version: 2.0.0
Hostname: web2-8474c56fd-lx55n
</code></pre>
<p>As can be seen, everything is working fine with no mods in your ingresses.</p>
