26.7. サブパスの指定
volumeMounts.subPath プロパティーを使用して、ボリュームのルートではなく、ボリューム内の サブパス を指定します。subPath を使用すると、1 つの Pod でボリュームを共有して複数の用途に使用できます。
ボリューム内のファイルの一覧を表示するには、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
- name: php
image: php
volumeMounts:
- mountPath: /var/www/html
name: site-data
subPath: html
volumes:
- name: site-data
persistentVolumeClaim:
claimName: my-site-data