简体   繁体   中英

Mount configmap file onto hostpath volume

I have mounted a hostpath volume in a Kubernetes container. Now I want to mount a configmap file onto the hostpath volume.

Is that possible?

Not really, a larger question would be would you'd want to do that?

The standard way to add configurations in Kubernetes is using ConfigMaps. They are stored in etcd and the size limit is 1MB . When your pod comes up the configuration is mounted on a pod mount point that you can specify in the pod spec.

You may want the opposite which is to use a hostPath that has some configuration and that's possible. Say, that you want to have some config that is larger than 1MB (which is not usual) and have your pod use it. The gotcha here is that you need to put this hostPath and the files in all your cluster nodes where your pod may start.

No. The volume mounts are all about pushing data into pods or persisting data that originates in a pod, and aren't usually a bidirectional data transfer mechanism.

If you want to see what's in a ConfigMap, you can always kubectl get configmap NAME -o yaml to dump it out.

(With some exceptions around things like the Docker socket, hostPath volumes aren't that common in non-Minikube Kubernetes installations, especially once you get into multi-host setups, and I'd investigate other paths to do whatever you're using it for now.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM