<p>Is it possible to select a service/pod via its label from Ingress (to direct the traffic to)?</p>

<p>Let's say I have 2 similar pods/services with different labels, but I want to direct the traffic to only one of them</p>

<p>I'm looking for something similar to this:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: Ingress-name
  labels:
    owner: me
selector:
  matchLabels:
    podlabel: pod-label
spec:
  rules:
  - host: ${INGRESS_HOST}
    http:
      paths:
        - path: /api
          backend:
            serviceName: &lt;something&gt;
            servicePort: &lt;something&gt;
</code></pre>

<p>how should I support this part:</p>

<pre><code>selector:
  matchLabels:
    podlabel: pod-label
</code></pre>

Mahyar
<p>If you want to select a service name from ingress then you can use </p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
spec:
  rules:
  - host: ${INGRESS_HOST}
    http:
      paths:
        - path: /api
          backend:
            serviceName: &lt;service name&gt;
            servicePort: &lt;service name&gt;
</code></pre>

<p>If you want to manage the traffic to redirect to particular pod then you can achieve this at the service layer.</p>

<p>If you want to blue/green deployment etc you can manage and divert traffic to particular pod from service only.</p>

<p>So ingress will be pointing to the same service but service will be changing pointing of pod. </p>

<p>Check this blue-green deployment: <a href="https://www.ianlewis.org/en/bluegreen-deployments-kubernetes" rel="nofollow noreferrer">https://www.ianlewis.org/en/bluegreen-deployments-kubernetes</a> you can find out how service manages traffic routes based on lables blue and green.</p>
