If you’re using Kubernetes, you can use Longhorn to provide persistent storage using the Longhorn Container Storage Interface (CSI) driver.

Preferred driver

The CSI driver is preferred to the FlexVolume driver, which is deprecated as of Longhorn v0.8.0 and should no longer be used.

Note that the volume created and used through one driver won’t be recognized by Kubernetes using the other driver. So please don’t switch driver (e.g. during upgrade) if you have existing volumes created using the old driver. To switch from the FlexVolume driver to the CSI driver, see here for instructions.

The CSI driver

Requirements for the CSI driver

  1. Kubernetes v1.10+
    1. CSI is in beta release for this version of Kubernetes, and enabled by default.
  2. Mount propagation feature gate enabled.
    1. It’s enabled by default in Kubernetes v1.10. But some early versions of RKE may not enable it.
    2. You can check it by using environment check script.

Check if your setup satisfied CSI requirement

  1. Use the following command to check your Kubernetes server version

    1. kubectl version

    Result:

    1. Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.3", GitCommit:"2bba0127d85d5a46ab4b778548be28623b32d0b0", GitTreeState:"clean", BuildDate:"2018-05-21T09:17:39Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}
    2. Server Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.1", GitCommit:"d4ab47518836c750f9949b9e0d387f20fb92260b", GitTreeState:"clean", BuildDate:"2018-04-12T14:14:26Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}

    The Server Version should be v1.10 or above.

  2. The result of environment check script should contain MountPropagation is enabled!.

Environment check script

We’ve written a script to help you gather enough information about the factors. Before installing, run:

  1. curl -sSfL https://raw.githubusercontent.com/longhorn/longhorn/master/scripts/environment_check.sh | bash

Example result:

  1. daemonset.apps/longhorn-environment-check created
  2. waiting for pods to become ready (0/3)
  3. all pods ready (3/3)
  4. MountPropagation is enabled!
  5. cleaning up...
  6. daemonset.apps "longhorn-environment-check" deleted
  7. clean up complete

Successful CSI deployment example

  1. $ kubectl -n longhorn-system get pod
  2. NAME READY STATUS RESTARTS AGE
  3. csi-attacher-6fdc77c485-8wlpg 1/1 Running 0 9d
  4. csi-attacher-6fdc77c485-psqlr 1/1 Running 0 9d
  5. csi-attacher-6fdc77c485-wkn69 1/1 Running 0 9d
  6. csi-provisioner-78f7db7d6d-rj9pr 1/1 Running 0 9d
  7. csi-provisioner-78f7db7d6d-sgm6w 1/1 Running 0 9d
  8. csi-provisioner-78f7db7d6d-vnjww 1/1 Running 0 9d
  9. engine-image-ei-6e2b0e32-2p9nk 1/1 Running 0 9d
  10. engine-image-ei-6e2b0e32-s8ggt 1/1 Running 0 9d
  11. engine-image-ei-6e2b0e32-wgkj5 1/1 Running 0 9d
  12. longhorn-csi-plugin-g8r4b 2/2 Running 0 9d
  13. longhorn-csi-plugin-kbxrl 2/2 Running 0 9d
  14. longhorn-csi-plugin-wv6sb 2/2 Running 0 9d
  15. longhorn-driver-deployer-788984b49c-zzk7b 1/1 Running 0 9d
  16. longhorn-manager-nr5rs 1/1 Running 0 9d
  17. longhorn-manager-rd4k5 1/1 Running 0 9d
  18. longhorn-manager-snb9t 1/1 Running 0 9d
  19. longhorn-ui-67b9b6887f-n7x9q 1/1 Running 0 9d