Is it possible to use configmap with hostPath in kubernetes?

12/19/2017

Instead of using direct configuration for volume host path, like

 volumes:
    - name: mongo-24
      hostPath:
        path: /my/path/to/file/or/directory
        type: DirectoryOrCreate

I want to put this into configmap, so I have tried this one:

  volumes:
    - name: myVolume
      hostPath:
        path: 
          valueFrom:
          configMapKeyRef:
            name: common-config
            key: MY_VOLUME_PATH
        type: DirectoryOrCreate

but this was not successful, because:

error validating data: expected type string, for field spec.template.spec.volumes[0].hostPath.path, got map

Is it possible to use hostPath / path with config map?

-- Vladimir
kubernetes

1 Answer

12/19/2017

Simply put, no. The question is, why do you need it / what do you want to achieve ?

-- Radek 'Goblin' Pieczonka
Source: StackOverflow