I have been trying to use something along these lines to access a file in a volume mount:
with open('./log/file.json', 'w+') as f:
f.write(json.dumps(output, sort_keys=True, indent=4))
but it is not working. Are there any ideas? In my deployment file, I have this:
volumeMounts:
- mountPath: /logs
name: wag-log
You've defined a volumeMount
with the mountPath
set to /logs
, which would mount a volume into the /logs
directory. In your Python code you're writing at the path ./log/file.json
, which is not in /logs
.
Try to write a log to the directory you mounted, for example:
with open('/logs/file.json', 'w+') as f:
f.write(json.dumps(output, sort_keys=True, indent=4))