I want my applications to write log files at a host location, so I'm mounting a hostPath
volume. But all applications try to write logs using the same file name.
I'd like to separate the files into folders named after the Pod names, but I see nowhere in the documentation how to implement it:
volumes:
- name: logs-volume
hostPath:
path: /var/logs/apps/${POD_NAME}
type: DirectoryOrCreate
In the (not working) example above, apps should write files to the POD_NAME folder.
Is it possible?
As of kubernetes 1.17 this is supported using subPathExpr. See https://kubernetes.io/docs/concepts/storage/volumes/#using-subpath-expanded-environment for details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With