I understand that in Kubernetes you don't want to "tie" a pod to a host, but in certain cases you might need to.
In my particular case I have a DB that lives on blockstorage which is mounted to a specific host.
What I am trying to accomplish with Kubernetes is the equivalent of a bind-mount in Docker. I want to specify the directory on the host that I need mounted in the pod, similar to this:
/mnt/BTC_2:/root/.bitcoin:rw
How do I specify the location of where I want my persistent storage to be on the node/host? Would this be a hostPath
volume like the following:
volumeMounts:
- mountPath: /root/.bitcoin
name: test-volume
volumes:
- name: test-volume
hostPath:
# directory location on host
path: /mnt/BTC_2
I want to specify the directory on the host that I need mounted in the pod
That should be documented here
A hostPath volume mounts a file or directory from the host node’s filesystem into your pod. This is not something that most Pods will need, but it offers a powerful escape hatch for some applications.
Warning:
The files or directories created on the underlying hosts are only writable by root. You either need to run your process as root in a privileged container or modify the file permissions on the host to be able to write to a hostPath volume
volumes:
- name: test-volume
hostPath:
# directory location on host
path: /data
# this field is optional
type: Directory