Openshift4 on vSphere add more Datastore expandable
--
By default if you Installed Openshift with UPI or IPI on VMware vSphere. You will got 2 storageclass thin
and thin-csi
both will pointed to the same Datastore on your vCenter.
If you would like to add more storageclass with new Datastore you can follow the yaml below with kubernetes.io/vsphere-volume
this one cannot expandable on operation day 2.
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
annotations:
storageclass.kubernetes.io/is-default-class: "true"
name: new-thin-sc
parameters:
datastore: datastore1
diskformat: thin
provisioner: kubernetes.io/vsphere-volume
reclaimPolicy: Delete
volumeBindingMode: Immediate
If you look at thin-csi
storageclass. It’ll look like the yaml below. It might notice you that their is no datastore parameter like thin
but StoragePolicy parameter is required.
allowVolumeExpansion: true
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: thin-csi
parameters:
StoragePolicyName: openshift-storage-policy-xxxxxx
provisioner: csi.vsphere.vmware.com
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer
So, We need to create storage policy
on vCenter first.
- Create/Assign Tag on target Datastore.
2. Create storage policy
- vCenter -> policies & profiles -> VM Storage Policies
3. Create storageclass with the yaml below
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
annotations:
storageclass.kubernetes.io/is-default-class: "false"
name: sc-datastore1
parameters:
StoragePolicyName: upi-datastore1 ### -> TAG
provisioner: csi.vsphere.vmware.com
reclaimPolicy: Delete
allowVolumeExpansion: true
volumeBindingMode: Immediate
4. Test create PVC and check on vCenter
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: busybox-pvc-data1
spec:
storageClassName: sc-datastore1
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2Gi
5. Test expand PVC