<p>I have an agent (datadog agent but could be something else) running on all the nodes of my cluster, deployed through a DaemonSet. This agent is collecting diverse metrics about the host: cpu and memory usage, IO, which containers are running.</p>

<p>It can also collect custom metrics, by listening on a specific port 1234.</p>

<p>How can I send data from a pod to the instance of the agent running on the same node than the pod?
If I use a Kubernetes service the calls to send the metric will be load balanced across all my agents and I'll lose the correlation between the pod emitting the metric and the host it's running on.</p>

<p>I use the exact same setup, <code>dd-agent</code> running as a DaemonSet in my kubernetes cluster. Using the same port mapping you commented <a href="https://stackoverflow.com/questions/44855220/sending-data-from-one-pod-to-another-pod-running-specifically-on-the-same-host#comment76761846_44857071">here</a>, you can just send metrics to the hostname of the node an application is running on.</p>

<p>You can add the node name to the pods environment using the downward api in your pod spec:</p>

<pre><code>env:
- name: NODE_NAME
  valueFrom:
    fieldRef:
      fieldPath: spec.nodeName 
</code></pre>

<p>Then, you can just open an UDP connection to <code>${NODE_NAME}:8125</code> to connect to the datadog agent.</p>
