Kubernetes mount volume on existing directory with files inside the container

前端 未结 1 915
春和景丽
春和景丽 2021-01-02 02:17

I am using k8s with version 1.11 and CephFS as storage.

I am trying to mount the directory created on the CephFS in the pod. To achieve the same I have written the f

1条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-02 02:34

    Unfortunately Kubernetes' volume system is very different from Docker's so this is not possible directly. If there is a single file (or a small number) you can use subPath projection like this:

    volumeMounts:
    - name: cephfs-0
      mountPath: /opt/myapplication/conf/foo.conf
      subPath: foo.conf
    

    Repeat that for each file. But if you have a lot of files, or if they can vary, then you have to handle this at runtime or use templating tools. Usually that means mounting it somewhere else and setting up symlinks before your main process starts.

    0 讨论(0)
提交回复
热议问题