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的名字)是统一层级。

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