<p>I want a created Service per pod to be used from a dynamically generated Ingress.</p>
<p>But for that, I need a way to differentiate pods instantiated by my DaemonSet.</p>
<p>I tried:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Service
metadata:
  name: my-service-node1
spec:
  selector:
    app: my-app
    kubernetes.io/hostname: &quot;node1&quot;
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
</code></pre>
<p>but <code>kubernetes.io/hostname</code> is only defined in node,
I look for a way to forward this label, and I find this only <a href="https://stackoverflow.com/questions/57388658/how-to-inherit-node-labels-to-pod-labels-in-kubernetes">Q/A</a>.</p>
<p>Generating a random label for each DaemonSet should work too, but I think it is not possible too.</p>
<p>Using variables in my <code>template/metadata/labels</code> in my <code>DaemonSet</code> would be nice, but that does not exist too.</p>
<p>If I could refer a pod directly in my Ingress, that would fix my problem, but it look like an Ingress can only talk to a Service.</p>

Uriel
<p>Didn't get 100% of your problem however you can use the <strong>init container</strong> to add labels to <strong>service</strong> and <strong>POD</strong></p>
<p>So whenever any POD is starting it will run the init container first get the necessary label from where you want to get it. After that it will add the label to POD and update the service also with same selector.</p>
<p>Command for patch</p>
<pre><code>kubectl patch service &lt;Service-name&gt; -p '{&quot;spec&quot;:{&quot;selector&quot;:{&quot;app&quot;: &quot;new-app&quot;}}}'
</code></pre>
<p>To update the service you can use the <strong>Patch</strong> method</p>
<pre><code>apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: node2pod
spec:
  replicas: 1
  template:
    metadata:
      labels:
        name: node2pod
        app: node2pod
    spec:
      initContainers:
      - name: node2pod
        image: &lt;IMAGE&gt;
        command:
        - &quot;sh&quot;
        - &quot;-c&quot;
        - &quot;kubectl -n ${NAMESPACE} label pods ${POD_NAME} vm/rack=$(kubectl get no -Lvm/rack | grep ${NODE_NAME} | awk '{print $6}')&quot;
        - &quot;kubectl patch service &lt;Service-name&gt; -p '{&quot;spec&quot;:{&quot;selector&quot;:{&quot;app&quot;: &quot;new-app&quot;}}}'&quot;
        env:
        - name: NODE_NAME
          valueFrom:
            fieldRef:
              fieldPath: spec.nodeName
        - name: NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        - name: POD_NAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
      containers:
      - name: nginx
        image: nginx
</code></pre>
