How To Configure Node Pools Using Cloud-Init in Vultr Kubernetes Engine

Updated on 11 September, 2025
Guide
Learn how to configure Vultr Kubernetes Engine (VKE) node pools with Cloud-Init for automated provisioning and management.
How To Configure Node Pools Using Cloud-Init in Vultr Kubernetes Engine header image

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:

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.

  1. 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 content Greetings from Vultr!.

  2. 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 the USERDATA environment variable.

  3. 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.

  1. Export your Vultr API Key to the active shell environment.

    console
    $ export VULTR_API_KEY=YOUR_VULTR_API_KEY
    
  2. 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.

  3. 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.

  4. 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.

  5. 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.

  6. 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.

Verify Cloud-Init Config Reflected Into Node-Pool Nodes

  1. Log in to the Vultr Customer Portal.

  2. Navigate to Compute under Products section.

  3. Locate the instances created by your node pool. The instance labels will use the prefix you specified when creating the node pool.

  4. Click on an instance to open its management page.

  5. Copy the login credentials such as IP Address, Username, and Password.

  6. 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 named vultr.txt.

  7. Verify that you are in the /root directory.

    console
    # pwd
    

    Output:

    /root
  8. 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.

Comments

No comments yet.