20.7. サブパスの指定
volumeMounts.subPath
プロパティーを使用し、ボリュームのルートの代わりにボリューム内で subPath
を指定します。 l>subPath
により、単一 Pod で複数の使用目的のために 1 つのボリュームを共有できます。
ボリューム内のファイルの一覧を表示するには、oc rsh
コマンドを実行します。
$ oc rsh <pod> sh-4.2$ ls /path/to/volume/subpath/mount example_file1 example_file2 example_file3
subPath
を指定します。
subPath の使用例
apiVersion: v1 kind: Pod metadata: name: my-site spec: containers: - name: mysql image: mysql volumeMounts: - mountPath: /var/lib/mysql name: site-data subPath: mysql 1 - name: php image: php volumeMounts: - mountPath: /var/www/html name: site-data subPath: html 2 volumes: - name: site-data persistentVolumeClaim: claimName: my-site-data