NFS Operator with Extra Functionality on Top of Rook NFS

The Kubernetes Operator in this project is in Alpha version. Use at your own risk

  1. It is able to set ownership and permissions for the (NFS) Server export
  2. It is able to autoexpand/adjust the value of (NFS) Server PVC storage size
  3. 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

Prerequisites are the same as Rook NFS. Therefore, Rook NFS v1.6 must be installed.

Install

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

Uninstall

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

Configuration Options

For a CRD sample, see: sample

Ownership/Permissions

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

Autoexpansion

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

Please, you should take into consideration the following:

  • 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

StorageClass

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.

Advanced Options

For advanced configuration options available for CR spec, take a look at the options

Want to contribute?

18