<p>I have multiple pods, that scale up and down automatically.</p>
<p>I am using an ingress as entry point. I need to route external traffic to a specific pod base on some conditions (lets say path). At the point the request is made I am sure the specific pod is up.</p>
<p>For example lets say I have domain someTest.com, that normally routes traffic to pod 1, 2 and 3 (lets say I identify them by internal ips - 192.168.1.10, 192.168.1.11 and 192.168.1.13).</p>
<p>When I call someTest.com/specialRequest/12, I need to route the traffic to 192.168.1.12, when I call someTest.com/specialRequest/13, I want to route traffic to 192.168.1.13. For normal cases (someTest.com/normalRequest) I just want to do the lb do his epic job normally.</p>
<p>If pods scale up and 192.168.1.14 appears, I need to be able to call someTest.com/specialRequest/14 and be routed to the mentioned pod.</p>
<p>Is there anyway I can achieve this?</p>

zozo
<p>Yes, you can easily achieve this using Kubernetes Ingress. Here is a sample code that might help:</p>
<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: app-ingress
  spec:
    rules:
    - host: YourHostName.com
      http:
        paths:
        - path: /
          backend:
            serviceName: Service1
            servicePort: 8000
        - path: /api
          backend:
            serviceName: Service2
            servicePort: 8080
        - path: /admin
          backend:
            serviceName: Service3
            servicePort: 80
</code></pre>
<p>Please not that the ingress rules have serviceNames and not pod names, so you will have to create services for your pods. Here is an example for a service which exposes nginx as a service in Kubernetes:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: nginx-service
  labels:
    io.kompose.service: nginx
spec:
  ports:
  - name: &quot;80&quot;
    port: 80
    targetPort: 80
  selector:
    io.kompose.service: nginx
</code></pre>
