Create a Vultr cluster from an existing instance template using the API for consistent, repeatable instance deployments.
Instance templates define a reusable blueprint for instances, including the plan, OS, and SSH keys. Using a template when creating a cluster ensures consistent deployments and simplifies scaling.
This guide explains how to create a cluster from an existing instance template using the Vultr API. To create a cluster by specifying a plan directly, see How to Create a Cluster.
Send a GET request to the List Instance Templates endpoint to retrieve all available templates. If you do not have a template, create one by following the instructions in How to Create an Instance Template.
Note the id of the template you want to use.
Send a POST request to the Create Cluster endpoint to create a new cluster using the template. Replace REGION with the region identifier, TEMPLATE_ID with the instance template's ID, CLUSTER_LABEL with a descriptive name, and HOSTNAME with a hostname for the cluster's instances. Do not include a plan field alongside instance_template. The request accepts either one. Whether the cluster is a Compute Cluster or a Bare Metal Cluster is inferred from the template's plan and cannot be set directly. Set gpu_fabric to true to create a GPU Fabric Cluster. The desired_pool_count must be equal to or greater than min_pool_count.
A successful request returns an HTTP 200 OK response with the cluster details, including the inferred type. Note the cluster id for future operations.
Attach an existing Vultr File Storage (VFS) subscription with vfs.ids, or provision a new one inline with vfs.create. A VFS subscription must be in the same region as the cluster.
Optionally, add a head node to the cluster by including use_head_node and head_node_plan in the request body. Replace HEAD_NODE_PLAN with the compute plan for the head node. The head node needs its own image source, since the compute nodes' image sources come from TEMPLATE_ID rather than a top-level os_id. Provide one in a head_node_template object, or reference an existing instance template by setting head_node_template to its ID directly.
The response includes a head_node_instance_template_id and one additional instance labeled Cluster Head Node, with hostname HOSTNAME-head-node. The head node does not count toward desired_pool_count.
Send a GET request to the Get Cluster endpoint to retrieve the cluster details. Replace {cluster-id} with the ID from the previous step.
Verify that state progresses from empty to active as instances are provisioned.
0 Comments
Be the first to comment and share your perspective with the community.