<p>I have a StatefulSet with pods <code>server-0</code>, <code>server-1</code>, etc. I want to expose them directly to the internet with URLs like server-0.mydomain.com or like mydomain.com/server-0.</p>

<p>I want to be able to scale the StatefulSet and automatically be able to access the new pods from the internet. For example, if I scale it up to include a <code>server-2</code>, I want mydomain.com/server-2 to route requests to the new pod when it's ready. I don't want to have to also scale some other resource or create another Service to achieve that effect.</p>

<p>I could achieve this with a custom proxy service that just checks the request path and forwards to the correct pod internally, but this seems error-prone and wasteful.</p>

<p>Is there a way to cause an Ingress to automatically route to different pods within a StatefulSet, or some other built-in technique that would avoid custom code?</p>

Riley Lark
<p>I don't think you can do it. Being part of the same statefulSet, all pods up to pod-x, are targeted by a service. As you can't define which pod is going to get a request, you can't force "pod-1.yourapp.com" or "yourapp.com/pod-1" to be sent to pod-1. It will be sent to the service, and the service might sent it to pod-4.</p>

<p>Even though if you could, you would need to dynamically update your ingress rules, which can cause a downtime of minutes, easily.</p>

<p>With the custom proxy, I see it impossible too. Note that it would need to basically replace the service behind the pods. If your ingress controller knows that it needs to deliver a packet to a service, now you have to force it to deliver to your proxy. But how?</p>
