<p>I have deployed a statefulset in AKS - My goal is to load balance traffic to my statefulset.</p>
<p>From my understanding I can define a LoadBalancer Service that can route traffic based on Selectors, something like this.</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: nginx
  labels:
    app: nginx
spec:
  type: LoadBalancer
  ports:
  - port: 80
    name: web
  selector:
    app: nginx
</code></pre>
<p>However I don't want to necessarily go down the LoadBalance route and I would prefer Ingress doing this work for me,   My question is can any of the ingress controller support routing rules which can do Path based routing to  endpoints based on selectors? Instead of routing to another service.</p>
<p><strong>Update</strong>
To elaborate more on the scenario - Each pod in my statefulset is a stateless node doing data processing of a HTTP feed. I want my ingress service to be able to load balance traffic across these statefulset pods ( honoring keep-alives etc), however given the nature of statefulsets in k8s they are currently exposed through a headless service. I am not sure if a headless service can load balance traffic to my statefulsets?</p>
<p><strong>Update 2</strong>
Quick search reveals <a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="nofollow noreferrer">headless</a> service does <em><strong>not</strong></em>  loadbalance</p>
<p><code>Sometimes you don't need load-balancing and a single Service IP. In this case, you can create what are termed &quot;headless&quot; Services, by explicitly specifying &quot;None&quot; for the cluster IP (.spec.clusterIP).</code></p>

<p>As much i know it's not possible to do the selector-based routing with ingress.</p>
<p>selector based routing is mostly used during a Blue-green deployment or canary deployment you can only achieve this by using the service mesh. You can use any of the service mesh like <strong>istio</strong> or <strong>APP mesh</strong> and you can do the selector base routing.</p>
<blockquote>
<p>I have deployed a statefulset in AKS - My goal is to load balance
traffic to my statefulset.</p>
</blockquote>
<p>if your goal is to just load balance traffic you can use the ingress controller maybe still not sure about scenrio you are trying to explain.</p>
<p>By default kubernetes <strong>service</strong> also <strong>Load balance</strong> the traffic across the <strong>PODs</strong>.</p>
<p>Flow will be something like <code>DNS &gt; ingress &gt; ingress controller &gt; Kubernetes service (Load balancing here) &gt; any of statefulset</code></p>
