1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 12:46:18 +01:00
Files
openshift-docs/modules/nodes-containers-volumes-subpath.adoc
2024-11-05 22:51:43 +00:00

76 lines
1.7 KiB
Plaintext

// Module included in the following assemblies:
//
// * nodes/nodes-containers-volumes.adoc
:_mod-docs-content-type: PROCEDURE
[id="nodes-containers-volumes-subpath_{context}"]
= Configuring volumes for multiple uses in a pod
You can configure a volume to share one volume for
multiple uses in a single pod using the `volumeMounts.subPath` property to specify a `subPath` value inside a volume
instead of the volume's root.
[NOTE]
====
You cannot add a `subPath` parameter to an existing scheduled pod.
====
.Procedure
. To view the list of files in the volume, run the `oc rsh` command:
+
[source,terminal]
----
$ oc rsh <pod>
----
+
.Example output
[source,terminal]
----
sh-4.2$ ls /path/to/volume/subpath/mount
example_file1 example_file2 example_file3
----
. Specify the `subPath`:
+
.Example `Pod` spec with `subPath` parameter
[source,yaml]
----
apiVersion: v1
kind: Pod
metadata:
name: my-site
spec:
securityContext:
runAsNonRoot: true
seccompProfile:
type: RuntimeDefault
containers:
- name: mysql
image: mysql
volumeMounts:
- mountPath: /var/lib/mysql
name: site-data
subPath: mysql <1>
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: [ALL]
- name: php
image: php
volumeMounts:
- mountPath: /var/www/html
name: site-data
subPath: html <2>
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: [ALL]
volumes:
- name: site-data
persistentVolumeClaim:
claimName: my-site-data
----
<1> Databases are stored in the `mysql` folder.
<2> HTML content is stored in the `html` folder.