2.x
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: default
provisioner: csi.vsphere.vmware.com
# Missing parameters section defining the storage policy
To ensure PVs are correctly provisioned on vSAN, define a StorageClass that explicitly references a vSphere Storage Policy compatible with your vSAN datastore.
Log in to the vSphere Client.
Navigate to Policies and Profiles > VM Storage Policies.
Identify the policy used for your vSAN (e.g., "vSAN Default Storage Policy" or "Tanzu Storage Policy").
Note the exact name (case-sensitive).
Create a YAML file (e.g., vsan-storageclass.yaml) with the following content. Ensure you update the storagePolicyName to match the policy identified in Step 1.
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: vsan-default
annotations:
storageclass.kubernetes.io/is-default-class: "true"
provisioner: csi.vsphere.vmware.com
parameters:
storagePolicyName: "vSAN Default Storage Policy" # Update this name to match your environment
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer
kubectl patch storageclass default -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"false"}}}'kubectl apply -f vsan-storageclass.yaml