This guide documents how to manage persistent volumes on a Tanzu Kubernetes Grid cluster.
- Being an administrative contact of your Hosted Private Cloud infrastructure to receive login credentials
- A user account with access to the OVHcloud Control Panel
- A user account with access to vSphere
- You need to have deployed the Workload TKG cluster using the Tanzu Management Cluster Grid Administration guide.
Persistent volumes are used to store data permanently on a Kubernetes cluster. This mechanism is based on Storage Classes. There are various Storage Classes. Read the Kubernetes Storage Classes guide for more information.
When deploying a WorkLoad cluster, a Storage Class CSI provisioner is created and points to the Datastore folder that contains the virtual machines in the WorkLoad cluster.
From your VMware cluster, go to the inventory. Select the storage icon to the left, and go to the datastore where your WorkLoad cluster was deployed. Go to the
Files tab and click the
The folder is empty because the WorkLoad cluster does not yet use persistent volumes.
You can create additional Storage Classes for each WorkLoad cluster.
We will connect to a WorkLoad cluster from the console of the Bootstrap virtual machine. You can use the Tanzu Management Cluster Grid Administration guide to create and manage a workload cluster.
From the Bootstrap virtual machine console, run this command to view the contexts that can be used on this cluster:
# Display all the contexts of your TANZU KUBERNETES GRID cluster kubectl config get-contexts
Run this command to use the WorkLoad cluster:
# Connect to WorkLoad cluster kubectl config use-context tkgm-workload-cluster-admin@tkgm-workload-cluster
Displaying Existing Storage Classes
For information about the Storage Classes in a WorkLoad cluster, run these commands:
# Display Storage Classes kubectl get storageclass # Storage Class description kubectl describe storageclass nomclasse
Creating a storage class on another datastore
On our VMware cluster, we have two datastores connected to NFS servers. One of the datastores contains the virtual machines in the WorkLoad cluster, as well as the fcd folder used by the Storage Class in the Workload cluster.
We will create a new Storage Class on the second datastore.
Go back to your VMware cluster in storage management, select the second datastore, and click
Summary in the tab on the left.
URL below “Type:NFS3”.
Go to the console of the Bootstrap virtual machine, edit a new file named
secondstorageclass.yaml with this content:
Edit the file by replacing
ds:///vmfs/volumes/xxxxxxxxxxxxxxxxx/with the URL you just copied.
Next, run this command:
# Creating storageclass from yaml file kubectl apply -f secondstorageclass.yaml # Display storageclasses kubectl get storageclass
We are now seeing two Storage Classes:
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE default (default) csi.vsphere.vmware.com Delete Immediate true 3d18h secondstorageclass (default) csi.vsphere.vmware.com Delete Immediate false 12s tanzu@bootstrap:~$
Creating a persistent volume in the default Storage class
Create a file named
default-pvc-storage.yaml with this content:
The persistent storage name is next to
storageClassName contains the name of the Storage Class that is used for this volume.
Run this command to create the persistent volume:
# Create a namespace that will be used for my persistent volume. kubectl create namespace myspace # Applying the configuration file to the created namespace. kubectl apply -f default-pvc-storage.yaml -n myspace # Display persistent volumes of created namespace kubectl get pv,pvc -n myspace
Go back to the inventory in your vCenter interface, click on the
DataCenter icon on the left, then go to the
Monitor tab on the right, and click on
Container Volumes to see the persistent volumes.
The persistent volume that has been created is displayed, and to the right you can see the name of the datastore on which it is stored.
Click the notebook icon to the left of the volume to view the details.
The information about this persistent storage is displayed, and corresponds to what was created using Kubernetes commands.
Go to the Datastore that is used by default, right-click the
Files tab and scroll through the folders in the Datastore to the
You see that the folder contains two files, a vmdk file that contains the persistent volume data and an associated temporary file.
Creating a persistent volume on the second Storage Class
Return to the Bootstrap virtual machine and use the command line.
Create a file named
The file uses the same syntax as the first persistent storage, but with a different name and Storage Class.
Run this command to create the persistent volume in the myspace namespace:
# Applying the configuration file to the created namespace. kubectl apply -f second-storage-pvc.yaml -n myspace # Display persistent volumes of created namespace kubectl get pv,pvc -n myspace
The persistent volume is created on the second Datastore.
Return to the vCenter interface. You will see that you do not have any new files in the
Right-click the second Datastore, go to the
fcd folder for that datastore. You will see that you have two new files, as in the first datastore.
Go back to the
Datacenter at the root of the datacenters, click on the
Monitor tab, and choose
Container volumes to see the two persistent volumes appear with their locations in the datastores.