1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-06 06:46:26 +01:00
Files
openshift-docs/modules/persistent-storage-hostpath-static-provisioning.adoc
2023-10-30 10:13:25 -04:00

68 lines
1.8 KiB
Plaintext

// Module included in the following assemblies:
//
// * storage/persistent_storage/persistent-storage-hostpath.adoc
:_mod-docs-content-type: PROCEDURE
[id="hostpath-static-provisioning_{context}"]
= Statically provisioning hostPath volumes
A pod that uses a hostPath volume must be referenced by manual (static) provisioning.
.Procedure
. Define the persistent volume (PV). Create a file, `pv.yaml`, with the `PersistentVolume` object definition:
+
[source,yaml]
----
apiVersion: v1
kind: PersistentVolume
metadata:
name: task-pv-volume <1>
labels:
type: local
spec:
storageClassName: manual <2>
capacity:
storage: 5Gi
accessModes:
- ReadWriteOnce <3>
persistentVolumeReclaimPolicy: Retain
hostPath:
path: "/mnt/data" <4>
----
<1> The name of the volume. This name is how it is identified by persistent volume claims or pods.
<2> Used to bind persistent volume claim requests to this persistent volume.
<3> The volume can be mounted as `read-write` by a single node.
<4> The configuration file specifies that the volume is at `/mnt/data` on the cluster's node. Do not mount to the container root, `/`, or any path that is the same in the host and the container. This can corrupt your host system. It is safe to mount the host by using `/host`.
. Create the PV from the file:
+
[source,terminal]
----
$ oc create -f pv.yaml
----
. Define the persistent volume claim (PVC). Create a file, `pvc.yaml`, with the `PersistentVolumeClaim` object definition:
+
[source,yaml]
----
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: task-pvc-volume
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
storageClassName: manual
----
. Create the PVC from the file:
+
[source,terminal]
----
$ oc create -f pvc.yaml
----