Openshift: NFS-Client Provisioner

This is a quick start guide on how to deploy an NFS Client Provisioner in your openshift cluster. If you would like a more detailed info/walkthrough, please visit https://github.com/kubernetes-incubator/external-storage/tree/master/nfs-client

PS: This assumes you already have an NFS Server.

### Collect your NFS server info.
# NFS_SERVER: 192.168.3.7
# NFS_PATH: /var/nfs

### Clone the repo
$ git clone https://github.com/kubernetes-incubator/external-storage.git
$ cd external-storage/nfs-client/deploy

### Setup authorization
$ oc project default
$ oc create -f auth/openshift-clusterrole.yaml -f auth/serviceaccount.yaml
serviceaccount "nfs-client-provisioner" created
clusterrole "nfs-client-provisioner-runner" created
$ oc adm policy add-scc-to-user hostmount-anyuid system:serviceaccount:default:nfs-client-provisioner
$ oc adm policy add-cluster-role-to-user nfs-client-provisioner-runner system:serviceaccount:default:nfs-client-provisioner

Edit deployment.yaml with your variables. Change NFS_SERVER and NFS_PATH with your settings.

You may also want to change the PROVISIONER_NAME from fuseim.pri/ifs to something more descriptive like nfs-storage, but if you do, remember to also change the PROVISIONER_NAME in the storage class definition, class.yaml

# Edit the section below from deployment.yaml with your variables.

  env:
    - name: PROVISIONER_NAME
      value: fuseim.pri/ifs
    - name: NFS_SERVER
      value: <YOUR NFS SERVER HOSTNAME>
    - name: NFS_PATH
      value: /var/nfs
volumes:
- name: nfs-client-root
  nfs:
    server: <YOUR NFS SERVER HOSTNAME>
    path: /var/nfs

and remember to edit PROVISIONER_NAME in class.yaml if you changed PROVISIONER_NAME in the deployment.yaml file

Since I wanted to make this the default, I added storageclass.kubernetes.io/is-default-class: "true" to class.yaml and archiveOnDelete: "true" to archive when the PV gets deleted. So now my class.yaml file looks to something like this:

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: nfs-storage
  annotations:
    storageclass.kubernetes.io/is-default-class: "true"
provisioner: example.com/nfs # or choose another name, must match deployment's env PROVISIONER_NAME'
parameters:
  archiveOnDelete: "true" # When set to "false" your PVs will not be archived
                           # by the provisioner upon deletion of the PVC.

And now we're ready to deploy it:

### Configure the NFS-Client provisioner
$ oc create -f deployment.yaml -f class.yaml

### Finally, test your environment!
$ oc create -f test-claim.yaml -f test-pod.yaml

# Now check your NFS Server for the file SUCCESS.

$ oc delete -f test-pod.yaml -f test-claim.yaml

Now you can deploy your own PersistentVolumeClaims and your PV should get created automatically!!!

Comments:

For comments, please visit https://plus.google.com/u/0/+JefferyBagirimvano/posts/hUM2rfUyCLj