<p>I have been trying to use something along these lines to access a file in a volume mount: </p>

<pre><code>with open('./log/file.json', 'w+') as f:
    f.write(json.dumps(output, sort_keys=True, indent=4))
</code></pre>

<p>but it is not working. Are there any ideas? In my deployment file, I have this:</p>

<pre><code>volumeMounts:
- mountPath: /logs
  name: wag-log
</code></pre>

Chlei
<p>You've defined a <code>volumeMount</code> with the <code>mountPath</code> set to <code>/logs</code>, which would mount a volume into the <code>/logs</code> directory. In your Python code you're writing at the path <code>./log/file.json</code>, which is not in <code>/logs</code>.</p>

<p>Try to write a log to the directory you mounted, for example:</p>

<pre class="lang-py prettyprint-override"><code>with open('/logs/file.json', 'w+') as f:
    f.write(json.dumps(output, sort_keys=True, indent=4))
</code></pre>
