You need to enable JavaScript to run this app.
Volcengine Kubernetes Engine

Volcengine Kubernetes Engine

Copy page
Download PDF
Terraform
Managing existing nodes in the default node pool by using Terraform
Copy page
Download PDF
Managing existing nodes in the default node pool by using Terraform
This topic describes how to create a default node pool in a cluster created using Terraform, and how to add existing nodes to or remove existing nodes from the default node pool.​
Prerequisites​
Creating a default node pool and adding existing nodes to the default node pool​
To create a default node pool using Terraform and add existing nodes to the default node pool, follow the steps below.​
  1. Create a folder and a configuration file named main.tf in it.​
  • ​
    terraform {​
    required_providers {​
    volcengine = {​
    source = "volcengine/volcengine"​
    version = "0.0.140" # Query available versions from the official Terraform website (https://registry.terraform.io/providers/volcengine/volcengine/latest).​
    }​
    }​
    }​
    ​
    provider "volcengine" {​
    access_key = "**********" # The Access Key ID of the Volcano Engine root user.​
    secret_key = "**********" # The Secret Access Key of the Volcano Engine root user.​
    region = "cn-beijing" # The region where the VKE cluster is located.​
    }​
    ​
    data "volcengine_vke_clusters" "default" {​
    name_regex = "tf-created-vke" # The name of the cluster created by Terraform.​
    }​
    ​
    # Create a default node pool and add existing nodes to the node pool.​
    resource "volcengine_vke_default_node_pool" "vke_test" {​
    cluster_id = data.volcengine_vke_clusters.default.clusters[0].id​
    node_config {​
    security {​
    login {​
    password = "*****" # The node access credential. It is the password of the root user. The value must be Base64-encoded.​
    }​
    }​
    }​
    instances {​
    instance_id = "i-ybwgrtud6d********" # The ID of the existing node (ECS instance).​
    keep_instance_name = true # Whether to retain the ECS instance name. The value "true" retains the instance name. The value "false" specifies that the ECS instance is assigned a new name after it is added into the cluster.​
    additional_container_storage_enabled = true # Whether to format the data volume and mount it to the container and image storage directories. The value "true" allows this action, while the value "false" does not allow this action.​
    container_storage_path = "/dev/vdb" # Specify the mount directory of the data volume.​
    }​
    instances {​
    instance_id = "i-ybwgqqpjav********"​
    keep_instance_name = true​
    additional_container_storage_enabled = true​
    container_storage_path = "/dev/vdb"​
    }​
    }​
    ​
  1. Initialize the Terraform environment.​
  • ​
    terraform init​
    ​
  • The expected result is as follows.​
  • ​
    Initializing the backend...​
    ​
    Initializing provider plugins...​
    - Finding volcengine/volcengine versions matching "0.0.140"...​
    - Installing volcengine/volcengine v0.0.140...​
    ​
    ...​
    ​
    Terraform has been successfully initialized!​
    ​
    You may now begin working with Terraform. Try running "terraform plan" to see​
    any changes that are required for your infrastructure. All Terraform commands​
    should now work.​
    ​
    If you ever set or change modules or backend configuration for Terraform,​
    rerun this command to reinitialize your working directory. If you forget, other​
    commands will detect it and remind you to do so if necessary.​
    ​
  1. Perform resource planning.​
  • ​
    terraform plan​
    ​
  • The expected result is as follows.​
  • ​
    Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:​
    + create​
    ​
    Terraform will perform the following actions:​
    ...​
    Plan: 1 to add, 0 to change, 0 to destroy.​
    ​
  1. Create a default node pool and add existing nodes to the default node pool.​
  • ​
    terraform apply​
    ​
  • The expected result is as follows.​
  • ​
    Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:​
    + create​
    ​
    Terraform will perform the following actions:​
    ...​
    Do you want to perform these actions?​
    Terraform will perform the actions described above.​
    Only 'yes' will be accepted to approve.​
    ​
    Enter a value: yes​
    ​
    volcengine_vke_default_node_pool.vke_test: Creating...​
    ...​
    Apply complete! Resources: 1 added, 0 changed, 0 destroyed.​
    ​
  • You can also check the existing nodes in the default node pool named vke-default-nodepool in the VKE console.​
Removing nodes from the default node pool​
To remove a previously added node from the default node pool using Terraform, follow these steps.​
warning​
Regardless of whether the billing method for the existing node to be removed is subscription or pay-as-you-go, this action will not release the node. You can release the node in the ECS console. For details, see Deleting instances.​
  1. Delete the content of the instances field from the main.tf file.​
  • ​
    ...​
    #instances {​
    # instance_id = "i-ybwgqqpjav********"​
    # keep_instance_name = true​
    # additional_container_storage_enabled = true​
    # container_storage_path = "/dev/vdb"​
    #}​
    ...​
    ​
  1. Run the command to remove the node.​
  • ​
    terraform apply​
    ​
  • The expected result is as follows.​
  • ​
    Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:​
    ~ update in-place​
    ​
    Terraform will perform the following actions:​
    ...​
    Plan: 0 to add, 1 to change, 0 to destroy.​
    ​
    Do you want to perform these actions?​
    Terraform will perform the actions described above.​
    Only 'yes' will be accepted to approve.​
    ​
    Enter a value: yes​
    ...​
    Apply complete! Resources: 0 added, 1 changed, 0 destroyed.​
    ​
  • You can check whether the node has been removed from the default node pool in the VKE console.​
​
Last updated: 2026.07.23 14:31:47