Managing persistent volumes in Tanzu Kubernetes Grid
How to deploy an application in Tanzu Kubernetes Grid with persistent volumes
How to deploy an application in Tanzu Kubernetes Grid with persistent volumes
Last updated 10th November 2022
This guide documents how to manage persistent volumes on a Tanzu Kubernetes Grid cluster.
OVHcloud provides services for which you are responsible, with regard to their configuration and management. It is therefore your responsibility to ensure that they work properly.
This guide is designed to assist you as much as possible with common tasks. However, we recommend contacting a specialist provider if you experience any difficulties or doubts when it comes to managing, using or setting up a service on a server.
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 fcd
folder.
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
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
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.
Copy the URL
below "Type: NFS 3".
Go to the console of the Bootstrap virtual machine, edit a new file named secondstorageclass.yaml
with this content:
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: secondstorageclass
annotations:
storageclass.kubernetes.io/is-default-class: "true"
provisioner: csi.vsphere.vmware.com
parameters:
datastoreurl: "ds:///vmfs/volumes/xxxxxxxxxxxxxxxxx/"
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:~$
Create a file named default-pvc-storage.yaml
with this content:
kind: persistantVolumeClaim
apiVersion: v1
metadata:
name: default-pvc-storage
spec:
accessModes:
- ReadWriteOnce
storageClassName: "default"
resources:
requests:
storage: 2Gi
The persistent storage name is next to name
, 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 fcd
folder.
You see that the folder contains two files, a vmdk file that contains the persistent volume data and an associated temporary file.
Return to the Bootstrap virtual machine and use the command line.
Create a file named second-storage-pvc.yaml
:
kind: persistantVolumeClaim
apiVersion: v1
metadata:
name: second-storage-pvc
spec:
accessModes:
- ReadWriteOnce
storageClassName: "secondstorageclass"
resources:
requests:
storage: 2Gi
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 fcd
folder.
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.
Introduction to Tanzu Kubernetes Grid at OVHcloud
Installing Tanzu Kubernetes Grid
Managing Tanzu Management Cluster Grid
Introducing VMware Tanzu Kubernetes Grid
VMware Tanzu Kubenetes Grid documentation
Manual installation of the CLI tool for the deployment of Tanzu Kubernetes GRID
Join our community of users on https://community.ovh.com/en/.
Please feel free to give any suggestions in order to improve this documentation.
Whether your feedback is about images, content, or structure, please share it, so that we can improve it together.
Your support requests will not be processed via this form. To do this, please use the "Create a ticket" form.
Thank you. Your feedback has been received.
Access your community space. Ask questions, search for information, post content, and interact with other OVHcloud Community members.
Discuss with the OVHcloud community