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 clients in the StorageClass #3895

Merged
merged 1 commit into from Jul 6, 2023

Conversation

spuiuk
Copy link
Contributor

@spuiuk spuiuk commented Jun 9, 2023

The clients parameter in the storage class is used to limit access to the export to the set of hostnames, networks or ip addresses specified.

Describe what this PR does

This PR addresses the requirements in Issue #3852 allowing users to specify hostname, networks and ip addresses allowed to access the NFS volume.

Related issues

Fixes: #3852

Future concerns

Users may want to add different access_types for different clients. However this is not supported by go-ceph at the moment. We may have to review this change once we can set this up with go-ceph.

@mergify mergify bot added the component/nfs Issues related to NFS label Jun 9, 2023
@spuiuk
Copy link
Contributor Author

spuiuk commented Jun 9, 2023

/test ci/centos/mini-e2e-helm/k8s-1.27

@spuiuk
Copy link
Contributor Author

spuiuk commented Jun 12, 2023

From my own testing.

Storage-Class:

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: rook-nfs
provisioner: rook-ceph.nfs.csi.ceph.com
parameters:
  nfsCluster: my-nfs
  server: rook-ceph-nfs-my-nfs-a
  clusterID: rook-ceph 
  fsName: myfs
  pool: myfs-replicated
  csi.storage.k8s.io/provisioner-secret-name: rook-csi-cephfs-provisioner
  csi.storage.k8s.io/provisioner-secret-namespace: rook-ceph 
  csi.storage.k8s.io/controller-expand-secret-name: rook-csi-cephfs-provisioner
  csi.storage.k8s.io/controller-expand-secret-namespace: rook-ceph 
  csi.storage.k8s.io/node-stage-secret-name: rook-csi-cephfs-node
  csi.storage.k8s.io/node-stage-secret-namespace: rook-ceph 
  secTypes: sys,krb5
  clients: 192.168.23.1/24,192.168.1.1/24
reclaimPolicy: Delete
allowVolumeExpansion: true
mountOptions:

Test PVC created from

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: nfs-test
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
  storageClassName: rook-nfs

The resulting exports block created by the CSI driver.

EXPORT {
    FSAL {
        name = "CEPH";
        user_id = "nfs.my-nfs.1";
        filesystem = "myfs";
        secret_access_key = "AQAu2IZkVBzGLRAABhHO4zuxlhYxXNChWrdUDA==";
    }
    CLIENT {
        clients = 192.168.23.1/24,  192.168.1.1/24;
        access_type = "rw";
        squash = "none";
    }
    export_id = 1;
    path = "/volumes/csi/csi-vol-a79fb1a5-93d8-40cb-a18d-be4dc5f7c0ea/f6dcc67d-5276-4bf2-8c25-71d29bf4a044";
    pseudo = "/0001-0009-rook-ceph-0000000000000001-a79fb1a5-93d8-40cb-a18d-be4dc5f7c0ea";
    access_type = "none";
    squash = "none";
    attr_expiration_time = 0;
    security_label = true;
    protocols = 4;
    transports = "TCP";
    SecType = "sys", "krb5";
}

@Rakshith-R
Copy link
Contributor

/test ci/centos/mini-e2e-helm/k8s-1.27

@Rakshith-R
Copy link
Contributor

/test ci/centos/mini-e2e/k8s-1.27

Copy link
Contributor

@Rakshith-R Rakshith-R left a comment

Choose a reason for hiding this comment

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

A small nit, the pr looks good to me.
I'll let niels do review since he's more familiar with nfs exports.
(helm e2e doesn't test nfs.)

Comment on lines 54 to 55
# (optional) List of IP addresses, hostnames or IPv4 network addresses that
# that these export permissions apply to. The <client-list> is a comma
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's word it similar to the commit message and make it clear that only these clients will be able to access
the export ?

@Rakshith-R Rakshith-R requested a review from nixpanic June 12, 2023 10:37
e2e/nfs.go Outdated
if err != nil {
framework.Failf("failed to create NFS storageclass: %v", err)
}
err = validatePVCAndAppBinding(pvcPath, appPath, f)
Copy link
Member

@nixpanic nixpanic Jun 12, 2023

Choose a reason for hiding this comment

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

Do you expect this to fail, or succeed? I don't know what IP-address is used while testing, so using an IP-address that definitely won't be used might be best to check if mounting fails?

The test currently fails:

  �[1mSTEP:�[0m create a storageclass with a list of clients allowed to mount it and a PVC then bind it to an app �[38;5;243m@ 06/12/23 10:55:40.376�[0m
  Jun 12 10:55:40.380: INFO: ExecWithOptions {Command:[/bin/sh -c ceph fsid] Namespace:rook-ceph PodName:rook-ceph-tools-cbdbf594c-cwdfj ContainerName:rook-ceph-tools Stdin:<nil> CaptureStdout:true CaptureStderr:true PreserveWhitespace:true Quiet:false}
  Jun 12 10:55:40.381: INFO: >>> kubeConfig: /root/.kube/config
  Jun 12 10:55:40.381: INFO: ExecWithOptions: Clientset creation
  Jun 12 10:55:40.381: INFO: ExecWithOptions: execute(POST https://192.168.49.2:8443/api/v1/namespaces/rook-ceph/pods/rook-ceph-tools-cbdbf594c-cwdfj/exec?command=%2Fbin%2Fsh&command=-c&command=ceph+fsid&container=rook-ceph-tools&container=rook-ceph-tools&stderr=true&stdout=true)
  Jun 12 10:55:41.014: INFO: Waiting up to &PersistentVolumeClaim{ObjectMeta:{cephcsi-nfs-pvc  nfs-9603    0 0001-01-01 00:00:00 +0000 UTC <nil> <nil> map[] map[] [] [] []},Spec:PersistentVolumeClaimSpec{AccessModes:[ReadWriteMany],Resources:ResourceRequirements{Limits:ResourceList{},Requests:ResourceList{storage: {{1073741824 0} {<nil>} 1Gi BinarySI},},Claims:[]ResourceClaim{},},VolumeName:,Selector:nil,StorageClassName:*csi-nfs-sc,VolumeMode:nil,DataSource:nil,DataSourceRef:nil,},Status:PersistentVolumeClaimStatus{Phase:,AccessModes:[],Capacity:ResourceList{},Conditions:[]PersistentVolumeClaimCondition{},AllocatedResources:ResourceList{},ResizeStatus:nil,},} to be in Bound state
  Jun 12 10:55:41.014: INFO: waiting for PVC cephcsi-nfs-pvc (0 seconds elapsed)
  Jun 12 10:55:43.016: INFO: waiting for PVC cephcsi-nfs-pvc (2 seconds elapsed)
  Jun 12 10:55:43.021: INFO: Waiting for PV pvc-c2f7bf8f-7300-4ade-959d-2198a50677d8 to bind to PVC cephcsi-nfs-pvc
  Jun 12 10:55:43.021: INFO: Waiting up to timeout=10m0s for PersistentVolumeClaims [cephcsi-nfs-pvc] to have phase Bound
  Jun 12 10:55:43.023: INFO: PersistentVolumeClaim cephcsi-nfs-pvc found and phase=Bound (1.967893ms)
  Jun 12 10:55:43.023: INFO: Waiting up to 10m0s for PersistentVolume pvc-c2f7bf8f-7300-4ade-959d-2198a50677d8 to have phase Bound
  Jun 12 10:55:43.025: INFO: PersistentVolume pvc-c2f7bf8f-7300-4ade-959d-2198a50677d8 found and phase=Bound (2.020311ms)
  Jun 12 10:55:43.034: INFO: Waiting up to cephcsi-nfs-demo-pod to be in Running state
  �[38;5;9m[FAILED]�[0m in [It] - /go/src/github.com/ceph/ceph-csi/e2e/nfs.go:452 �[38;5;243m@ 06/12/23 11:05:43.035�[0m
  Jun 12 11:05:43.060: INFO: Logs of cephcsi-e2e-35924b08/csi-nfsplugin-provisioner-7cb7dbcffb-jrwt5:csi-provisioner on node minikube

https://jenkins-ceph-csi.apps.ocp.cloud.ci.centos.org/blue/rest/organizations/jenkins/pipelines/mini-e2e_k8s-1.27/runs/164/nodes/90/log/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't realise that it actually mounts and tests it. I thought it simply built the exports file and attached it to confirm that the configuration file is build as expected and no errors were detected. I'll investigate this further.

@spuiuk
Copy link
Contributor Author

spuiuk commented Jun 16, 2023

/test ci/centos/mini-e2e/k8s-1.27

@spuiuk
Copy link
Contributor Author

spuiuk commented Jun 16, 2023

/test ci/centos/mini-e2e/k8s-1.27

@spuiuk
Copy link
Contributor Author

spuiuk commented Jun 16, 2023

/test ci/centos/mini-e2e/k8s-1.27

1 similar comment
@spuiuk
Copy link
Contributor Author

spuiuk commented Jun 17, 2023

/test ci/centos/mini-e2e/k8s-1.27

@spuiuk
Copy link
Contributor Author

spuiuk commented Jun 29, 2023

/test ci/centos/mini-e2e/k8s-1.27

1 similar comment
@Madhu-1
Copy link
Collaborator

Madhu-1 commented Jun 29, 2023

/test ci/centos/mini-e2e/k8s-1.27

e2e/nfs.go Outdated
Comment on lines 461 to 478
found := false
for _, export := range exportList {
for _, client := range export.Clients {
for _, address := range client.Addresses {
if address == clientExample {
found = true
break
}
}
if found == true {
if client.AccessType != "rw" {
framework.Failf("Unexpected value for client AccessType: %s", client.AccessType)
}
break
}
}
if found == true {
if export.AccessType != "none" {
framework.Failf("Unexpected value for default AccessType: %s", export.AccessType)
}
break
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Move this to a helper function which does all the check and return error or nil

pvc, err := loadPVC(pvcPath)
if err == nil {
framework.Failf("Could not create PVC: %v", err)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Dont we need to create PVC here and ensure its bound?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. You are right. I am still experimenting with this code and unfortunately the only easy way to test it is to send it to the PR. Thanks for the review but it isn't ready yet. I'll post it when the code is closer to being ready.

# access to the export to the set of hostnames, networks or ip addresses
# specified. The <client-list> is a comma delimited string,
# for example: "192.168.0.10,192.168.1.0/8"
# clients: <client-list>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a chance we need these IP's to be ever changed on the existing PVC?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There could be requirements to change the ip addresses in the figure. There isn't an easy solution for that and will need users to use a new storageclass with the new set of ips. Unfortunately that is a limitation of this particular design.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it possible to move this configuration to the configmap here https://github.com/ceph/ceph-csi/blob/devel/deploy/csi-config-map-sample.yaml#L68?

Copy link
Member

Choose a reason for hiding this comment

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

Not sure how practical that is. Changing the client list after the fact is not something that can (easily) be done through Ceph Mgr once the NFS-export has been created. As the StorageClass parameters are immutable, it shows the right behavior (and difficulties for changing options).

The current design allows creation of different StorageClasses with different client-lists. It becomes ugly and more error prone if that is placed in a ConfigMap.

@spuiuk
Copy link
Contributor Author

spuiuk commented Jun 29, 2023

/test ci/centos/mini-e2e/k8s-1.27

e2e/nfs.go Outdated Show resolved Hide resolved
@spuiuk
Copy link
Contributor Author

spuiuk commented Jun 29, 2023

/test ci/centos/mini-e2e/k8s-1.27

1 similar comment
@spuiuk
Copy link
Contributor Author

spuiuk commented Jun 29, 2023

/test ci/centos/mini-e2e/k8s-1.27

e2e/utils.go Outdated Show resolved Hide resolved
@nixpanic
Copy link
Member

I don't immediately see why the ci fails, it complains about e2e/nfs.go:472 which is the deletion of the StorageClass, but there are no errors logged that help identifying the cause. My guess is that ceph fsid failed for some reason, maybe it needs a retry as we have in other parts of the code?

logs

@nixpanic
Copy link
Member

/test ci/centos/mini-e2e/k8s-1.27

@spuiuk
Copy link
Contributor Author

spuiuk commented Jun 30, 2023

/test ci/centos/mini-e2e/k8s-1.27

@spuiuk
Copy link
Contributor Author

spuiuk commented Jul 3, 2023

/test ci/centos/mini-e2e/k8s-1.27

2 similar comments
@spuiuk
Copy link
Contributor Author

spuiuk commented Jul 4, 2023

/test ci/centos/mini-e2e/k8s-1.27

@spuiuk
Copy link
Contributor Author

spuiuk commented Jul 4, 2023

/test ci/centos/mini-e2e/k8s-1.27

Copy link
Member

@nixpanic nixpanic left a comment

Choose a reason for hiding this comment

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

looks good, thanks for all the iterations to add a test!

@nixpanic
Copy link
Member

nixpanic commented Jul 5, 2023

@Mergifyio queue

@mergify
Copy link
Contributor

mergify bot commented Jul 5, 2023

queue

🛑 The pull request has been removed from the queue default

Pull request #3895 has been dequeued due to failing checks or checks timeout.

You can take a look at Queue: Embarked in merge train check runs for more details.

In case of a failure due to a flaky test, you should first retrigger the CI.
Then, re-embark the pull request into the merge queue by posting the comment
@mergifyio refresh on the pull request.

@nixpanic
Copy link
Member

nixpanic commented Jul 5, 2023

@Mergifyio refresh

@mergify
Copy link
Contributor

mergify bot commented Jul 5, 2023

refresh

✅ Pull request refreshed

@nixpanic
Copy link
Member

nixpanic commented Jul 5, 2023

@Mergifyio rebase

The clients parameter in the storage class is used to limit access to
the export to the set of hostnames, networks or ip addresses specified.

Signed-off-by: Sachin Prabhu <sprabhu@redhat.com>
@mergify
Copy link
Contributor

mergify bot commented Jul 5, 2023

rebase

✅ Branch has been successfully rebased

@nixpanic nixpanic added the ok-to-test Label to trigger E2E tests label Jul 5, 2023
@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/k8s-e2e-external-storage/1.25

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/k8s-e2e-external-storage/1.26

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/k8s-e2e-external-storage/1.27

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/mini-e2e-helm/k8s-1.25

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/mini-e2e-helm/k8s-1.26

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/mini-e2e-helm/k8s-1.27

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/mini-e2e/k8s-1.25

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/mini-e2e/k8s-1.26

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/mini-e2e/k8s-1.27

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/upgrade-tests-cephfs

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/upgrade-tests-rbd

@ceph-csi-bot ceph-csi-bot removed the ok-to-test Label to trigger E2E tests label Jul 5, 2023
@yati1998
Copy link
Contributor

yati1998 commented Jul 6, 2023

/retest ci/centos/mini-e2e-helm/k8s-1.25

@mergify mergify bot merged commit 254699c into ceph:devel Jul 6, 2023
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/nfs Issues related to NFS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow users to specify client lists allowed to access a NFS share
6 participants