This guide gives a simple example on how to use this driver with filestore instances that have been pre-provisioned by an administrator.
If you have not already pre-provisioned a filestore instance on GCP you can do that now.
- Create a filestore instance following the instructions here
- Create example Storage Class
kubectl apply -f ./examples/kubernetes/sc-latebind.yaml
This storageclass will not bind a PVC to a PV until there is a pod created using
the PVC. If you wish to bind the PV and PVC immediately on PVC creation, change
volumeBindingMode
to Immediate
.
- Create example Persistent Volume
Note: The volumeHandle
should be updated
based on the zone, Filestore instance name, and share name created. storage
value
should be generated based on the size of the underlying instance. VolumeAttributes ip
must
point to the filestore instance IP, and volume
must point to the fileshare name.
kubectl apply -f ./examples/kubernetes/pre-provision/preprov-pv.yaml
- Create example PVC and Pod
$ kubectl apply -f ./examples/kubernetes/pre-provision/preprov-pod-demo.yaml
- Verify PV is created and bound to PVC
$ kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
preprov-pvc Bound my-pre-pv 1Ti RWX csi-filestore 76s
- Verify pod is created and in
RUNNING
state (it may take a few minutes to get to running state)
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
web-server 1/1 Running 0 119s
- Verify contents of the mounted volume
kubectl exec web-server -- ls /usr/share/nginx/html
lost+found
- The PV was created with a "Retain" persistentVolumeReclaimPolicy. This means the deletion of PVC will not trigger the deletion of PV and the underlying storage.
$ kubectl delete pod web-server
pod "web-server" deleted
$ kubectl delete pvc preprov-pvc
persistentvolumeclaim "preprov-pvc" deleted
- Check the state of the PV after the Pod and PVC are successfully deleted. It should report a
Released
state
$ kubectl get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
my-pre-pv 1Ti RWX Retain Released default/preprov-pvc 2m28s
- Verify the underlying filestore instance exists
$ gcloud filestore instances list --project=<your-gcp-project> --zone=<filestore-location>
For regional Filestore instances (e.g enterprise tier), replace "--zone" with "--region"
- To reuse the PV again edit the PV and delete the claimRef.
$ kubectl patch pv my-pre-pv --type json -p '[{"op": "remove", "path": "/spec/claimRef"}]'
persistentvolume/my-pre-pv patched
- PV will now report an
Available
status and ready to be bound again to a PVC as indicated in steps above.
$ kubectl get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
my-pre-pv 1Ti RWX Retain Available 19m
- If the PV is no longer needed it can be deleted too. The underlying filestore instance will not be deleted.
$ kubectl delete pv my-pre-pv
persistentvolume "my-pre-pv" deleted
- Verify Filestore instance still exists as shown in step 7 above