Storage options on IBM Cloud and Red Hat OpenShift
vSphere storage for Kubernetes
You can use the VMware Cloud Foundation for Classic datastores as a location for storing persistent volumes for Kubernetes by using the VMware® Cloud Provider.
Complete the following steps to create a new volume:
-
From the bastion host, use
govc
to enable the vSphere connection.export GOVC_URL='10.208.17.2' export GOVC_USERNAME='administrator@vsphere.local' export GOVC_PASSWORD='xxx' export GOVC_INSECURE=1 export GOVC_NETWORK='SDDC-DPortGroup-Mgmt' export GOVC_DATASTORE='vsanDatastore'
-
Create a folder on the specified datastore.
govc datastore.mkdir ocp-volumes
-
Create a new persistent volume (vmdk).
govc datastore.disk.create -size 10G volumes/ocp-pv-001.vmdk
-
Log in to your Kubernetes environment from the command line.
oc login
-
Create a persistent volume in Kubernetes, for the recently created vdmk. Replace volumePath with your vmdk, in the example file called vsphere-volume-pv.yaml.
apiVersion: v1 kind: PersistentVolume metadata: name: ocpvsan002 spec: capacity: storage: 10Gi accessModes: - ReadWriteOnce persistentVolumeReclaimPolicy: Retain vsphereVolume: volumePath: "[ESX_OCP] volumes/ocp-pv-001.vmdk" fsType: ext4 storageClassName: "vsphere-standard"
kubectl create -f vsphere-volume-pvc.yaml
-
Create a Persistent Volume Claim in Kubernetes. Replace volumePath with your Persistent Volume name, in the example file called vsphere-volume-pvc.yaml.
apiVersion: "v1" kind: "PersistentVolumeClaim" metadata: name: "pvcvsan002" spec: accessModes: - "ReadWriteOnce" resources: requests: storage: "1Gi" storageClassName: "vsphere-standard" volumeName: "ocpvsan002"
kubectl create -f vsphere-volume-pv.yaml
Now you have a persistent volume claim that can be mapped to the container application.