Проблема объемного монтирования Kurbernetes ConfigMaps - PullRequest
0 голосов
/ 12 июня 2018

Я не могу смонтировать configmap с помощью многопапольного монтирования тома.

Структура моего volume-mount.yaml приведена ниже:

НЕ РАБОТАЕТ

apiVersion: v1
kind: Pod
metadata:
  name: test-web
spec:
  containers:
    - name: test-web
      image: docker.io/hello-world    
      volumeMounts:
      - name: config-volume
        mountPath: /usr/test
  volumes:
    - name: config-volume
      configMap:
        name: test-config-map
        items:
       - key: application.properties 
         path: test-web
       - key: test.xml
          path: test-web/configs/test_config
  restartPolicy: Never

Ошибка :

MountVolume.SetUp failed for volume "config-volume" : open /var/lib/kubelet/pods/93768c34-6dc6-11e8-9546-025000000001/volumes/kubernetes.io~configmap/config-volume/..2018_06_11_22_27_08.476420050/test-web: is a directory`

РАБОТАЕТ

apiVersion: v1
kind: Pod
metadata:
  name: test-web
spec:
  containers:
    - name: test-web
      image: docker.io/hello-world    
      volumeMounts:
      - name: config-volume
        mountPath: /usr/test
  volumes:
    - name: config-volume
      configMap:
        name: test-config-map
        items:
       - key: test.xml
          path: test-web/configs/test_config
  restartPolicy: Never

Кроме того, configmap монтируется от имени пользователя rootгде, поскольку мы хотим, чтобы монтирование тома происходило от имени конкретного пользователя.

Не могли бы вы сообщить мне, что мне может не хватать в моем файле yaml, чтобы устранить вышеуказанные 2 проблемы.

1 Ответ

0 голосов
/ 12 июня 2018

В вашем случае это должно подходить:

apiVersion: v1
kind: Pod
metadata:
  name: test-web
spec:
  containers:
    - name: test-web
      image: docker.io/hello-world
      volumeMounts:
      - name: config-volume-1
        mountPath: /usr/test1
      - name: config-volume-2
        mountPath: /usr/test2
  volumes:
    - name: config-volume-1
      configMap:
        name: test-config-map
        items:
        - key: application.properties 
          path: test-web
    - name: config-volume-2
      configMap:
        name: test-config-map
        items:
        - key: test.xml
          path: test-web/configs/test_config
  restartPolicy: Never

Ссылка на: https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/

...