You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Brian Salcedo 8f9a9c06b7 back one level 4 months ago
deploy add deployment manifests 4 months ago
.gitignore initial commit 4 months ago
Dockerfile initial commit 4 months ago
Makefile initial commit 4 months ago back one level 4 months ago
go.mod initial commit 4 months ago
go.sum initial commit 4 months ago
nfs-client-provisioner.go add README 4 months ago

Kubernetes NFS-Client Provisioner

Notes: Because external-storage is now deprecated, this version is modified to work with sig-storage-lib-external-provisioner. The parameter to delete or archive a PersistentVolume upon object deletion was removed. PersistentVolumes are archived upon object deletion.

nfs-client is an automatic provisioner that use your existing and already configured NFS server to support dynamic provisioning of Kubernetes Persistent Volumes via Persistent Volume Claims. Persistent volumes are provisioned as ${namespace}-${pvcName}-${pvName}.

How to deploy nfs-client to your cluster.

To note again, you must already have an NFS Server.

Step 1: Get connection information for your NFS server. Make sure your NFS server is accessible from your Kubernetes cluster and get the information you need to connect to it. At a minimum you will need its hostname.

Step 2: Get the NFS-Client Provisioner files. To setup the provisioner you will download a set of YAML files, edit them to add your NFS server’s connection information and then apply each with the kubectl / oc command.

Get all of the files in the deploy directory of this repository.

Step 3: Setup authorization. If your cluster has RBAC enabled or you are running OpenShift you must authorize the provisioner. If you are in a namespace/project other than “default” edit deploy/rbac.yaml.


# Set the subject of the RBAC objects to the current namespace where the provisioner is being deployed
$ NS=$(kubectl config get-contexts|grep -e "^\*" |awk '{print $5}')
$ NAMESPACE=${NS:-default}
$ sed -i'' "s/namespace:.*/namespace: $NAMESPACE/g" ./deploy/rbac.yaml ./deploy/deployment.yaml
$ kubectl create -f deploy/rbac.yaml


On some installations of OpenShift the default admin user does not have cluster-admin permissions. If these commands fail refer to the OpenShift documentation for User and Role Management or contact your OpenShift provider to help you grant the right permissions to your admin user.

# Set the subject of the RBAC objects to the current namespace where the provisioner is being deployed
$ NAMESPACE=`oc project -q`
$ sed -i'' "s/namespace:.*/namespace: $NAMESPACE/g" ./deploy/rbac.yaml
$ oc create -f deploy/rbac.yaml
$ oadm policy add-scc-to-user hostmount-anyuid system:serviceaccount:$NAMESPACE:nfs-client-provisioner

Step 4: Configure the NFS-Client provisioner

Next you must edit the provisioner’s deployment file to add connection information for your NFS server. Edit deploy/deployment.yaml and replace the two occurences of with your server’s hostname.

kind: Deployment
apiVersion: apps/v1
  name: nfs-client-provisioner
  replicas: 1
      app: nfs-client-provisioner
    type: Recreate
        app: nfs-client-provisioner
      serviceAccountName: nfs-client-provisioner
        - name: nfs-client-provisioner
          image: mantra/nfs-client-provisioner:latest
            - name: nfs-client-root
              mountPath: /persistentvolumes
            - name: PROVISIONER_NAME
              value: nfs-storage
            - name: NFS_SERVER
              value: <YOUR NFS SERVER HOSTNAME>
            - name: NFS_PATH
              value: /var/nfs
        - name: nfs-client-root
            server: <YOUR NFS SERVER HOSTNAME>
            path: /var/nfs

This is deploy/class.yaml which defines the NFS-Client’s Kubernetes Storage Class:

kind: StorageClass
  name: managed-nfs-storage
provisioner: nfs-storage # or choose another name, must match deployment's env PROVISIONER_NAME'

Step 5: Deploying your own PersistentVolumeClaims. To deploy your own PVC, make sure that you have the correct storage-class as indicated by your deploy/class.yaml file.

For example:

kind: PersistentVolumeClaim
apiVersion: v1
  name: test-claim
  annotations: "managed-nfs-storage"
    - ReadWriteMany
      storage: 1Mi