<p>I have configured a kubernetes ingress service but it only works when the path is /</p>

<p>I have tried all manner of different values for the path including:</p>

<pre><code>/*
/servicea
/servicea/
/servicea/*
</code></pre>

<p>This is my ingress configuration (that works)</p>

<pre><code>- apiVersion: extensions/v1beta1
  kind: Ingress
  metadata:
    name: boardingservice
    annotations:
      ingress.kubernetes.io/rewrite-target: /
  spec:
    rules:
    - host: my.url.com
      http:
        paths:
        - path: /
          backend:
            serviceName: servicea-nodeport
            servicePort: 80
</code></pre>

<p>This is my nodeport service</p>

<pre><code>- apiVersion: v1
  kind: Service
  metadata:
    name: servicea-nodeport
  spec:
    type: NodePort
    ports:
    - port: 80
      targetPort: 8081
      nodePort: 30124
    selector:
      app: servicea
</code></pre>

<p>And this is my deployment</p>

<pre><code>- apiVersion: extensions/v1beta1
  kind: Deployment
  metadata:
    name: servicea
  spec:
    replicas: 1
    template:
      metadata:
        name: ervicea
        labels:
          app: servicea
      spec: 
        containers:
        - image: 350329402011.dkr.ecr.eu-west-2.amazonaws.com/servicea
          name: servicea
          ports: 
          - containerPort: 8080
            protocol: TCP              
        - image: 350329402011.dkr.ecr.eu-west-2.amazonaws.com/serviceb
          name: serviceab
          ports: 
          - containerPort: 8081
            protocol: TCP  
</code></pre>

<p>If the path is / then I can do this <a href="http://my.url.com/api/ping" rel="noreferrer">http://my.url.com/api/ping</a>
but as I will have multiple services I want to do this: <a href="http://my.url.com/servicea/api/ping" rel="noreferrer">http://my.url.com/servicea/api/ping</a> but when I set the path to /servicea I get a 404.</p>

<p>I am running kubernetes on AWS with an ingress-nginx ingress controller</p>

<p>Any idea?</p>

<p>You are not using kubernetes Pods as they are intended to be used. <a href="https://kubernetes.io/docs/concepts/workloads/pods/pod/" rel="noreferrer">A Pod</a></p>

<blockquote>
  <p>it contains one or more application containers which are relatively tightly coupled — in a pre-container world, they would have executed on the same physical or virtual machine.</p>
</blockquote>

<p>If you have two applications, <code>servicea</code> and <code>serviceb</code>, they should be running on different Pods: one pod for <code>servicea</code> and another one for <code>serviceb</code>. This has many benefits: you can deploy them separately, scale them independently, etc.
As the <a href="https://kubernetes.io/docs/concepts/workloads/pods/pod-overview/#understanding-pods" rel="noreferrer">docs say</a></p>

<blockquote>
  <p>A Pod represents a unit of deployment: a single instance of an application in Kubernetes, which might consist of either a single container or a small number of containers that are tightly coupled and that share resources.</p>
</blockquote>

<p>These Pods can be created using <code>Deployments</code>, as you were already doing. That's fine and recommended.</p>

<p>Once you have the <code>Deployments</code> running, you'd create a different <code>Service</code> that would balance traffic between all the <code>Pod</code>s for a given <code>Deployment</code>.</p>

<p>And finally, you want to hit <code>servicea</code> or <code>serviceb</code> depending on the request URL. That can be done with <code>Ingress</code>, as you were trying, but <a href="https://kubernetes.io/docs/concepts/services-networking/ingress/#simple-fanout" rel="noreferrer">mapping each path to different services</a>. For example</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: test
  annotations:
    ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - host: my.url.com
    http:
      paths:
      - path: /servicea
        backend:
          serviceName: servicea
          servicePort: 80
      - path: /serviceb
        backend:
          serviceName: serviceb
          servicePort: 80
</code></pre>

<p>That way, requests going to your ingress controller using the /servicea path would be served by the Pods behind the <code>servicea</code> Service. And requests going to your ingress controller using the /serviceb path would be served by the Pods behind the <code>serviceb</code> Service.</p>
