Skip to content

Commit

Permalink
feat(provisioner): add mount options to NFS PV (#8)
Browse files Browse the repository at this point in the history
exposed 111 port and updated the provisioner to add Options passed
from the StorageClass to the NFS PV spec.

Signed-off-by: kmova <[email protected]>
  • Loading branch information
kmova authored Feb 10, 2021
1 parent a653ae9 commit 627e0ed
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ nohup.out
coverage.txt
profile.out
.DS_Store
buildscripts/provisioner-nfs/provisioner-nfs
9 changes: 9 additions & 0 deletions pkg/kubernetes/api/core/v1/persistentvolume/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,15 @@ func (b *Builder) WithNFS(server, path string, readOnly bool) *Builder {
return b
}

// WithMountOptions sets the MountOptions field in PV with provided arguments
func (b *Builder) WithMountOptions(mountOptions []string) *Builder {
if len(mountOptions) == 0 {
return b
}
b.pv.object.Spec.MountOptions = mountOptions
return b
}

// Build returns the PV API instance
func (b *Builder) Build() (*corev1.PersistentVolume, error) {
if len(b.errs) > 0 {
Expand Down
18 changes: 16 additions & 2 deletions provisioner/helper_kernel_nfs_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ const (

// NFSPVFinalizer represents finalizer string used by NFSPV
NFSPVFinalizer = "nfs.openebs.io/finalizer"

//NFS Server Port
NFSServerPort = 2049

//RPC Bind Port
RPCBindPort = 111
)

var (
Expand Down Expand Up @@ -210,7 +216,11 @@ func (p *Provisioner) createDeployment(nfsServerOpts *KernelNFSServerOptions) er
[]corev1.ContainerPort{
corev1.ContainerPort{
Name: "nfs",
ContainerPort: 2049,
ContainerPort: NFSServerPort,
},
corev1.ContainerPort{
Name: "rpcbind",
ContainerPort: RPCBindPort,
},
},
).
Expand Down Expand Up @@ -327,7 +337,11 @@ func (p *Provisioner) createService(nfsServerOpts *KernelNFSServerOptions) error
[]corev1.ServicePort{
corev1.ServicePort{
Name: "nfs",
Port: 2049,
Port: NFSServerPort,
},
corev1.ServicePort{
Name: "rpcbind",
Port: RPCBindPort,
},
},
).
Expand Down
1 change: 1 addition & 0 deletions provisioner/provisioner_kernel_nfs_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func (p *Provisioner) ProvisionKernalNFSServer(opts pvController.ProvisionOption
WithReclaimPolicy(*opts.StorageClass.ReclaimPolicy).
WithAccessModes(pvc.Spec.AccessModes).
WithCapacityQty(pvc.Spec.Resources.Requests[v1.ResourceName(v1.ResourceStorage)]).
WithMountOptions(opts.StorageClass.MountOptions).
WithNFS(nfsService, "/", false)

//Build the pvObject
Expand Down

0 comments on commit 627e0ed

Please sign in to comment.