<p>I am trying to write logs to the kubernetes host machine from pod.</p>

<p>Please could you suggest if an application inside the pod can write on the host machine?</p>

<p>Below is my configuration. I am seeing logs being written to '/opt/logstash/logs' inside the pod but i am not seeing them on the host machine inside '/home/centos/dev/logstash/logs'</p>

<pre><code>    volumeMounts:
    - name: sre-logstash-data-tcp
      mountPath: /opt/logstash/logs

  volumes:
  - name: sre-logstash-data-tcp
    hostPath:
      path: /home/centos/dev/logstash/logs
</code></pre>

bigskull
<blockquote>
  <p>Please could you suggest if an application inside the pod can write on the host machine?</p>
</blockquote>

<p>Yes, it can be configured to do so, hostPath is one of the ways to do so.</p>

<blockquote>
  <p>I am seeing logs being written to '/opt/logstash/logs' inside the pod but i am not seeing them on the host machine inside '/home/centos/dev/logstash/logs'</p>
</blockquote>

<p>That is most probably because node that pod is running on is different than node you are looking at /home/centos/dev/logstash/logs.</p>

<p>Check what node pod is running onto and then make sure to check path on that very node.</p>

<p>Just as a side note hostPath can be problematic for data persistence if you don't use some kind of node affinity to allocate pods to same node and can lead to confusion around it as well.</p>
