Openshift4 on vSphere add more Datastore expandable

Surote Wongpaiboon
3 min readMar 10, 2023

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

ref: https://access.redhat.com/solutions/4618011

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.

  1. Create/Assign Tag on target Datastore.
example Tag `upi-datastore1` with Catagory `<openshift tag>`
Catagory come with openshift installation just assigned Tag to your cluster category

2. Create storage policy
- vCenter -> policies & profiles -> VM Storage Policies

Select tag that assigned on the target Datastore
make sure compatible Datastore is correct

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
oc get pvc

5. Test expand PVC

expand using openshift console
check event on vCenter
check pvc with new capacity

--

--