OpenShift PersistentVolume Operations: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 61: Line 61:


<pre>
<pre>
apiVersion: v1
apiVersion: "v1"
kind: PersistentVolumeClaim
kind: "PersistentVolumeClaim"
metadata:
metadata:
   name: jenkins-data
   name: "jenkins-data"
spec:
spec:
  capacity:
    storage: 10Gi
   accessModes:
   accessModes:
  - ReadWriteOnce
    - "ReadWriteOnce"
  resources:
    requests:
      storage: "2Gi"
</pre>
</pre>



Revision as of 23:56, 1 November 2017

External

Internal

Delete a Persistent Volume

oc delete pv <persistent-volume-name>
oc delete pv metrics-volume

Create a Persistent Volume

NFS

Provision the Underlying Storage

Create the Persistent Volume Definition File

Create a "pv.yaml" file with the following content:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: metrics-volume
spec:
  capacity:
    storage: 10Gi
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  nfs:
    path: /support-nfs-storage/metrics
    server: support.local

Make sure the "support.local" server is accessible from any node that will use the volume, and the /support-nfs-storage/metrics is exported and has sufficient permissions.

Create the Volume

oc create -f pv.yaml

Once created, it will shows as:

oc get pv

NAME              CAPACITY   ACCESSMODES   RECLAIMPOLICY   STATUS      CLAIM                    REASON    AGE
...
metrics-volume    10Gi       RWO           Retain          Available                                      25s
...

Note that the volume, even if available, it won't be used until a matching persistent volume claim is declared.

Create a Persistent Volume Claim

Create a definition of the persistent volume claim, a "pvc.yaml" file with the following content

apiVersion: "v1"
kind: "PersistentVolumeClaim"
metadata:
  name: "jenkins-data"
spec:
  accessModes:
    - "ReadWriteOnce"
  resources:
    requests:
      storage: "2Gi"

Create the persistent volume claim:

oc create -f pvc.yaml

Associate a Persistent Volume Claim with a Deployment Configuration