The Kubernetes Operator in this project is in Alpha version. Use at your own risk
NFS Operator adds three important features for a NFS in Kubernetes. It allows setting NFS export ownership/permissions, enables PVC autoexpansion and reduces the number of manual resource definitions. It is based on Rook NFS v1.6 and Ansible Operator SDK. Thus, the new features are in addition to those in Rook NFS. The extra functions it adds on top of Rook NFS are:
- It is able to set ownership and permissions for the (NFS) Server export
- It is able to autoexpand/adjust the value of (NFS) Server PVC storage size
- It automatically creates a StorageClass with a (NFS) Server
There are some restrictions compared to Rook NFS:
- Only one export/PVC per (NFS) Server
Prerequisites are the same as Rook NFS. Therefore, Rook NFS v1.6 must be installed.
Follow the next steps to install the NFS Operator as well as Rook NFS v1.6 operator. Notice that CRs should be installed in the namesapace rook-nfs. It is the default namespace for (NFS) Servers in Rook NFS Operator installation:
# install rook nfs operator v1.6 make deploy-rook # install this operator make deploy # add a nfs server cr/object kubectl -n rook-nfs apply -f config/samples/nfs_v1alpha1_server.yaml # follow/check nfs operator logs kubectl -n nfs-operator-system logs -l control-plane=controller-manager -c manager -f # follow sample nfs server cr/object status kubectl -n rook-nfs get Server server-sample -o yaml -w
Follow the next steps to uninstall it.
# delete the nfs server cr/object # CAUTION with data loss kubectl -n rook-nfs delete -f config/samples/nfs_v1alpha1_server.yaml # uninstall this operator make undeploy # uninstall rook nfs operator v1.6 make undeploy-rook
For a CRD sample, see: sample
To set export folder ownership, set server_export_userid and server_export_groupid. For export folder permissions, set server_export_permissions. For instance:
spec: # Ownership/permissions ## Set export folder userid to 48 server_export_userid: 48 ## Set export folder groupid to 0 server_export_groupid: 0 ## Set export folder permissions to 775 server_export_permissions: 755
When autoexpansion is enabled (server_pvc_autoexpansion), if storage available is less than 20% or below server_pvc_autoexpansion_gib, PVC storage size is auto incremented according to server_pvc_autoexpansion_gib. However, it will not be increment beyond server_pvc_autoexpansion_cap_gib (see related function). The following is a config example for it:
spec: # Autoexpansion ## Enable autoexpansion server_pvc_autoexpansion: true ## Every time autoexpansion is required, increment 5 GiB server_pvc_autoexpansion_gib: 5 ### But no more than 250 GiB server_pvc_autoexpansion_cap_gib: 250
- Not all types of storage are compatible. For instance, hostpath is not.
- Kubernetes cluster and (NFS) Server PVC must support expansion of volumes
- In older K8s versions, (NFS) Server pod may be restart when autoexpansion is enabled if Kubernetes feature gate ExpandInUsePersistentVolumes is false. See: Kubernetes Feature Gates
A class is automatically created with suffix -nfs-sc. If a CR is created with the name: server-sample, a storage class named server-sample-nfs-sc is also created and showed in the CR status.
For advanced configuration options available for CR spec, take a look at the options