https://github.com/kubesphere/nfs-pv-static-provisioner
A NFS persistent volume static provisioner
https://github.com/kubesphere/nfs-pv-static-provisioner
nfs provisioner volume
Last synced: about 1 month ago
JSON representation
A NFS persistent volume static provisioner
- Host: GitHub
- URL: https://github.com/kubesphere/nfs-pv-static-provisioner
- Owner: kubesphere
- Created: 2024-09-09T02:35:28.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-11-26T09:50:15.000Z (6 months ago)
- Last Synced: 2025-04-01T19:15:48.634Z (about 2 months ago)
- Topics: nfs, provisioner, volume
- Language: Go
- Homepage: https://github.com/kubesphere/nfs-pv-static-provisioner
- Size: 52.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# nfs-pv-static-provisioner
A NFS persistent volume static provisioner, which allows you to quickly bind an existing NFS volume to PVC.**This provisioner will NOT provision volumes on NFS server when you create a PVC.** If you are looking for a dynamic provisioner of NFS, please consider other projects, like [this](https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner).
## Description
The provisioner listens PVC CREATE and UPDATE events, when the PVC has demanded annotations, the provisioner will create/update a NFS PV and bind it with the PVC automatically.| Annotation | Required | Default Value | Explanation | Example Values |
|--------------------------------------------|----------|----------------------|--------------------------------------------------------------|-----------------------------------------|
| storage.kubesphere.io/nfs-static-provision | Y | "false" | must set to "true" in order to use this provisioner | "true" |
| storage.kubesphere.io/nfs-server | Y | "" | nfs server hostname or IP address (PV.spec.nfs.server) | "example.nfs.server.com", "192.168.0.5" |
| storage.kubesphere.io/nfs-path | Y | "" | nfs volume absolute path (PV.spec.nfs.path) | "/exports/volume1" |
| storage.kubesphere.io/nfs-readonly | N | "false" | whether the volume is read-only (PV.spec.nfs.readOnly) | "false", "true" |
| storage.kubesphere.io/reclaim-policy* | N | "Delete" | reclaim policy of PV (PV.spec.persistentVolumeReclaimPolicy) | "Delete", "Retain" |
| storage.kubesphere.io/mount-options | N | "" | mount options of PV (PV.spec.mountOptions) | `"[\"nfsvers=3\",\"nolock\",\"hard\"]"` |
| storage.kubesphere.io/pv-name | N | "pvc-${random uuid}" | PV name | "nfs-pv-1" |- *When reclaim policy is "Delete", the PV will be deleted when the PVC is deleted. However, this only affects the PV resource in k8s cluster, the real backend volume on NFS server still exists.
## Usecase
- As a tenant(e.g. admin of a namespace) on kubernetes cluster, you don't have permissions to create PV resources (as PV is cluster-level resource), but you own an external NFS server and want to use the existing volumes via PVC.## Deploy
### Deploy
To deploy the controller:
```sh
make deploy
```### Test
Create a PVC and check if it can be automatically bound. Take [this](./config/samples/pvc.yaml) for example.### Undeploy
To uninstall the controller:
```sh
make undeploy
```## Events
PV create/update events will be issued targeting the PVC object.e.g.
```sh
$ kubectl describe pvc pvc-nfs
Name: pvc-nfs
Namespace: default
StorageClass:
Status: Pending
Volume: pvc-f6c5a1c9-cbfc-4994-8079-956024db8e52
Labels:
Annotations: storage.kubesphere.io/nfs-path: aaa
storage.kubesphere.io/nfs-server: test.nfs.server.com
storage.kubesphere.io/nfs-static-provision: true
Finalizers: [kubernetes.io/pvc-protection]
Capacity: 0
Access Modes:
VolumeMode: Filesystem
Used By:
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal FailedBinding 9s persistentvolume-controller no persistent volumes available for this claim and no storage class is set
Normal VolumeNameUpdated 9s nfs-pv-static-provisioner volumeName updated successfully
Warning CreatePVFailed 4s (x11 over 9s) nfs-pv-static-provisioner failed to create pv pvc-f6c5a1c9-cbfc-4994-8079-956024db8e52, error: PersistentVolume "pvc-f6c5a1c9-cbfc-4994-8079-956024db8e52" is invalid: spec.nfs.path: Invalid value: "aaa": must be an absolute path
``````sh
$ kubectl describe pvc pvc-nfs
Name: pvc-nfs
Namespace: default
StorageClass:
Status: Bound
Volume: pvc-f6f9747e-3479-4664-a32f-268b2c62f0bd
Labels:
Annotations: pv.kubernetes.io/bind-completed: yes
storage.kubesphere.io/nfs-path: /a/b
storage.kubesphere.io/nfs-server: test.nfs.server.com
storage.kubesphere.io/nfs-static-provision: true
Finalizers: [kubernetes.io/pvc-protection]
Capacity: 1Gi
Access Modes: RWX
VolumeMode: Filesystem
Used By:
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal FailedBinding 12s persistentvolume-controller no persistent volumes available for this claim and no storage class is set
Normal VolumeNameUpdated 12s nfs-pv-static-provisioner volumeName updated successfully
Normal PVCreated 12s nfs-pv-static-provisioner pv pvc-f6f9747e-3479-4664-a32f-268b2c62f0bd created successfully
```