How to Create or Remove a custom VM_TYPE template in VMware Tanzu Application Service (TAS) and VMware Tanzu Kubernetes Grid Integrated Edition (TKGI) for VMs using the Operations Manager API
search cancel

How to Create or Remove a custom VM_TYPE template in VMware Tanzu Application Service (TAS) and VMware Tanzu Kubernetes Grid Integrated Edition (TKGI) for VMs using the Operations Manager API

book

Article ID: 297413

calendar_today

Updated On:

Products

VMware Tanzu Application Service for VMs VMware Tanzu Kubernetes Grid Integrated (TKGi)

Issue/Introduction

This article applies to VMware Tanzu Application Service (TAS) for VMs versions 1.10x and above. You can only create custom VM types if the IaaS CPI supports it, for example vSphere. 
 
Note: Pivotal Cloud Foundry (PCF) is now VMware Tanzu Application Service (TAS) for VMs.
 
This article applies to VMware Tanzu Kubernetes Grid Integrated Edition (TKGI) 1.15.x and above. You can only create custom VM types if the IaaS CPI supports it, for example vSphere. 

Note: If you have installed TKGI via Management Console, you should use compute profiles instead as the custom VM type will not be in sync with the Management Console. More information on the following link --> https://docs.vmware.com/en/VMware-Tanzu-Kubernetes-Grid-Integrated-Edition/1.19/tkgi/GUID-console-compute-profile.html 

In some cases, you need to create a custom vm_type because the current predefined templates are not the configuration that a customer wants. A good example may be when the customer has plenty of resources and wants to create a VM with high CPU, disk, and RAM resources.

Resolution

We have the following pre-defined vm_type templates available currently. The following list is a snapshot taken at the time of writing this article. You should execute step 3 below to retrieve the list from your system:

{
    "vm_types": [
        {
            "name": "Standard_DS1_v2",
            "ram": 3584,
            "cpu": 1,
            "ephemeral_disk": 51200,
            "builtin": true
        },
        {
            "name": "Standard_DS2_v2",
            "ram": 7168,
            "cpu": 2,
            "ephemeral_disk": 102400,
            "builtin": true
        },
        {
            "name": "Standard_DS3_v2",
            "ram": 14336,
            "cpu": 4,
            "ephemeral_disk": 204800,
            "builtin": true
        },
        {
            "name": "Standard_DS4_v2",
            "ram": 28672,
            "cpu": 8,
            "ephemeral_disk": 409600,
            "builtin": true
        },
        {
            "name": "Standard_DS5_v2",
            "ram": 57344,
            "cpu": 8,
            "ephemeral_disk": 819200,
            "builtin": true
        },
        {
            "name": "Standard_DS11_v2",
            "ram": 14336,
            "cpu": 2,
            "ephemeral_disk": 102400,
            "builtin": true
        },
        {
            "name": "Standard_DS12_v2",
            "ram": 28672,
            "cpu": 4,
            "ephemeral_disk": 204800,
            "builtin": true
        },
        {
            "name": "Standard_DS13_v2",
            "ram": 57344,
            "cpu": 8,
            "ephemeral_disk": 409600,
            "builtin": true
        },
        {
            "name": "Standard_DS14_v2",
            "ram": 114688,
            "cpu": 16,
            "ephemeral_disk": 819200,
            "builtin": true
        },
        {
            "name": "Standard_F1s",
            "ram": 2048,
            "cpu": 1,
            "ephemeral_disk": 16384,
            "builtin": true
        },
        {
            "name": "Standard_F2s",
            "ram": 4096,
            "cpu": 2,
            "ephemeral_disk": 32768,
            "builtin": true
        },
        {
            "name": "Standard_F4s",
            "ram": 8192,
            "cpu": 4,
            "ephemeral_disk": 65536,
            "builtin": true
        },
        {
            "name": "Standard_F8s",
            "ram": 16384,
            "cpu": 8,
            "ephemeral_disk": 131072,
            "builtin": true
        }
    ]
}


Create Custom VM_TYPE

Let's consider that we need to create a vm_type with the following specs:

  • CPU: 8, RAM: 64 GB, Disk: 128 GB

As you can see, there is no pre-defined vm_type that matches the above specs. Let's follow the steps below to create vm_type: custom type.

1. SSH into Operations Manager VM.

2. Use the UAAC command to target your Operations Manager and generate a token:

uaac target https://<OpsMan-Hostname>/uaa
    uaac token owner get

    Client name: opsman
    Client secret: <Leave this Blank>
    User name: your_username_here / admin
    Password: your_username_here / admin_password


In the case of SAML integration, please follow the procedure below:

uaac token sso get    
Client name: opsman    
Client secret: leave blank    
click on the url and paste in the code below
Password: 


3. Use the following command to retrieve the existing pre-loaded vm_types:

uaac curl https://<OpsMan-Hostname>/api/v0/vm_types -k


4. Store the output of the above command, which is only the value of RESPONSE BODY and not anything else as shown below:

RESPONSE BODY:
{
  "vm_types": [
    {
      "name": "nano",
      "ram": 512,
      "cpu": 1,
      "ephemeral_disk": 1024,
      "builtin": true
    },
   ............. 
   ............. 
   .............
  ]
 }


5. Add custom vm_type with the desired specification at the bottom of the above output and use it with the following command:

Note: For AWS, the name field determines which instance type to use which means it needs to match an actual AWS Instance type. Ops Manager uses the name of the vm_type as the instance_type.  The /api/v0/vm_types api does not accept an instance_type in the payload.

uaac curl https://<OpsMan-Hostname>/api/v0/vm_types -X PUT -H "Content-Type: application/json" -d 
 '{
  "vm_types": [
    {
      "name": "nano",
      "ram": 512,
      "cpu": 1,
      "ephemeral_disk": 1024,
      "builtin": true
    },
   ............. 
   ............. 
   .............
   {
      "name": "customtype",
      "cpu": 8,
      "ram": 65536,
      "ephemeral_disk": 131072
   } 
  ]
 }' -k


Note: You can add as many VM types as you like to the list. Changes above are immediate and no restart is required, just refresh the browser to see the new list of options.


6. Now you can use this newly added vm_type to replace and update any existing and future VMs:

Remove Custom VM_TYPE

Use the following commands to remove all vm_types:

uaac curl https://<OpsMan-Hostname>/api/v0/vm_types -X DELETE


To bring back default vm_types, do a PUT with the output from step 4.

uaac curl https://<OpsMan-Hostname>/api/v0/vm_types -X PUT -H "Content-Type: application/json" -d 
'{
"vm_types": [
  {
    "name": "nano",
    "ram": 512,
    "cpu": 1,
    "ephemeral_disk": 1024,
    "builtin": true
  },
 ............. 
 ............. 
 .............
 ]
}' -k
Impact


Please be sure to append custom vm_type values to the existing list otherwise it will replace the entire list of default vm_types. If you accidentally do this, run the command Remove Custom VM_TYPE to restore the defaults and try again. If you wrongly remove the entire list and just keep your custom vm_type then the updated list will not take effect until you apply changes.

Once the changes are applied, all the VMs will be updated based on your custom template as this new vm_type will be the only template.