mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-05 12:46:18 +01:00
123 lines
3.5 KiB
Plaintext
123 lines
3.5 KiB
Plaintext
:_mod-docs-content-type: REFERENCE
|
|
[id="odo-storage_{context}"]
|
|
= odo storage
|
|
|
|
|
|
`odo` lets users manage storage volumes that are attached to the components. A storage volume can be either an ephemeral volume using an `emptyDir` Kubernetes volume, or a link:https://kubernetes.io/docs/concepts/storage/volumes/#persistentvolumeclaim[Persistent Volume Claim] (PVC). A PVC allows users to claim a persistent volume (such as a GCE PersistentDisk or an iSCSI volume) without understanding the details of the particular cloud environment. The persistent storage volume can be used to persist data across restarts and rebuilds of the component.
|
|
|
|
== Adding a storage volume
|
|
|
|
To add a storage volume to the cluster, run the command:
|
|
|
|
[source,terminal]
|
|
----
|
|
$ odo storage create
|
|
----
|
|
|
|
.Example output
|
|
[source,terminal]
|
|
----
|
|
$ odo storage create store --path /data --size 1Gi
|
|
✓ Added storage store to nodejs-project-ufyy
|
|
|
|
$ odo storage create tempdir --path /tmp --size 2Gi --ephemeral
|
|
✓ Added storage tempdir to nodejs-project-ufyy
|
|
|
|
Please use `odo push` command to make the storage accessible to the component
|
|
----
|
|
|
|
|
|
In the above example, the first storage volume has been mounted to the `/data` path and has a size of `1Gi`, and the second volume has been mounted to `/tmp` and is ephemeral.
|
|
|
|
== Listing the storage volumes
|
|
|
|
To check the storage volumes currently used by the component, run the command:
|
|
|
|
[source,terminal]
|
|
----
|
|
$ odo storage list
|
|
----
|
|
|
|
.Example output
|
|
[source,terminal]
|
|
----
|
|
$ odo storage list
|
|
The component 'nodejs-project-ufyy' has the following storage attached:
|
|
NAME SIZE PATH STATE
|
|
store 1Gi /data Not Pushed
|
|
tempdir 2Gi /tmp Not Pushed
|
|
----
|
|
|
|
== Deleting a storage volume
|
|
|
|
To delete a storage volume, run the command:
|
|
|
|
[source,terminal]
|
|
----
|
|
$ odo storage delete
|
|
----
|
|
|
|
.Example output
|
|
[source,terminal]
|
|
----
|
|
$ odo storage delete store -f
|
|
Deleted storage store from nodejs-project-ufyy
|
|
|
|
Please use `odo push` command to delete the storage from the cluster
|
|
----
|
|
|
|
In the above example, using the `-f` flag force deletes the storage without asking user permission.
|
|
|
|
== Adding storage to specific container
|
|
|
|
If your devfile has multiple containers, you can specify which container you want the storage to attach to, using the `--container` flag in the `odo storage create` command.
|
|
|
|
The following example is an excerpt from a devfile with multiple containers :
|
|
|
|
[source,yaml]
|
|
----
|
|
components:
|
|
- name: nodejs1
|
|
container:
|
|
image: registry.access.redhat.com/ubi8/nodejs-12:1-36
|
|
memoryLimit: 1024Mi
|
|
endpoints:
|
|
- name: "3000-tcp"
|
|
targetPort: 3000
|
|
mountSources: true
|
|
- name: nodejs2
|
|
container:
|
|
image: registry.access.redhat.com/ubi8/nodejs-12:1-36
|
|
memoryLimit: 1024Mi
|
|
----
|
|
|
|
In the example, there are two containers,`nodejs1` and `nodejs2`. To attach storage to the `nodejs2` container, use the following command:
|
|
|
|
[source,terminal]
|
|
----
|
|
$ odo storage create --container
|
|
----
|
|
|
|
.Example output
|
|
[source,terminal]
|
|
----
|
|
$ odo storage create store --path /data --size 1Gi --container nodejs2
|
|
✓ Added storage store to nodejs-testing-xnfg
|
|
|
|
Please use `odo push` command to make the storage accessible to the component
|
|
----
|
|
|
|
You can list the storage resources, using the `odo storage list` command:
|
|
|
|
[source,terminal]
|
|
----
|
|
$ odo storage list
|
|
----
|
|
|
|
.Example output
|
|
[source,terminal]
|
|
----
|
|
The component 'nodejs-testing-xnfg' has the following storage attached:
|
|
NAME SIZE PATH CONTAINER STATE
|
|
store 1Gi /data nodejs2 Not Pushed
|
|
---- |