Getting Started VMware Tanzu Community Edition (Part 3)

This is part 3 of Getting Started VMware Tanzu Community Edition

Set Up vSphere CNS and Create a Storage Policy in vSphere

vSphere administrators can set up vSphere CNS and create storage policies for virtual disk (VMDK) storage, based on the needs of workload cluster users. You can use either vSAN or local VMFS (Virtual Machine File System) for persistent storage in a Kubernetes cluster. In this case, use local VMFS as follows:
From the top-level vSphere menu, select Tags & Custom Attributes

  1. In the Tags pane, select Categories and click New.

2. Enter a category name, such as tkg-storage. Use the checkboxes to associate it with Datacenter and the storage objects, Folder and Datastore. Click Create.

3. From the top-level Storage view, select your VMFS volume, and in its Summary pane, click Tags > Assign….

4. From the Assign Tag popup, click Add Tag.

5. From the Create Tag popup, give the tag a name, such as tkg-storage-ds1 and assign it the Category you created. Click OK.

6. From Assign Tag, select the tag and click Assign.

7. From top-level vSphere, select VM Storage Policies > Create a Storage Policy. A configuration wizard starts.

Choose VM Storage Policies

Choose Create VM Storage Policy

VM Storage Policies

8. In the Name and description pane, enter a name for your storage policy. Record the storage policy name for reference as the storagePolicyName value in StorageClass objects.

Name and description

9. In the Policy structure pane, under Datastore specific rules, select Enable tag-based placement rules.

Policy structure

10. In the Tag based placement pane, click Add Tag Rule and configure:

  • Tag Category: Select your category name, for example tkg-storage
  • Usage option: Use storage tagged with
  • Tags: Browse and select your tag name “tkg-storage-ds1
Tag-based placement
Storage compatibility

11. Confirm and configure other panes or accept defaults as needed, then click Review and finish. Finish creating the storage policy.

Review and finish

See Tanzu VM Storage Policy on the list

VM Storage Policies

Create Persistent Volumes with Storage Classes

Default Storage Classes

Tanzu provides default StorageClass objects that let workload cluster users provision persistent storage on their infrastructure in a turnkey environment, without needing StorageClass objects created by a cluster administrator.

The ENABLE_DEFAULT_STORAGE_CLASS a variable is set to true by default in the cluster configuration file passed to --file option of tanzu cluster create, to enable the default storage class for a workload cluster.

The Tanzu default storage class definitions are “vSphere CNS”:

kind: StorageClass
name: default
annotations: "true"
storagePolicyName: optional

See the vSphere CSI storage class parameters in the Kubernetes documentation.

Create a Custom Storage Class

Cluster administrators can select or create the VM storage policy to use as the basis for the Kubernetes StorageClass. vSphere administrators can create a storage policy by following the steps in Set Up vSphere CNS and Create a Storage Policy in vSphere above.

  1. Create a StorageClass configuration .yaml with provisioner, parameters, and other options.

2. (vSphere only) Associate a Kubernetes storage class with a vSphere storage policy by setting its storagePolicyName parameter to the vSphere storage policy name, as a double-quoted string. For example tanzu-custom-sc.yaml

### tanzu-custom-sc.yamlapiVersion:
kind: StorageClass
name: custom-sc
annotations: "true"
storagePolicyName: "Tanzu VM Storage Policy"

3. Pass the file to kubectl create -f tanzu-custom-sc.yaml

4. Verify the storage class by running kubectl describe storageclass custom-sc.

Use a Custom Storage Class in a Cluster

To provision persistent storage for their cluster nodes that don’t use one of the Default Storage Classes described above, cluster users include a custom storage class in a pod configuration as follows:

  1. Set the context of kubectl to the cluster. For example:
kubectl config use-context workload1-admin@workload1

2. Select or create a storage class.

==> Select: To list available storage classes, run kubectl get storageclass.

==> Create: Cluster admins can create storage classes by Creating a Custom Storage Class.

3. Create a PVC and its PV:

Create a PersistentVolumeClaim configuration .yaml with spec.storageClassName set to the value of your StorageClass object. For an example, see Enabling Dynamic Provisioning in the Kubernetes documentation. For example tanzu-pvc.yaml

### tanzu-pvc.yamlapiVersion: v1
kind: PersistentVolumeClaim
name: claim1
- ReadWriteOnce
storageClassName: custom-sc
storage: 5Gi
  • Pass the file to kubectl create -f tanzu-pvc.yaml
  • Verify a PVC by runningkubectl describe pvc claim1
  • A PV is automatically created with the PVC. Record its name, listed in the kubectl describe pvc output after Successfully provisioned volume.
  • Verify a PV by running kubectl describe pv <pv_unique_name>

4. Create a pod using the PVC:

Create a Pod configuration .yaml that sets spec.volumes to include your PVC under persistentVolumeClaim.claimName. For an example, see Dynamic Provisioning and StorageClass API in the vSphere Storage for Kubernetes documentation. For example tanzu-pod-use-pvc.yaml

### tanzu-pod-use-pvc.yamlapiVersion: v1
kind: Pod
name: test-pod
- name: my-container1
- name: volume1
mountPath: /test-vmdk
- name: volume1
claimName: claim1
  • Pass the file to kubectl create -f tanzu-pod-use-pvc.yaml
  • Verify a pod used PVC by running kubectl describe pod test-pod

See other content

References :

#VMware #Tanzu # Community #Orchestration #Kubernetes #PaaS



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ach.Chusnul Chikam

Ach.Chusnul Chikam


Cloud Consultant | RHCSA | RHCE in Red Hat OpenStack | Google Cloud ACE | AWS SAA | LinkedIn: