Harvester CSI Driver

The Harvester Container Storage Interface (CSI) Driver provides a standard CSI interface used by guest Kubernetes clusters in Harvester. It connects to the host cluster and hot-plugs host volumes to the virtual machines (VMs) to provide native storage performance.

Deploying

Prerequisites

  • The Kubernetes cluster is built on top of Harvester virtual machines.
  • The Harvester virtual machines run as guest Kubernetes nodes are in the same namespace.

Harvester CSI Driver - 图1note

Currently, the Harvester CSI driver only supports single-node read-write(RWO) volumes. Please follow the issue #1992 for future multi-node read-only(ROX) and read-write(RWX) support.

Deploying with Harvester RKE1 Node Driver

  • Select Harvester(Out-of-tree) option (optional. If you don’t need to use the Cloud Provider feature at the same time, you can select the None option).

    Harvester CSI Driver - 图2

  • Install Harvester CSI Driver from the Rancher marketplace.

    Harvester CSI Driver - 图3

Deploying with Harvester RKE2 Node Driver

When spinning up a Kubernetes cluster using Rancher RKE2 node driver, the Harvester CSI driver will be deployed when Harvester cloud provider is selected.

select-harvester-cloud-provider

You can also deploy Harvester CSI Driver manually if you have already deployed the Harvester node driver manually. Perform the following steps to manually deploy the Harvester CSI Driver.

  1. Generate the addon config.

Harvester CSI Driver - 图5note

The script uses kubectl and jq to operate the Harvester cluster. The script needs access to the Harvester Cluster kubeconfig to work. The <serviceaccount name> is usually your guest cluster name, and the <namespace> needs to match the namespace of the guest cluster.

  • Install jq:
  1. # apt install jq
  • Set up kubectl and the kubeconfig file (the kubeconfig should allow you to access the Harvester Cluster):
  1. # export KUBECONFIG=kubeconfig
  2. # export PATH="${PATH}:/var/lib/rancher/rke2/bin"

You can generate the kubeconfig file using the generate_addon_csi.sh script. It is available on the harvester/harvester-csi-driver repo.

  1. # ./generate_addon_csi.sh <serviceaccount name> <namespace>

Get the addon yaml from the output of the script above.

Harvester CSI Driver - 图6

  1. Create the addon config file and add the addon yaml from the output above.
  1. # mkdir -p /var/lib/rancher/rke2/etc/config-files
  2. # vim /var/lib/rancher/rke2/etc/config-files/csi_addon.yaml
  1. Install Harvester CSI Driver.

Install Harvester CSI Driver from the Rancher marketplace. Harvester CSI Driver - 图7

You do not need to change the cloud-config path: Harvester CSI Driver - 图8

The Harvester CSI driver should now be deployed successfully.

Deploying with Harvester K3s Node Driver

  1. # depend on kubectl to operate the Harvester cluster
  2. ./deploy/generate_addon_csi.sh <serviceaccount name> <namespace>
  • Install Harvester CSI Driver from the Rancher marketplace.

    Harvester CSI Driver - 图9