Red Hat Training
A Red Hat training course is available for OpenShift Container Platform
21.3.3. ボリュームでの使用
ConfigMap はボリュームで使用することもできます。以下の ConfigMap の例に戻りましょう。
apiVersion: v1 kind: ConfigMap metadata: name: special-config namespace: default data: special.how: very special.type: charm
ボリュームでこの ConfigMap を使用する方法として 2 つの異なるオプションがあります。最も基本的な方法は、キーがファイル名であり、ファイルの内容がキーの値になっているファイルでボリュームを設定する方法です。
apiVersion: v1
kind: Pod
metadata:
name: dapi-test-pod
spec:
containers:
- name: test-container
image: gcr.io/google_containers/busybox
command: [ "/bin/sh", "cat", "/etc/config/special.how" ]
volumeMounts:
- name: config-volume
mountPath: /etc/config
volumes:
- name: config-volume
configMap:
name: special-config
restartPolicy: Neverこの Pod が実行されると出力は以下のようになります。
very
ConfigMap キーが展開されるボリューム内のパスを制御することもできます。
apiVersion: v1
kind: Pod
metadata:
name: dapi-test-pod
spec:
containers:
- name: test-container
image: gcr.io/google_containers/busybox
command: [ "/bin/sh", "cat", "/etc/config/path/to/special-key" ]
volumeMounts:
- name: config-volume
mountPath: /etc/config
volumes:
- name: config-volume
configMap:
name: special-config
items:
- key: special.how
path: path/to/special-key
restartPolicy: Neverこの Pod が実行されると出力は以下のようになります。
very