k8s volumeMounts 功能 使用時subPath 參數

寫pod的yaml文件時,如果想使用雲存儲,則volumeMounts這個property,
mountPath 爲container內部目錄
而subPath 雖然緊跟mountpath, 最容易被誤解爲本地路徑,其實其爲遠端雲存儲上的子路徑

所以進入pod內部看磁盤情況,顯示
bbuser@stream-notifications-baseline-learn-tomcat-7cd697-2xwp7:~$ df -v
Filesystem 1K-blocks Used Available Use% Mounted on
10.114.70.2:/learn_perf_bbcontent_1/instance/stream-notifications-baseline 570422592 19338048 551084544 4% /mnt/bbcontent

- name: learn
        image: ${LEARN_DOCKER_IMAGE}
        imagePullPolicy: IfNotPresent
        resources:
          requests:
            cpu: ${LEARN_CPU_REQUEST}
            memory: ${LEARN_MEM_REQUEST}
          limits:
            cpu: ${LEARN_CPU_LIMITS}
            memory: ${LEARN_MEM_LIMITS}
        command:
        - ${BB_USER_HOME}/bin/launcher.sh
        env:
        - name: DEV_FEATURES
          valueFrom:
            configMapKeyRef:
              name: ${INSTANCE_NAME}-learn-config
              key: DEV_FEATURES
        volumeMounts:
        - name: bbcontent
          **mountPath: /mnt/bbcontent
          subPath: instance/${INSTANCE_NAME} **
   volumes:
      - name: bbcontent
        persistentVolumeClaim:
          claimName: learn-deployments-share

volume 和name(container的名字)是統一層級。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章