问题原文
原帖链接 · Giles Thomas · CC BY-SA 3.0
In Kubernetes, you can create a volume to mount into a pod with type "HostPath" to specify that the storage should be provided by a directory on the node running the pod.
The documentation specifies "single node testing only – local storage is not supported in any way and WILL NOT WORK in a multi-node cluster", but I can't find any documentation as to why that is.
One reason that occurs to me is that the path would need to exist on every node in the cluster, and would need to be consistent so that the pod could be moved seamlessly from node to node. But it would be easy enough to mount an NFS disk onto a consistent mount point on all of the nodes so that constraint was satisfied.
Are there any other reasons that anyone knows about? Perhaps the "HostPath" plugin is just not designed for production use because others are more generally useful, the coding effort has all gone to the others?
已采纳解答
原帖链接 · ConnorJC · CC BY-SA 3.0
As you said, it's because the data will not be synced across multiple nodes. It's probably ok to do some weird syncing solution across multiple nodes if only one pod will access the data at a time, but this quickly becomes a headache with multiple pods.
Instead of syncing the directory with something like nfs, just use that as your volume instead of a HostPath volume. Kubernetes supports nfs as a volume already, and many many more solutions as well.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
