6.3.7. 配置卷以在 pod 中用于多种用途
您可以使用 volumeMounts.subPath 属性来指定卷中的 subPath 而非卷的根目录,将卷配置为允许在一个 pod 中多处使用这个卷。
流程
运行
oc rsh命令来查看卷中的文件列表:$ oc rsh <pod>输出示例
sh-4.2$ ls /path/to/volume/subpath/mount example_file1 example_file2 example_file3指定
subPath:带有
subPath参数的Podspec 示例apiVersion: v1 kind: Pod metadata: name: my-site spec: containers: - name: mysql image: mysql volumeMounts: - mountPath: /var/lib/mysql name: site-data subPath: mysql1 - name: php image: php volumeMounts: - mountPath: /var/www/html name: site-data subPath: html2 volumes: - name: site-data persistentVolumeClaim: claimName: my-site-data