1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-06 06:46:26 +01:00
Files
openshift-docs/modules/nodes-containers-volumes-adding.adoc
2020-08-07 01:40:52 +00:00

115 lines
2.7 KiB
Plaintext

// Module included in the following assemblies:
//
// * nodes/nodes-containers-volumes.adoc
[id="nodes-containers-volumes-adding_{context}"]
= Adding volumes to a pod
You can add volumes and volume mounts to a pod.
.Procedure
To add a volume, a volume mount, or both to pod templates:
[source,terminal]
----
$ oc set volume <object_type>/<name> --add [options]
----
.Supported Options for Adding Volumes
[cols="3a*",options="header"]
|===
|Option |Description |Default
|`--name`
|Name of the volume.
|Automatically generated, if not specified.
|`-t, --type`
|Name of the volume source. Supported values: `emptyDir`, `hostPath`, `secret`,
`configmap`, `persistentVolumeClaim` or `projected`.
|`emptyDir`
|`-c, --containers`
|Select containers by name. It can also take wildcard `'*'` that matches any
character.
|`'*'`
|`-m, --mount-path`
|Mount path inside the selected containers.
|
|`--path`
|Host path. Mandatory parameter for `--type=hostPath`.
|
|`--secret-name`
|Name of the secret. Mandatory parameter for `--type=secret`.
|
|`--configmap-name`
|Name of the configmap. Mandatory parameter for `--type=configmap`.
|
|`--claim-name`
|Name of the persistent volume claim. Mandatory parameter for
`--type=persistentVolumeClaim`.
|
|`--source`
|Details of volume source as a JSON string. Recommended if the desired volume
source is not supported by `--type`.
|
|`-o, --output`
|Display the modified objects instead of updating them on the server. Supported
values: `json`, `yaml`.
|
|`--output-version`
|Output the modified objects with the given version.
|`api-version`
|===
For example:
* To add a new volume source *emptyDir* to DeploymentConfig *registry*:
+
[source,terminal]
----
$ oc set volume dc/registry --add
----
* To add volume *v1* with secret *secret1* for replication controller *r1* and mount
inside the containers at *_/data_*:
+
[source,terminal]
----
$ oc set volume rc/r1 --add --name=v1 --type=secret --secret-name='secret1' --mount-path=/data
----
* To add existing persistent volume *v1* with claim name *pvc1* to deployment
configuration *_dc.json_* on disk, mount the volume on container *c1* at
*_/data_*, and update the DeploymentConfig on the server:
+
[source,terminal]
----
$ oc set volume -f dc.json --add --name=v1 --type=persistentVolumeClaim \
--claim-name=pvc1 --mount-path=/data --containers=c1
----
* To add a volume *v1* based on Git repository
*$$https://github.com/namespace1/project1$$* with revision *5125c45f9f563* for
all replication controllers:
+
[source,terminal]
----
$ oc set volume rc --all --add --name=v1 \
--source='{"gitRepo": {
"repository": "https://github.com/namespace1/project1",
"revision": "5125c45f9f563"
}}'
----