vSphere with Tanzu offers the VM Service functionality to enable DevOps engineers to provision and manage VMs on a namespace in a self-service manner. You use the vSphere with Tanzu automation APIs to create VM classes that specify the deployment policy and resource reservations of such VMs.
Starting with vSphere 7.0 Update 2a, DevOps engineers can use the VM Service functionality to deploy and run VMs on a namespace through the kubectl commands. You can use the vSphere with Tanzu automation APIs to manage the two VM Service components: VM classes and content libraries. For more information about managing content libraries in the context of vSphere with Tanzu, see Content Libraries in vSphere with Tanzu.
You can use the automation APIs to create and manage VM classes. A VM class specification defines the number of CPUs, memory capacity, and resource reservation settings of the desired virtual machine. vSphere with Tanzu currently offers twelve ready-to-use VM classes (T-shirt sizes) that are derived from the most popular VMs in Kubernetes. Based on the resource reservation that a VM specification requests, each predefined VM class has two editions: guaranteed and best effort. The guaranteed VM class fully reserves the configured resources. A best effort VM class does not guarantee any resource reservations and allows their overcommitment.
You associate a VM class with a specific namespace to make it available to the DevOps engineers who have access to that namespace. You can assign any number of existing VM classes or create a custom one. Note that VMs deployed by the DevOps engineers through the VM Service can only be managed with the kubectl commands. A VM provisioned by DevOps engineers shares the same resources in a namespace as containers.
Use the VirtualMachineClasses interface to create and manage a specification of a VM class object. Through these objects you predefine the number of CPUs, memory capacity, and reservation settings. See Create a VM Class in vSphere with Tanzu. To make a VM class available to the DevOps engineers for self-service VM deployment, you must associate it with a specific namespace. See Associating a VM Class with a vSphere Namespace.
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 Supervisors 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
Procedure
What to do next
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.
Editing or Removing a VM Class from Your Environment
You can use the automation APIs to edit the configuration of a VM class that you created or a predefined VM classes that vSphere with Tanzu offers. When you no longer need an existing VM class, you can remove it from your vCenter Server instance.
Note that editing a VM class specification does not affect the VMs that are already deployed by the DevOps engineers from this class. Only newly deployed VMs will use the reconfigured VM class.
Deleting a VM class results in its removal from all related namespaces. All VMs deployed with this VM class remain unchanged but DevOps engineers can no longer use it.
You can list all VM classes available for a vCenter Server instance by calling the list method of the VirtualMachineClasses interface. You receive a list of all VM classes and a detailed information about each one of them. Based on the detailed information, you can narrow the list and retrieve the IDs of the VM classes that you want to edit or delete.
To edit a VM class configuration, call the update(String vmClass, VirtualMachineClassesTypes.UpdateSpec spec) method of the VirtualMachineClasses interface and pass as arguments the VM class ID and the update specification. You can edit all VM class attributes except the ID of the class. Only the attributes modified within the update specification will be edited.
To delete a VM class from your environment, call the delete(java.lang.String vmClass) method of the VirtualMachineClasses interface and pass the ID of the class as argument.
Associating a VM Class with a vSphere Namespace
You must associate a VM class with a namespace to make it available for DevOps engineers to deploy VMs in a self-service manner.
You can associate one or more VM classes with a single namespace or you can add one VM class to several namespaces. You can use the predefined VM classes that vSphere with Tanzu provides or you can create custom ones. See Create a VM Class in vSphere with Tanzu.
Since VM Service is the feature responsible for handling VM classes, you must make that service aware of the VM classes available to the engineers using a specific namespace. You can achieve this when you create a new namespace or edit an existing one. See Managing Namespaces on a Supervisor.
When you create the VM Service specification set the list of VM classes that must be used to create VMs on the specific namespace. You achieve this by calling the setVmClasses(java.util.Set<java.lang.String> vmClasses) method of the VirtualMachineClasses object.
You can also associate one or more content libraries with a namespace that has the VM Service enabled. See Associating a Content Library with a Namespace.