<p>i want a daemonset-redis where every node will have it's own caching and each deployment pod will communicate with it's local daemonset-redis how to achieve it? how to reference daemonset pod in the same node from within docker-container?</p>

<p><strong>UPDATE</strong>:
i rather not use service option and make sure each pod access its local daemonset</p>

<pre class="lang-py prettyprint-override"><code>apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: redislocal
spec:
  selector:
    matchLabels:
      name: redislocal
  template:
    metadata:
      labels:
        name: redislocal
    spec:
      hostNetwork: true
      containers:
      - name: redislocal
        image: redis:5.0.5-alpine
        ports:
        - containerPort: 6379
          hostPort: 6379

</code></pre>

<p>There is a way of <strong>not</strong> using a <code>service</code>.</p>

<p>You can <a href="https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/" rel="noreferrer">Expose Pod Information to Containers Through Environment Variables</a>.</p>

<p>And you can use <code>status.hostIP</code> to know the ip address of node where <code>pod</code> is running.
This was introduced in Kubernetes 1.7 <a href="https://github.com/kubernetes/kubernetes/pull/42717" rel="noreferrer">link</a></p>

<p>You can add that to your <code>pod</code> or <code>deployment</code> yaml:</p>

<pre><code>env:
- name: HOST_IP
  valueFrom:
    fieldRef:
      fieldPath: status.hostIP
</code></pre>

<p>It will set an variable <code>HOST_IP</code> which will have a value of node ip on which the <code>pod</code> is running, then you can use it to connect to a local <code>DeamonSet</code>.</p>
