Create a VM Class in vSphere with Tanzu

You can use the vSphere Automation Kubernetes APIs to create custom VM classes to be used for VM deployment in vSphere with Tanzu.

A VM class specifies the CPU, memory, and resource reservations for a VM. vSphere with Tanzu offers several preconfigured VM classes which you can use as is, edit, or delete. You can also create a custom VM class in your vCenter Server instance and it will be available to all Supervisor Clusters and the namespaces created in these clusters. Note that even though a VM class is available to all namespaces, a DevOps user can only use the VM classes associated with the namespaces that he/she can access.

Prerequisites

Required privileges:
  • Namespaces.Modify cluster-wide configuration
  • Namespaces.Modify namespace configuration
  • Virtual Machine Classes.Manage Virtual Machine Classes

Procedure

  1. Create the specification of the VM class object by providing the following attributes:
    Attribute Description
    id / setId(java.lang.String id) The identifier of the VM class must follow these DNS requirements:
    • A unique name in the current vCenter Server instance.
    • An alphanumeric name with maximum 63 characters.
    • No uppercase letters of spaces.
    • A dash can be used anywhere except as a first or last character.
    Note that after a VM class is created, you cannot edit its ID.
    cpu_count / setCpuCount(long cpuCount) The number of virtual CPUs (vCPUs) configured for a VM that will be deployed with this VM class.
    memory_MB / setMemoryMB(long memoryMB) The memory in MB configured for a VM that will be deployed with this VM class. The value must be between 4 MB and 24 TB and a multiple of 4.
    description / setDescription(java.lang.String description) Optional. The description of the VM class.
    cpu_reservation / setCpuReservation(java.lang.Long cpuReservation) Optional. The percentage of total available CPU resources reserved for the VM deployed with the VM class. The percentage you specify with this attribute is multiplied by the minimum CPU available among all cluster nodes to get the CPU resources guaranteed by vSphere for a VM. The resulting value is in MHz.
    memory_reservation / setMemoryReservation(java.lang.Long memoryReservation) Optional. The percentage of available memory that is reserved for a VM deployed with this VM class. The value can be between 0 and 100%.
  2. Create the VM class object.
    Call the create(VirtualMachineClassesTypes.CreateSpec spec) method of the VirtualMachineClasses interface and pass as argument the created VM class specification. You can also call the POST https://<vCenter_Server_IP>/api/vcenter/namespace-management/virtual-machine-classes HTTP request and pass the created VM class specification in the request body.

What to do next

After you create the custom VM class, you can edit its parameters or delete it from your environment. See Editing or Removing a VM Class from Your Environment.

You can make your VM class available to DevOps engineers by associating it with a namespace. See Associating a VM Class with a vSphere Namespace.