After you create a cluster by using Terraform, you can continue to use Terraform to manage the cluster. For example, you can create custom node pools within the cluster, scale out custom node pools, and delete custom node pools.
Prerequisites
Creating custom node pools
To create a custom node pool within a cluster by using Terraform, follow these steps.
- Create a folder and a configuration file named main.tf within it.
- Initialize the Terraform environment.
- The expected result is as follows.
- Perform resource planning.
- The expected result is as follows.
- Create the custom node pool.
- The expected result is as follows.
- You can view the created custom node pool in the VKE console.
Increasing or decreasing the number of nodes
To scale out or scale in a custom node pool that was created via Terraform, follow these steps.
- Update the auto_scaling.desired_replicas field in the main.tf file to a value between max_replicas and min_replicas.
- Run the command to scale out or in the node pool.
- The expected result is as follows.
- You can view the nodes in the target cluster after a scale-out or scale-in in the VKE console.
Deleting custom node pools
To delete a custom node pool created via Terraform, follow these steps.
Warning
When deleting a custom node pool using Terraform, you cannot retain worker nodes in the node pool. All non-subscription worker nodes will be automatically released. Exercise caution when you perform this operation.
Run the following command to delete the custom node pool.
The expected result is as follows.