Kubernetes config map symlinks (..data/) : is there a way to avoid them?

后端 未结 2 461
无人共我
无人共我 2021-02-05 09:03

I have noticed that when I create and mount a config map that contains some text files, the container will see those files as symlinks to ../data/myfile.txt .

2条回答
  •  再見小時候
    2021-02-05 09:32

    I am afraid I don't know if you can tell Kubernetes not to generate those symlinks although I think that it is a native behaviour.

    If having those files and links is an issue, a workaround that I can think of is to mount the configmap on one folder and copy the files over to another folder when you initialise the container:

      initContainers:
        - name: copy-config
          image: busybox
          command: ['sh', '-c', 'cp /configmap/* /configs']
          volumeMounts:
            - name: configmap
              mountPath: /configmap
            - name: config
              mountPath: /configs
    

    But you would have to declare two volumes, one for the configMap (configmap) and one for the final directory (config):

      volumes:
        - name: config
          emptyDir: {}
        - name: configmap
          configMap:
            name: myconfigmap
    

    Change the type of volume for the config volume as you please obviously.

提交回复
热议问题