This section describes information about deploying vSphere Container Storage Plug-in on Windows.

Guidelines and Requirements

Your environment must meet general requirements that apply to vSphere Container Storage Plug-in. For more information, see Preparing for Installation of vSphere Container Storage Plug-in.

In addition, follow these requirements to deploy vSphere Container Storage Plug-in with Windows.
  • Kubernetes version 1.20 or higher.
  • vSphere Container Storage Plug-in version 3.0.0 or later.
  • CSI Proxy v1. Install CSI Proxy on all Windows nodes. For more information, see https://github.com/kubernetes-csi/csi-proxy#installation
  • Control plane node run on Linux.
  • Worker nodes must have Windows Server 2019. Other versions of Windows Server are not supported. Windows worker nodes is supported on the following builds.
    • Windows-ltsc2022
    • Windows-20h2
    • Windows-1809
  • Containerd version must be 1.5 or higher if you use it in nodes. For more information, see containerd fails to add a disk mount on Windows.

Enable vSphere Container Storage Plug-in with Windows Nodes

Enable vSphere Container Storage Plug-in using Windows nodes on the Kubernetes cluster.

Note: When a pod is created and the volume does not have a filesystem created on it, the filesystem type supplied from the StorageClass is ignored and the volume gets formatted with the NTFS file system.

Procedure

  1. Install vSphere Container Storage Plug-in version 3.0.0.
  2. Verify that the Windows daemonset is available.
    $ kubectl get daemonsets vsphere-csi-node-windows --namespace=vmware-system-csi
    NAME                       DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR              AGE
    vsphere-csi-node-windows   1         1         1       1            1           kubernetes.io/os=windows   7m10s
  3. Create a storage class.
    1. Define a StorageClass example-windows-sc.yaml.
      kind: StorageClass
      apiVersion: storage.k8s.io/v1
      metadata:
        name: example-windows-sc
      provisioner: csi.vsphere.vmware.com
      allowVolumeExpansion: true  # Optional: only applicable to vSphere 7.0U1 and above
      parameters:
        storagepolicyname: "vSAN Default Storage Policy"  # Optional Parameter
        #datastoreurl: "ds:///vmfs/volumes/vsan:52cdfa80721ff516-ea1e993113acfc77/"  # Optional Parameter
        #csi.storage.k8s.io/fstype: "ntfs"  # Optional Parameter
      Note: csi.storage.k8s.io/fstype is an optional parameter. Using Windows file system, you can only set ntfs as its value since vSphere Container Storage Plug-in only supports NTFS file system on Windows nodes.
    2. Define a PersistentVolumeClaim request example-windows-pvc.yaml.
      apiVersion: v1
      kind: PersistentVolumeClaim
      metadata:
        name: example-windows-pvc
      spec:
        accessModes:
          - ReadWriteOnce
        resources:
          requests:
            storage: 5Gi
        storageClassName: example-windows-sc
        volumeMode: Filesystem
      Note: The pvc definition for Windows is the same as for Linux. You can specify only ReadWriteOnce as access modes.
    3. Import the PersistentVolumeClaim into Vanilla Kubernetes cluster:
      kubectl create -f example-windows-pvc.yaml
    4. Verify that the PersistentVolume is created successfully.
      The Status must display as Bound.
      $ kubectl describe pvc example-windows-pvc
      Name:          example-windows-pvc
      Namespace:     default
      StorageClass:  example-windows-sc
      Status:        Bound
      Volume:        pvc-e64e0716-ff63-47b8-8ee4-d1eb4f86dcd7
      Labels:        <none>
      Annotations:   pv.kubernetes.io/bind-completed: yes
                    pv.kubernetes.io/bound-by-controller: yes
                    volume.beta.kubernetes.io/storage-provisioner: csi.vsphere.vmware.com
      Finalizers:    [kubernetes.io/pvc-protection]
      Capacity:      5Gi
      Access Modes:  RWO
      VolumeMode:    Filesystem
      Used By:       example-windows-pod
      Events:        <none>
    5. Create a Windows pod specification example-windows-pod.yaml.
      In the specification, reference the example-windows-pvc that you created earlier.
      apiVersion: v1
      kind: Pod
      metadata:
        name: example-windows-pod
      spec:
        nodeSelector:
          kubernetes.io/os: windows
        containers:
          - name: test-container
            image: mcr.microsoft.com/windows/servercore:ltsc2019
            command:
              - "powershell.exe"
              - "-Command"
              - "while (1) { Add-Content -Encoding Ascii C:\\test\\data.txt $(Get-Date -Format u); sleep 1 }"
            volumeMounts:
              - name: test-volume
                mountPath: "/test/"
                readOnly: false
        volumes:
          - name: test-volume
            persistentVolumeClaim:
              claimName: example-windows-pvc
    6. Create the pod.
      kubectl create -f example-windows-pod.yaml
    7. Verify that the pod is created successfully.
      $ kubectl get pod example-windows-pod
      NAME                  READY   STATUS    RESTARTS   AGE
      example-windows-pod   1/1     Running   0          4m13s

      In the above example, example-windows-pvc is formatted as NTFS file system and is mounted to C:\test directory.