Skip to content

Install the CSI driver

  1. License Secret (License) in the namespace created in Prepare the Kubernetes cluster:
    Terminal window
    kubectl -n csi-hyperv create secret generic hypervcsi-license --from-file=license.lic=./license.lic
  2. Values file my-values.yaml (minimal; the chart’s values.yaml lists everything):
    global:
    imageTag: <version> # same version as the WebApi
    imagePullSecrets: [ { name: ghcr-regcred } ]
    license:
    existingSecret: hypervcsi-license
    hypervcsicontroller:
    enabled: true
    environment:
    - { name: ASPNETCORE_ENVIRONMENT, value: Production }
    - { name: Kestrel__EndPoints__UnixSocket__Url, value: "http://unix:/csi/csi.sock" }
    - { name: Kestrel__EndPoints__UnixSocket__Protocols, value: Http2 }
    - { name: K8sHypervServices__Mode, value: Http }
    - { name: K8sHypervServices__Http__ApiUrl, value: "http://<webapi-host>:8081" }
    - { name: K8sHypervServices__Http__ApiToken, value: "<ApiSettings:ApiToken of the WebApi>" }
    hypervcsinodedriver:
    enabled: true
    environment:
    - { name: ASPNETCORE_ENVIRONMENT, value: Production }
    - { name: Kestrel__EndPoints__UnixSocket__Url, value: "http://unix:/csi/csi.sock" }
    - { name: Kestrel__EndPoints__UnixSocket__Protocols, value: Http2 }
    - { name: K8sHypervServices__Mode, value: Http }
    - { name: K8sHypervServices__Http__ApiUrl, value: "http://<webapi-host>:8081" }
    - { name: K8sHypervServices__Http__ApiToken, value: "<same token>" }
    Do not add Kestrel__EndPoints__Http__Url: the CSI gRPC endpoints must stay on the Unix socket (they are unauthenticated). Keep the API token out of Git (SOPS, sealed secrets, or valueFrom with your own Secret).
  3. Install:
    Terminal window
    git clone https://github.com/baremetal-works/hypervcsi-helm.git
    helm install hypervcsi ./hypervcsi-helm/charts/hypervcsi -n csi-hyperv -f my-values.yaml
    The chart also creates the cluster-scoped CSIDriver object eu.nova.csi.hyperv.
  4. StorageClass:
    apiVersion: storage.k8s.io/v1
    kind: StorageClass
    metadata:
    name: hyperv-vstore1
    provisioner: eu.nova.csi.hyperv
    parameters:
    hostname: hv-cluster-01.example.com # required: cluster FQDN (Clusters[].Name + Domain) or a node FQDN
    store: VStore1 # CSV name; the Default store when omitted
    vhdType: Dynamic # Dynamic (default) or Fixed
    csi.storage.k8s.io/fstype: ext4 # ext4 (default), xfs or ext3
    # logicalSectorSize / physicalSectorSize: default 4096
    reclaimPolicy: Delete
    volumeBindingMode: Immediate
    allowVolumeExpansion: true # needs the CAN_RESIZE license feature
Terminal window
kubectl -n csi-hyperv get pods # controller 4/4 (5/5 with the health monitor), one node driver per node
kubectl get csidriver eu.nova.csi.hyperv
kubectl apply -f - <<'EOF'
apiVersion: v1
kind: PersistentVolumeClaim
metadata: { name: hyperv-test }
spec:
accessModes: [ReadWriteOnce]
storageClassName: hyperv-vstore1
resources: { requests: { storage: 1Gi } }
---
apiVersion: v1
kind: Pod
metadata: { name: hyperv-test }
spec:
containers:
- { name: c, image: busybox:1.36, command: [sh, -c, "echo ok > /data/ok && sleep 3600"], volumeMounts: [ { name: d, mountPath: /data } ] }
volumes: [ { name: d, persistentVolumeClaim: { claimName: hyperv-test } } ]
EOF
kubectl wait pod/hyperv-test --for=condition=Ready --timeout=180s
kubectl exec hyperv-test -- df -h /data
kubectl delete pod/hyperv-test pvc/hyperv-test # the VHDX is detached and deleted from the CSV