Writing from container to host in Kubernetes

5/25/2018

I currently have a job that runs a script. This script needs to create a file on the host file system.

To do so I make use of a hostPath volume with:

volumeMounts:
- mountPath: /var/logs/test
  name: joblogs
volumes:
- hostPath:
  path: /root/test
  type: DirectoryOrCreate
  name: joblogs

I used

 chcon -Rt svirt_sandbox_file_t /root/test

to allow the writing on this directory, but even if files are created in

/var/logs/test

they are not on

/root/test

on the host.

EDIT: The pod itself runs on the same node I am talking about.

-- djuarez
kubernetes
openshift

0 Answers