Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nfs: add support for secTypes parameter in StorageClass #3434

Merged
merged 1 commit into from
May 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion e2e/nfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,24 @@ var _ = Describe("nfs", func() {
})

By("create a storageclass with pool and a PVC then bind it to an app", func() {
err := createNFSStorageClass(f.ClientSet, f, false, nil)
err := createNFSStorageClass(f.ClientSet, f, true, nil)
if err != nil {
framework.Failf("failed to create NFS storageclass: %v", err)
}
err = validatePVCAndAppBinding(pvcPath, appPath, f)
if err != nil {
framework.Failf("failed to validate NFS pvc and application binding: %v", err)
}
err = deleteResource(nfsExamplePath + "storageclass.yaml")
if err != nil {
framework.Failf("failed to delete NFS storageclass: %v", err)
}
})

By("create a storageclass with sys,krb5i security and a PVC then bind it to an app", func() {
err := createNFSStorageClass(f.ClientSet, f, false, map[string]string{
"secTypes": "sys,krb5i",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add validation to ensure the secTypes are set in the exported path?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is difficult... Ceph Mgr generates a configuration snippet in json-like format for NFS-Ganesha, and stores it directly in some internal RADOS pool. We would need to fetch that configuration snippet and parse the NFS-Ganesha options. Possible, but difficult.

In the (hopefully) near future, we should be able to do a mount with Kerberos. Once that functionality lands, exporting with Kerberos will be automatically tested.

})
if err != nil {
framework.Failf("failed to create NFS storageclass: %v", err)
}
Expand Down
6 changes: 6 additions & 0 deletions examples/nfs/storageclass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,11 @@ parameters:
# If omitted, defaults to "csi-vol-".
volumeNamePrefix: nfs-export-

# (optional) Security requirements for the NFS-export. Valid flavours
# include: none, sys, krb5, krb5i and krb5p. The <sectype-list> is a comma
# delimited string, for example "sys,krb5".
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to mention the supported ceph version for this option

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I can include that now the changes are included in Ceph.

# This option is available with Ceph v17.2.6 and newer.
# secTypes: <sectype-list>

reclaimPolicy: Delete
allowVolumeExpansion: true
14 changes: 12 additions & 2 deletions internal/nfs/controller/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ func (nv *NFSVolume) CreateExport(backend *csi.Volume) error {
fs := backend.VolumeContext["fsName"]
nfsCluster := backend.VolumeContext["nfsCluster"]
path := backend.VolumeContext["subvolumePath"]
secTypes := backend.VolumeContext["secTypes"]

err := nv.setNFSCluster(nfsCluster)
if err != nil {
Expand All @@ -142,12 +143,21 @@ func (nv *NFSVolume) CreateExport(backend *csi.Volume) error {
return fmt.Errorf("failed to get NFSAdmin: %w", err)
}

_, err = nfsa.CreateCephFSExport(nfs.CephFSExportSpec{
export := nfs.CephFSExportSpec{
FileSystemName: fs,
ClusterID: nfsCluster,
PseudoPath: nv.GetExportPath(),
Path: path,
})
}

if secTypes != "" {
export.SecType = []nfs.SecType{}
for _, secType := range strings.Split(secTypes, ",") {
export.SecType = append(export.SecType, nfs.SecType(secType))
}
}

_, err = nfsa.CreateCephFSExport(export)
switch {
case err == nil:
return nil
Expand Down