1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 12:46:18 +01:00
Files
openshift-docs/modules/persistent-storage-hostpath-static-provisioning.adoc
2019-11-07 18:46:17 +00:00

65 lines
1.5 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Module included in the following assemblies:
//
// * storage/persistent-storage/persistent-storage-hostpath.adoc
[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 PersistentVolumeClaims or Pods.
<2> Used to bind PersistentVolumeClaim requests to this PersistentVolume.
<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 clusters node.
. Create the PV from the file:
+
----
$ 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:
+
----
$ oc create -f pvc.yaml
----