1. 声明nas挂载卷
    spec:
      volumes:
        - name: nas
          persistentVolumeClaim:
            claimName: nas-static
2. 挂载nas子路径
      containers:
        - name: container-0
          image: nging:1.18.1-alpine
          ... 略
          volumeMounts:
            - name: nas
              mountPath: /data/website
              subPath: static
            - name: nas
              mountPath: /etc/nginx/ssl/
              subPath: config/ca
            - name: nas
              mountPath: /data/img
              subPath: static/images

说明:
1. 首先需要声明nas挂载卷,名称为 nas-static
2. 然后再使用子路径方式挂载nas卷:
    a. nas存储根目录下有两个目录 static、config
    b. 使用子路径挂载
        static 挂载到容器里的 /data/website;
        config/ca 挂载到容器里的 /etc/nginx/ssl
        static/images 挂载到容器里的 /data/img
     c. 二级子路径可以挂载到容器的不同挂载点
nas卷挂载:
默认为读写模式,需要设置只读模式时,添加一会行 readOnly: true

posted on 2021-03-31 11:24  51core  阅读(300)  评论(0)    收藏  举报