Move the NFS docs to standalone document and leave the common parts to
be reused by documentation of other volume plugins.
| ... | ... |
@@ -1,54 +1,12 @@ |
| 1 |
-# How To Use NFS Persistent Volumes |
|
| 1 |
+# How To Use Persistent Volumes |
|
| 2 | 2 |
|
| 3 |
-The purpose of this guide is to help you understand storage provisioning with NFS by creating a WordPress blog and MySQL database. |
|
| 3 |
+The purpose of this guide is to help you understand storage provisioning by creating a WordPress blog and MySQL database. |
|
| 4 | 4 |
In this example, both the blog and database require persistent storage. |
| 5 | 5 |
|
| 6 | 6 |
This guide assumes knowledge of OpenShift fundamentals and that you have a cluster up and running. Please review steps 1 - 10 in the |
| 7 | 7 |
[sample-app](https://github.com/openshift/origin/blob/master/examples/sample-app/README.md) to run an OpenShift cluster. |
| 8 | 8 |
|
| 9 |
-## NFS Provisioning |
|
| 10 |
- |
|
| 11 |
-We'll be creating NFS exports on the local machine. The instructions below are for Fedora. The provisioning process may be slightly different based on linux distribution or the type of NFS server being used. |
|
| 12 |
- |
|
| 13 |
-Create two NFS exports, each of which will become a Persistent Volume in the cluster. |
|
| 14 |
- |
|
| 15 |
-``` |
|
| 16 |
-# the directories in this example can grow unbounded |
|
| 17 |
-# use disk partitions of specific sizes to enforce storage quotas |
|
| 18 |
-mkdir /home/data/pv0001 |
|
| 19 |
-mkdir /home/data/pv0002 |
|
| 20 |
- |
|
| 21 |
-# data written to NFS by a pod gets squashed by NFS and is owned by 'nfsnobody' |
|
| 22 |
-# we'll make our export directories owned by the same user |
|
| 23 |
-chown -R /home/data nfsnobody:nfsnobody |
|
| 24 |
- |
|
| 25 |
-# security needs to be permissive currently, but the export will soon be restricted |
|
| 26 |
-# to the same UID/GID that wrote the data |
|
| 27 |
-chmod -R 777 /home/data/ |
|
| 28 |
- |
|
| 29 |
-# Add to /etc/exports |
|
| 30 |
-/home/data/pv0001 *(rw,sync,no_root_squash) |
|
| 31 |
-/home/data/pv0002 *(rw,sync,no_root_squash) |
|
| 32 |
- |
|
| 33 |
-# Enable the new exports without bouncing the NFS service |
|
| 34 |
-exportfs -a |
|
| 35 |
- |
|
| 36 |
-``` |
|
| 37 |
- |
|
| 38 |
-## Security |
|
| 39 |
- |
|
| 40 |
-### SELinux |
|
| 41 |
- |
|
| 42 |
-By default, SELinux does not allow writing from a pod to a remote NFS server. The NFS volume mounts correctly, but is read-only. |
|
| 43 |
- |
|
| 44 |
-To enable writing in SELinux on each node: |
|
| 45 |
- |
|
| 46 |
-``` |
|
| 47 |
-# -P makes the bool persistent between reboots. |
|
| 48 |
-$ setsebool -P virt_use_nfs 1 |
|
| 49 |
-``` |
|
| 50 |
- |
|
| 51 |
-### Root access |
|
| 9 |
+## Root access |
|
| 52 | 10 |
|
| 53 | 11 |
The Wordpress Dockerhub image binds Apache to port 80 in the container, which requires root access. We can allow that |
| 54 | 12 |
in this example, but those wishing to run a more secure cluster will want to ensure their images don't require root access (e.g, bind to high number ports, don't chown or chmod dirs, etc) |
| ... | ... |
@@ -77,21 +35,16 @@ seLinuxContext: |
| 77 | 77 |
|
| 78 | 78 |
Changing the restricted security context as shown above allows the Wordpress container to bind to port 80. |
| 79 | 79 |
|
| 80 |
+## Storage Provisioning |
|
| 80 | 81 |
|
| 81 |
-## Persistent Volumes and Claims |
|
| 82 |
+OpenShift expects that storage volumes are provisioned by system administrator outside of OpenShift. As subsequent step, the system admin then tells OpenShift about these volumes by creating Persistent Volumes objects. Wearing your "system admin" hat, follow these guides to create Persistent Volumes named `pv001` and `pv002`. |
|
| 82 | 83 |
|
| 83 |
-Each NFS export becomes its own Persistent Volume in the cluster. |
|
| 84 |
+* [NFS](nfs/README.md) |
|
| 84 | 85 |
|
| 85 |
-``` |
|
| 86 |
-# Create the persistent volumes for NFS. |
|
| 87 |
-$ oc create -f examples/wordpress/pv-nfs-1.yaml |
|
| 88 |
-$ oc create -f examples/wordpress/pv-nfs-2.yaml |
|
| 89 |
-$ oc get pv |
|
| 90 |
- |
|
| 91 |
-NAME LABELS CAPACITY ACCESSMODES STATUS CLAIM REASON |
|
| 92 |
-pv0001 <none> 1073741824 RWO,RWX Available |
|
| 93 |
-pv0002 <none> 5368709120 RWO Available |
|
| 86 |
+## Persistent Volumes Claims |
|
| 87 |
+Now that the "system admin" guy has deployed some Persistent Volumes, you can continue as an application developer and actually use these volumes to store some MySQL and Wordpress data. From now on, the guide does not depend on the underlying storage technology! |
|
| 94 | 88 |
|
| 89 |
+``` |
|
| 95 | 90 |
# Create claims for storage. |
| 96 | 91 |
# The claims in this example carefully match the volumes created above. |
| 97 | 92 |
$ oc create -f examples/wordpress/pvc-wp.yaml |
| 98 | 93 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,63 @@ |
| 0 |
+# How To Use NFS Persistent Volumes |
|
| 1 |
+ |
|
| 2 |
+The purpose of this guide is to create Persistent Volumes with NFS. It is part of [OpenShift persistent storage guide](../README.md), which explains how to use these Persistent Volumes as data storage for applications. |
|
| 3 |
+ |
|
| 4 |
+## NFS Provisioning |
|
| 5 |
+ |
|
| 6 |
+We'll be creating NFS exports on the local machine. The instructions below are for Fedora. The provisioning process may be slightly different based on linux distribution or the type of NFS server being used. |
|
| 7 |
+ |
|
| 8 |
+Create two NFS exports, each of which will become a Persistent Volume in the cluster. |
|
| 9 |
+ |
|
| 10 |
+``` |
|
| 11 |
+# the directories in this example can grow unbounded |
|
| 12 |
+# use disk partitions of specific sizes to enforce storage quotas |
|
| 13 |
+mkdir /home/data/pv0001 |
|
| 14 |
+mkdir /home/data/pv0002 |
|
| 15 |
+ |
|
| 16 |
+# data written to NFS by a pod gets squashed by NFS and is owned by 'nfsnobody' |
|
| 17 |
+# we'll make our export directories owned by the same user |
|
| 18 |
+chown -R /home/data nfsnobody:nfsnobody |
|
| 19 |
+ |
|
| 20 |
+# security needs to be permissive currently, but the export will soon be restricted |
|
| 21 |
+# to the same UID/GID that wrote the data |
|
| 22 |
+chmod -R 777 /home/data/ |
|
| 23 |
+ |
|
| 24 |
+# Add to /etc/exports |
|
| 25 |
+/home/data/pv0001 *(rw,sync,no_root_squash) |
|
| 26 |
+/home/data/pv0002 *(rw,sync,no_root_squash) |
|
| 27 |
+ |
|
| 28 |
+# Enable the new exports without bouncing the NFS service |
|
| 29 |
+exportfs -a |
|
| 30 |
+ |
|
| 31 |
+``` |
|
| 32 |
+ |
|
| 33 |
+## Security |
|
| 34 |
+ |
|
| 35 |
+### SELinux |
|
| 36 |
+ |
|
| 37 |
+By default, SELinux does not allow writing from a pod to a remote NFS server. The NFS volume mounts correctly, but is read-only. |
|
| 38 |
+ |
|
| 39 |
+To enable writing in SELinux on each node: |
|
| 40 |
+ |
|
| 41 |
+``` |
|
| 42 |
+# -P makes the bool persistent between reboots. |
|
| 43 |
+$ setsebool -P virt_use_nfs 1 |
|
| 44 |
+``` |
|
| 45 |
+ |
|
| 46 |
+## NFS Persistent Volumes |
|
| 47 |
+ |
|
| 48 |
+Each NFS export becomes its own Persistent Volume in the cluster. |
|
| 49 |
+ |
|
| 50 |
+``` |
|
| 51 |
+# Create the persistent volumes for NFS. |
|
| 52 |
+$ oc create -f examples/wordpress/nfs/pv-1.yaml |
|
| 53 |
+$ oc create -f examples/wordpress/nfs/pv-2.yaml |
|
| 54 |
+$ oc get pv |
|
| 55 |
+ |
|
| 56 |
+NAME LABELS CAPACITY ACCESSMODES STATUS CLAIM REASON |
|
| 57 |
+pv0001 <none> 1073741824 RWO,RWX Available |
|
| 58 |
+pv0002 <none> 5368709120 RWO Available |
|
| 59 |
+ |
|
| 60 |
+``` |
|
| 61 |
+ |
|
| 62 |
+Now the volumes are ready to be used by applications in the cluster. |
| 0 | 63 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,14 @@ |
| 0 |
+apiVersion: v1 |
|
| 1 |
+kind: PersistentVolume |
|
| 2 |
+metadata: |
|
| 3 |
+ name: pv0001 |
|
| 4 |
+spec: |
|
| 5 |
+ capacity: |
|
| 6 |
+ storage: 1Gi |
|
| 7 |
+ accessModes: |
|
| 8 |
+ - ReadWriteOnce |
|
| 9 |
+ - ReadWriteMany |
|
| 10 |
+ persistentVolumeReclaimPolicy: Recycle |
|
| 11 |
+ nfs: |
|
| 12 |
+ server: localhost |
|
| 13 |
+ path: /home/data/pv0001 |
| 0 | 14 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,13 @@ |
| 0 |
+apiVersion: v1 |
|
| 1 |
+kind: PersistentVolume |
|
| 2 |
+metadata: |
|
| 3 |
+ name: pv0002 |
|
| 4 |
+spec: |
|
| 5 |
+ capacity: |
|
| 6 |
+ storage: 5Gi |
|
| 7 |
+ accessModes: |
|
| 8 |
+ - ReadWriteOnce |
|
| 9 |
+ persistentVolumeReclaimPolicy: Recycle |
|
| 10 |
+ nfs: |
|
| 11 |
+ server: localhost |
|
| 12 |
+ path: /home/data/pv0002 |
| 0 | 13 |
deleted file mode 100644 |
| ... | ... |
@@ -1,14 +0,0 @@ |
| 1 |
-apiVersion: v1 |
|
| 2 |
-kind: PersistentVolume |
|
| 3 |
-metadata: |
|
| 4 |
- name: pv0001 |
|
| 5 |
-spec: |
|
| 6 |
- capacity: |
|
| 7 |
- storage: 1Gi |
|
| 8 |
- accessModes: |
|
| 9 |
- - ReadWriteOnce |
|
| 10 |
- - ReadWriteMany |
|
| 11 |
- persistentVolumeReclaimPolicy: Recycle |
|
| 12 |
- nfs: |
|
| 13 |
- server: localhost |
|
| 14 |
- path: /home/data/pv0001 |
| 15 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,13 +0,0 @@ |
| 1 |
-apiVersion: v1 |
|
| 2 |
-kind: PersistentVolume |
|
| 3 |
-metadata: |
|
| 4 |
- name: pv0002 |
|
| 5 |
-spec: |
|
| 6 |
- capacity: |
|
| 7 |
- storage: 5Gi |
|
| 8 |
- accessModes: |
|
| 9 |
- - ReadWriteOnce |
|
| 10 |
- persistentVolumeReclaimPolicy: Recycle |
|
| 11 |
- nfs: |
|
| 12 |
- server: localhost |
|
| 13 |
- path: /home/data/pv0002 |