The Issue
When you have attached a vSphere Storage Policy to your vSphere Namespace, and tried to create a cluster using the Storage Policy Name, you find it will fail with an error such as:
Error from server (storage class is not valid for control plane VM: StorageClass 'Tanzu Storage Policy' is not assigned for namespace 'deanl', storage class is not valid for worker VMs: StorageClass 'Tanzu Storage Policy' is not assigned for namespace 'deanl', storage class Tanzu Storage Policy under spec.settings.storage.defaultClass is not valid: StorageClass 'Tanzu Storage Policy' is not assigned for namespace 'deanl'): error when creating "cluster.yaml": admission webhook "default.validating.tanzukubernetescluster.run.tanzu.vmware.com" denied the request: storage class is not valid for control plane VM: StorageClass 'Tanzu Storage Policy' is not assigned for namespace 'deanl', storage class is not valid for worker VMs: StorageClass 'Tanzu Storage Policy' is not assigned for namespace 'deanl', storage class Tanzu Storage Policy under spec.settings.storage.defaultClass is not valid: StorageClass 'Tanzu Storage Policy' is not assigned for namespace 'deanl'
When you look at the vSphere namespace, the Storage Policy is attached.
And example of the erroneous Tanzu Cluster definition YAML:
apiVersion: run.tanzu.vmware.com/v1alpha1 kind: TanzuKubernetesCluster metadata: name: deanl-cluster namespace: deanl spec: distribution: version: v1.18.5 topology: controlPlane: class: best-effort-small count: 1 storageClass: "Tanzu Storage Policy" workers: class: best-effort-small count: 1 storageClass: "Tanzu Storage Policy" settings: network: cni: name: calico storage: defaultClass: "Tanzu Storage Policy"
The Cause
When the Storage Policy is attached, the name needs to be dns-compliant, so in the example above, it will change the uppercase letters to lowercase, and replace any spaces with hyphens.
The Fix
Validate your storage policy name by connecting to the vSphere Name using the “kubectl vsphere login” command and validate with either:
kubectl get storageclass kubectl describe namespace {vSphere Namespace}
An example of the corrected Tanzu Cluster definition YAML:
apiVersion: run.tanzu.vmware.com/v1alpha1 kind: TanzuKubernetesCluster metadata: name: deanl-cluster namespace: deanl spec: distribution: version: v1.18.5 topology: controlPlane: class: best-effort-small count: 1 storageClass: tanzu-storage-policy workers: class: best-effort-small count: 1 storageClass: tanzu-storage-policy settings: network: cni: name: calico storage: defaultClass: tanzu-storage-policy
Regards
Thnaks sf mUc you saved my time
I dont want why VMw a doan incude shc in his docuementation