
Vultr Kubernetes Engine (VKE) is a reliable and flexible service that lets you deploy your applications and services on Kubernetes clusters. A key feature is node pools, which group nodes with specific configurations like instance type, custom tags, and scaling behavior, helping separate workloads based on application requirements. For cases requiring custom setup during provisioning, Cloud-Init can automate tasks such as installing packages, configuring users, or writing files, ensuring nodes are ready for your workloads immediately.
This guide demonstrates how to configure node pools using Cloud-Init in Vultr Kubernetes Engine and how to manage them through the API.
Prerequisites
Before you begin, you need to:
- Have access to your Vultr API Key.
- Have a running Vultr Kubernetes Engine (VKE) cluster.
Create a Cloud-Init Config
In this section, you will create a Cloud-Init configuration file, encode it into base64, and export it into your shell environment as a variable. This allows you to pass the configuration when creating or updating VKE node pools.
Create a new Cloud-Init configuration file.
console$ vim cloud-config.yaml
Add the following content to the file:
yaml#cloud-config write_files: - path: /root/vultr.txt content: "Greetings from Vultr!\n" owner: root:root permissions: '0644'
Save and exit the file.
This configuration writes a text file
/root/vultr.txt
with the contentGreetings from Vultr!
.Encode the Cloud-Init configuration into
base64
and export it as an environment variable.console$ export USERDATA=$(base64 < cloud-config.yaml | tr -d '\n')
The command above base64-encodes your
cloud-config.yaml
and removes newlines (tr -d '\n'
) so that the output can be safely passed in API requests. The encoded string is stored in theUSERDATA
environment variable.Verify the exported
USERDATA
value.console$ echo $USERDATA
Output:
I2Nsb3VkLWNvbmZpZwp3cml0ZV9maWxlczoKICAtIHBhdGg6IC9yb290L3Z1bHRyLnR4dAogICAgY29udGVudDogIkdyZWV0aW5ncyBmcm9tIFZ1bHRyIVxuIgogICAgb3duZXI6IHJvb3Q6cm9vdAogICAgcGVybWlzc2lvbnM6ICcwNjQ0Jwo=
Create a Node Pool With Cloud-Init Config
In this section, you will create a new node pool in your Vultr Kubernetes Engine (VKE) cluster and attach the Cloud-Init configuration you encoded earlier. This ensures that each node in the pool automatically provisions with your custom configuration during bootstrap.
Export your Vultr API Key to the active shell environment.
console$ export VULTR_API_KEY=YOUR_VULTR_API_KEY
List all available VKE clusters.
console$ curl -sS --fail --compressed 'https://api.vultr.com/v2/kubernetes/clusters' \ --header "Authorization: Bearer ${VULTR_API_KEY}" | jq .
Note the Cluster ID where you want to create the new node pool.
Output:
{ "vke_clusters": [ { "id": "eba638dc-4a7e-42a7-ad69-2c1e8d7675a6", "firewall_group_id": "", "label": "my-vke-cluster",
In this example, the Cluster ID is
eba638dc-4a7e-42a7-ad69-2c1e8d7675a6
.Export the Cluster ID as an environment variable.
console$ export VKE_CLUSTER_ID=YOUR_VKE_CLUSTER_ID
Replace
YOUR_VKE_CLUSTER_ID
with your Cluster ID.Create a new node pool with your Cloud-Init configuration.
console$ curl --location "https://api.vultr.com/v2/kubernetes/clusters/${VKE_CLUSTER_ID}/node-pools" \ --header 'Content-Type: application/json' \ --header "Authorization: Bearer ${VULTR_API_KEY}" \ --data '{ "node_quantity": 3, "label": "my-vke-test-node-pool", "plan": "vhp-12c-24gb-intel", "tag": "my-vke-test-node-pool", "user_data": "'"${USERDATA}"'" }'
In this above request:
node_quantity
: Defines the number of nodes in the pool.label
: Assigns a human-readable name to the pool.plan
: Sets the instance type used for each node.tag
: Attaches a metadata tag for easier identification.user_data
: Injects the base64-encoded Cloud-Init configuration.
Output:
{ "node_pool": { "id": "59f729ad-c5a8-4160-a6c0-d8b786f5d14b", "date_created": "2025-08-29T08:10:06+00:00", "date_updated": "2025-08-29T08:10:08+00:00", "label": "my-vke-test-node-pool",
Your node pool is now created. Make a note of the Node Pool ID. It may take a few minutes for nodes to bootstrap and apply the Cloud-Init configuration.
Export the Node Pool ID as an environment variable.
console$ export NODE_POOL_ID=YOUR_NODE_POOL_ID
Replace
YOUR_NODE_POOL_ID
with your Node Pool ID.Verify that the node pool is created and has your Cloud-Init configuration.
console$ curl -sS --fail --compressed \ --location "https://api.vultr.com/v2/kubernetes/clusters/${VKE_CLUSTER_ID}/node-pools/${NODE_POOL_ID}" \ --header "Authorization: Bearer ${VULTR_API_KEY}" \ | jq .
Output:
{ "node_pool": { "id": "59f729ad-c5a8-4160-a6c0-d8b786f5d14b", "date_created": "2025-08-29T07:55:30+00:00", "date_updated": "2025-08-29T07:56:43+00:00", ...... "node_quantity": 3, "user_data": "I2Nsb3VkLWNvbmZpZwp3cml0ZV9maWxlczoKICAtIHBhdGg6IC9yb290L3Z1bHRyLnR4dAogICAgY29udGVudDogIkdyZWV0aW5ncyBmcm9tIFZ1bHRyIVxuIgogICAgb3duZXI6IHJvb3Q6cm9vdAogICAgcGVybWlzc2lvbnM6ICcwNjQ0Jwo=", ...
From this output you can confirm that the node pool has been created and that your base64-encoded Cloud-Init configuration was successfully applied.
In this section, you will learn how to update an existing Vultr Kubernetes Engine (VKE) node pool to use a custom Cloud-Init configuration. This allows you to apply initialization scripts, file writes, or system modifications to nodes created in the pool. Keep in mind that Cloud-Init only applies during the first boot of a new node, so updates will only affect nodes added into the node pool after the configuration is changed.
Export your Vultr API Key in the active shell environment.
console$ export VULTR_API_KEY=YOUR_VULTR_API_KEY
Get a list of all VKE clusters.
console$ curl -sS --fail --compressed 'https://api.vultr.com/v2/kubernetes/clusters' \ --header "Authorization: Bearer ${VULTR_API_KEY}" | jq .
Note the VKE Cluster ID in which your node pool exists.
Output:
{ "vke_clusters": [ { "id": "eba638dc-4a7e-42a7-ad69-2c1e8d7675a6", "firewall_group_id": "", "label": "my-vke-cluster",
In this example, the Cluster ID is
eba638dc-4a7e-42a7-ad69-2c1e8d7675a6
.Export the Cluster ID in your shell environment.
console$ export VKE_CLUSTER_ID=YOUR_VKE_CLUSTER_ID
Replace
YOUR_VKE_CLUSTER_ID
with your Cluster ID.Get all the node pools in your cluster.
console$ curl -sS --fail --compressed "https://api.vultr.com/v2/kubernetes/clusters/${VKE_CLUSTER_ID}/node-pools" \ --header "Authorization: Bearer ${VULTR_API_KEY}" \ | jq .
Output:
{ "node_pools": [ { "id": "59f729ad-c5a8-4160-a6c0-d8b786f5d14b", "date_created": "2025-08-29T07:55:30+00:00", "date_updated": "2025-08-29T07:56:43+00:00", "label": "my-vke-test-node-pool", .........
Note the Node Pool ID that you want to modify for later use.
Export your Node Pool ID in the active shell environment.
console$ export NODE_POOL_ID=YOUR_NODE_POOL_ID
Replace
YOUR_NODE_POOL_ID
with the Node Pool ID you want to modify.Update the node pool to include your Cloud-Init configuration.
console$ curl --location --request PATCH \ "https://api.vultr.com/v2/kubernetes/clusters/${VKE_CLUSTER_ID}/node-pools/${NODE_POOL_ID}" \ --header 'Content-Type: application/json' \ --header "Authorization: Bearer ${VULTR_API_KEY}" \ --data '{ "user_data": "'"${USERDATA}"'" }'
Verify that the node pool now includes your Cloud-Init configuration.
console$ curl -sS --fail --compressed \ --location "https://api.vultr.com/v2/kubernetes/clusters/${VKE_CLUSTER_ID}/node-pools/${NODE_POOL_ID}" \ --header "Authorization: Bearer ${VULTR_API_KEY}" \ | jq .
Output:
{ "node_pool": { "id": "59f729ad-c5a8-4160-a6c0-d8b786f5d14b", "date_created": "2025-08-29T07:55:30+00:00", "date_updated": "2025-08-29T09:24:09+00:00", "label": "my-vke-test-node-pool", ...... "user_data": "I2Nsb3VkLWNvbmZpZwp3cml0ZV9maWxlczoKICAtIHBhdGg6IC9yb290L3Z1bHRyLnR4dAogICAgY29udGVudDogIkdyZWV0aW5ncyBmcm9tIFZ1bHRyIVxuIgogICAgb3duZXI6IHJvb3Q6cm9vdAogICAgcGVybWlzc2lvbnM6ICcwNjQ0Jwo=", ...
From the above output, you can see that the
user_data
field has been successfully updated.Noteuser_data
for an existing node pool only applies to newly created nodes in that pool. Existing nodes will not be reconfigured, as Cloud-Init only runs during the first boot of an instance.
Verify Cloud-Init Config Reflected Into Node-Pool Nodes
Log in to the Vultr Customer Portal.
Navigate to Compute under Products section.
Locate the instances created by your node pool. The instance labels will use the prefix you specified when creating the node pool.
Click on an instance to open its management page.
Copy the login credentials such as IP Address, Username, and Password.
SSH into one of the VKE cluster worker nodes.
console$ ssh username@vke_worker_node_ip
In this guide, the Cloud-Init config created a text file in the
/root
directory namedvultr.txt
.Verify that you are in the
/root
directory.console# pwd
Output:
/root
View the file contents.
console# cat /root/vultr.txt
Output:
Greetings from Vultr!
The output confirms that the Cloud-Init configuration was successfully applied.
Conclusion
In this guide, you configured a VKE node pool with Cloud-Init, applied a custom user-data script through the Vultr API, and verified the changes on the worker nodes. Using Cloud-Init allows you to automate initial setup tasks such as writing files or installing packages so that new nodes are ready to use immediately after provisioning.
No comments yet.