Manually verifying CSI configuration

Summary

This article explains how to manually verify that a particular CSI driver is configured properly on a Kubernetes Cluster. In most cases, you should try using the automatic verification method described at:

https://docs.cloudcasa.io/help/kbs/kb-csi-checker.html

Note

This article assumes that the user has already set up a PVC of CSI type.

Step-by-Step

  1. Verify that “v1” version of Snapshot CRDs are available on the cluster. You can check this by running the following command:

    $ kubectl api-resources | grep snapshot.storage.k8s.io
    

    You should see output similar to the following. Note “v1”.:

    volumesnapshotclasses    vsclass,vsclasses  snapshot.storage.k8s.io/v1  false VolumeSnapshotClass
    volumesnapshotcontents   vsc,vscs           snapshot.storage.k8s.io/v1  false VolumeSnapshotContent
    volumesnapshots          vs                 snapshot.storage.k8s.io/v1  true  VolumeSnapshot
    

    If you don’t find the CRDs listed, follow the documentation of your CSI driver and install all necessary components.

  2. Identify a PVC you want to snapshot. Ensure that it is using CSI and identify the CSI driver. This can be done by checking the PV associated with the PVC. Here is an example of how to do that (only partial output is shown for the sake of brevity).

    • Get PVC:

      $ kubectl get pvc -A
      NAMESPACE     NAME              STATUS   VOLUME
      testapp-csi   testapp-storage   Bound    pvc-f2e4f9ec-13b7-4251-8eb0-8e3f28a8703d
      
    • Get details of the corresponding PV:

      $ kubectl describe pv pvc-f2e4f9ec-13b7-4251-8eb0-8e3f28a8703d
      
      Name:              pvc-f2e4f9ec-13b7-4251-8eb0-8e3f28a8703d
      StorageClass:      csi-hostpath-sc
      Status:            Bound
      Claim:             testapp-csi/testapp-storage
      ...
      
      Source:
          Type:              CSI (a Container Storage Interface (CSI) volume source)
          Driver:            hostpath.csi.k8s.io
          ...
      

    From PV details, you can see that the type is CSI. Also note the CSI driver.

  3. Make sure that there is a VolumeSnapshotClass for the CSI driver. If not, create one. Here is a sample:

    apiVersion: snapshot.storage.k8s.io/v1
    kind: VolumeSnapshotClass
    metadata:
        name: my-snapshotclass
    
    driver: <CSI_DRIVER>
    deletionPolicy: Delete
    

    Note that some CSI drivers require custom properties to be set in a volume snapshot class. Please refer to the documentation of your CSI driver. If such configuration is required, you would pass parameters in the field parameters. Here is an example:

    parameters:
        param1: param1-value
    
  4. Create VolumeSnapshot resource in the same namespace as the original PVC. This acts as the request to create a snapshot of the PVC. Here is a sample spec:

    apiVersion: snapshot.storage.k8s.io/v1
    kind: VolumeSnapshot
    metadata:
        name: my-snapshot
    spec:
        volumeSnapshotClassName: my-snapshotclass
        source:
            persistentVolumeClaimName: <PVC_NAME>
    

If the CSI is properly configured, you should see the field “readyToUse” set in VolumeSnapshot resource.:

$ kubectl -n <PVC_NAMESPACE> get volumesnapshot # Showing only relevant output

NAME          READYTOUSE   SOURCEPVC         SNAPSHOTCONTENT
my-snapshot   true         testapp-storage   snapcontent-3dddf8c5-c018-45a4-999c-b4f001f30555

If you don’t see Volume snapshot content in the output, external snapshotter is either not installed or is not working as expected. If VolumeSnapshotContent is created but “readyToUse” is not set, there may be an issue with CSI driver. Check logs of the CSI driver and consult the driver’s documentation.

Some possible reasons for snapshots not working:

  • External snapshotter and/or CSI driver are not installed.

  • External snapshotter and/or CSI driver cannot handle the version of volume snapshot CRDs.

  • CSI driver requires some parameters in Volume snapshot class resource but they are missing.

  • Finally, some CSI drivers don’t implement snapshot functionality so confirm from the driver documentation that this is not the case.

Finally, don’t forget to delete all the resources created for the testing (such as VolumeSnapshot).