Red Hat OpenShift 4.7 additional configuration
vSphere storage for Kubernetes
You can use the VMware vSphere® 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 persistent volume (.vmdk):
govc datastore.disk.create -size 10G ocp-volumes/ocp-pv-001.vmdk
-
Use the CLI to log in to your Kubernetes environment:
export KUBECONFIG=/opt/ocpinstall/auth/kubeconfig oc login
-
Create a persistent volume in Kubernetes for the recently created .vmdk. Replace volumePath with your .vmdk. The following example uses vsphere-volume-pv.yaml.
apiVersion: v1 kind: PersistentVolume metadata: name: ocpvsan001 spec: capacity: storage: 10Gi accessModes: - ReadWriteOnce persistentVolumeReclaimPolicy: Retain vsphereVolume: volumePath: "[ESX_OCP] volumes/ocp-pv-001.vmdk" fsType: ext4 storageClassName: "vsphere-standard"
export KUBECONFIG=/opt/ocpinstall/auth/kubeconfig kubectl create -f vsphere-volume-pv.yaml
-
Create a Persistent Volume Claim in Kubernetes.
Replace volumePath with your Persistent Volume name. The following example uses vsphere-volume-pvc.yaml.
apiVersion: "v1" kind: "PersistentVolumeClaim" metadata: name: "pvcvsan001" spec: accessModes: - "ReadWriteOnce" resources: requests: storage: "1Gi" storageClassName: "vsphere-standard" volumeName: "ocpvsan001"
kubectl create -f vsphere-volume-pvc.yaml
The persistent volume claim can now be mapped to the container application.