We have seen couple of requests from our customer about how to create a custom vm type in PKS as the cluster has plenty of resources and wants to create a VM with high CPU, disk, and RAM resources. Though the steps are available in the product knowledge base, some times it gets confusing.
In this blog post, we will see how to create a custom vm_type for the vms in Enterprise PKS/TKGI environment, using the Operations Manager API.
Create Custom VM_TYPE :
Step 1. SSH into Operations Manager VM.
Step 2. Use UAAC command to target your Operations Manager.
uaac target https://<OpsMan-Hostname>/uaa
Step 3: Use UAAC command to generate a token for the admin account
uaac token owner get
You need to input the client ID as opsman and leave the secret as blank. Username is admin and the password for the admin account. The output will be as below.
ubuntu@opsman:~$ uaac token owner get
Client ID: opsman
Client secret:
Unknown key: Max-Age = 86400
User name: admin
Password: ********
Unknown key: Max-Age = 172800
Successfully fetched token via owner password grant.
Target: https://opsman.corp.local/uaa
Context: admin, from client opsman
Step 4: Use the following command to retrieve the existing pre-loaded vm_types
into plans.json file.
uaac curl https://Opsman-FQDN/api/v0/vm_types --insecure > plans.json
Step 5: Edit the plans.json file using vim and remove unwanted content from top. Also add the custom plan to the json file. Once done, the file looks as below. You can see I have added a custom plan custom-rk at the end of the list in the plans.json file.
{
"vm_types": [
{
"name": "nano",
"ram": 512,
"cpu": 1,
"ephemeral_disk": 8192,
"builtin": true
},
{
"name": "micro",
"ram": 1024,
"cpu": 1,
"ephemeral_disk": 8192,
"builtin": true
},
{
"name": "micro.ram",
"ram": 1024,
"cpu": 2,
"ephemeral_disk": 8192,
"builtin": true
},
{
"name": "small",
"ram": 2048,
"cpu": 1,
"ephemeral_disk": 8192,
"builtin": true
},
{
"name": "small.disk",
"ram": 2048,
"cpu": 1,
"ephemeral_disk": 16384,
"builtin": true
},
{
"name": "medium",
"ram": 4096,
"cpu": 2,
"ephemeral_disk": 8192,
"builtin": true
},
{
"name": "medium.mem",
"ram": 8192,
"cpu": 1,
"ephemeral_disk": 8192,
"builtin": true
},
{
"name": "medium.disk",
"ram": 4096,
"cpu": 2,
"ephemeral_disk": 32768,
"builtin": true
},
{
"name": "medium.cpu",
"ram": 2048,
"cpu": 4,
"ephemeral_disk": 8192,
"builtin": true
},
{
"name": "large",
"ram": 8192,
"cpu": 2,
"ephemeral_disk": 16384,
"builtin": true
},
{
"name": "large.mem",
"ram": 16384,
"cpu": 1,
"ephemeral_disk": 16384,
"builtin": true
},
{
"name": "large.disk",
"ram": 8192,
"cpu": 2,
"ephemeral_disk": 65536,
"builtin": true
},
{
"name": "large.cpu",
"ram": 4096,
"cpu": 4,
"ephemeral_disk": 16384,
"builtin": true
},
{
"name": "xlarge",
"ram": 16384,
"cpu": 4,
"ephemeral_disk": 32768,
"builtin": true
},
{
"name": "xlarge.mem",
"ram": 32768,
"cpu": 2,
"ephemeral_disk": 32768,
"builtin": true
},
{
"name": "xlarge.disk",
"ram": 16384,
"cpu": 4,
"ephemeral_disk": 131072,
"builtin": true
},
{
"name": "xlarge.cpu",
"ram": 8192,
"cpu": 8,
"ephemeral_disk": 32768,
"builtin": true
},
{
"name": "2xlarge",
"ram": 32768,
"cpu": 8,
"ephemeral_disk": 65536,
"builtin": true
},
{
"name": "2xlarge.mem",
"ram": 65536,
"cpu": 4,
"ephemeral_disk": 65536,
"builtin": true
},
{
"name": "2xlarge.disk",
"ram": 32768,
"cpu": 8,
"ephemeral_disk": 262144,
"builtin": true
},
{
"name": "2xlarge.cpu",
"ram": 16384,
"cpu": 16,
"ephemeral_disk": 65536,
"builtin": true
},
{
"name": "custom-rk",
"ram": 16384,
"cpu": 16,
"ephemeral_disk": 65536,
"builtin": false
}
]
}
Step 6: Run the below command to set variable for the plans.json file for the ease of use in our next command.
data=$(cat plans.json)
Step 7: Add custom vm_type
with the desired specification at the bottom of the above output and use it with the following command:
uaac curl https://Opsman-FQDN/api/v0/vm_types -X PUT -H "Content-Type: application/json" -d "$data" --insecure
The output of the command would look like the below.
ubuntu@opsman:~$ uaac curl https://opsman.corp.local/api/v0/vm_types -X PUT -H "Content-Type: application/json" -d "$data" --insecure
PUT https://opsman.corp.local/api/v0/vm_types
REQUEST BODY: "{
"vm_types": [
{
"name": "nano",
"ram": 512,
"cpu": 1,
"ephemeral_disk": 8192,
"builtin": true
},
{
"name": "micro",
"ram": 1024,
"cpu": 1,
"ephemeral_disk": 8192,
"builtin": true
},
{
"name": "micro.ram",
"ram": 1024,
"cpu": 2,
"ephemeral_disk": 8192,
"builtin": true
},
{
"name": "small",
"ram": 2048,
"cpu": 1,
"ephemeral_disk": 8192,
"builtin": true
},
{
"name": "small.disk",
"ram": 2048,
"cpu": 1,
"ephemeral_disk": 16384,
"builtin": true
},
{
"name": "medium",
"ram": 4096,
"cpu": 2,
"ephemeral_disk": 8192,
"builtin": true
},
{
"name": "medium.mem",
"ram": 8192,
"cpu": 1,
"ephemeral_disk": 8192,
"builtin": true
},
{
"name": "medium.disk",
"ram": 4096,
"cpu": 2,
"ephemeral_disk": 32768,
"builtin": true
},
{
"name": "medium.cpu",
"ram": 2048,
"cpu": 4,
"ephemeral_disk": 8192,
"builtin": true
},
{
"name": "large",
"ram": 8192,
"cpu": 2,
"ephemeral_disk": 16384,
"builtin": true
},
{
"name": "large.mem",
"ram": 16384,
"cpu": 1,
"ephemeral_disk": 16384,
"builtin": true
},
{
"name": "large.disk",
"ram": 8192,
"cpu": 2,
"ephemeral_disk": 65536,
"builtin": true
},
{
"name": "large.cpu",
"ram": 4096,
"cpu": 4,
"ephemeral_disk": 16384,
"builtin": true
},
{
"name": "xlarge",
"ram": 16384,
"cpu": 4,
"ephemeral_disk": 32768,
"builtin": true
},
{
"name": "xlarge.mem",
"ram": 32768,
"cpu": 2,
"ephemeral_disk": 32768,
"builtin": true
},
{
"name": "xlarge.disk",
"ram": 16384,
"cpu": 4,
"ephemeral_disk": 131072,
"builtin": true
},
{
"name": "xlarge.cpu",
"ram": 8192,
"cpu": 8,
"ephemeral_disk": 32768,
"builtin": true
},
{
"name": "2xlarge",
"ram": 32768,
"cpu": 8,
"ephemeral_disk": 65536,
"builtin": true
},
{
"name": "2xlarge.mem",
"ram": 65536,
"cpu": 4,
"ephemeral_disk": 65536,
"builtin": true
},
{
"name": "2xlarge.disk",
"ram": 32768,
"cpu": 8,
"ephemeral_disk": 262144,
"builtin": true
},
{
"name": "2xlarge.cpu",
"ram": 16384,
"cpu": 16,
"ephemeral_disk": 65536,
"builtin": true
},
{
"name": "custom-rk",
"ram": 16384,
"cpu": 16,
"ephemeral_disk": 65536,
"builtin": false
}
]
}"
REQUEST HEADERS:
Content-Type: application/json
200 OK
RESPONSE HEADERS:
Date: Wed, 19 Aug 2020 06:07:40 GMT
Content-Type: text/html
Transfer-Encoding: chunked
Connection: close
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 1; mode=block
X-Content-Type-Options: nosniff
X-Download-Options: noopen
X-Permitted-Cross-Domain-Policies: none
Referrer-Policy: strict-origin-when-cross-origin
Cache-Control: no-cache, no-store
Pragma: no-cache
Expires: Fri, 01 Jan 1990 00:00:00 GMT
X-Request-Id: 741fe312-0862-4bad-aeec-f62b8f62d014
X-Runtime: 2.154988
Strict-Transport-Security: max-age=31536000; includeSubDomains
Server: Ops Manager
RESPONSE BODY:
Step 8: Login to opsman GUI and validate that you can see the custom plan under PKS tile > Plan > Master/worker vm_type. In the below screenshot, you can see the custom plan that I have added which is custom-rk.

I have tested the same steps in PKS 1.5 and now in TKGI 1.8 and it works beautifully. I hope this helps you to get your custom plan added easily into your TKGI environment. Make sure to update the CPU, disk, and RAM when you add the custom plan as per your requirement.
If you feel this blog has helped you, feel free to share it so that it helps someone else too. Happy learning 🙂
Leave a Reply