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

Volcengine Kubernetes Engine

Copy page
Download PDF
Nodes and node pools
Implementing custom node scale-in behavior with lifecycle hooks
Copy page
Download PDF
Implementing custom node scale-in behavior with lifecycle hooks
VKE allows you to implement custom actions on nodes by using the lifecycle hook feature of autoscaling groups during node deletion. This topic describes the considerations and procedure for setting up lifecycle hooks for node pools.​
Background​
When you create a node pool in a VKE cluster, the system automatically creates a scaling group for the node pool. You can configure a custom lifecycle hook in the scaling group to perform defined operations during manual node deletion or automatic scale-in. For example, you can implement cleanup behavior on nodes when deleting them. For details on lifecycle hooks, see Lifecycle hook overview.​
Usage limits​
  • When using lifecycle hooks of scaling groups, consider the following information about billing types of nodes in the node pool:​
  • Pay-as-you-go instances are recommended.​
  • Subscription instances are allowed. However, scaling in such instances usually triggers instance shutdown and system reinstallation, which may affect resource cleanup.​
  • Changing the billing type of instances within their lifecycles may cause instance release failures and consequent resource idleness.​
  • A configured lifecycle hook of a node pool works only during node deletion. ​
Prerequisites​
A node pool has been created. For details, see Creating node pools.​
Procedure​
Step 1: Create a command​
  1. Log in to the ECS console.​
  1. In the left navigation bar, click Maintenance & Monitoring > Cloud Assistant.​
  1. Click the Custom command tab. Click Create custom command to create a command to run during node deletion.​
tip​
This example uses a sleep command. Replace it with your desired command. For details on creating custom commands, see Managing custom commands.​
  1. Click Confirm.​
​
Step 2: Create a lifecycle hook​
  1. Log in to the Auto Scaling console.​
  1. In the left navigation bar, click Scaling Group.​
  1. In the scaling group list, click the name of the scaling group corresponding to the VKE cluster node pool. This opens the scaling group details page.​
tip​
The scaling group automatically created for a VKE cluster follows the naming format of vke-${Cluster-id}-${Nodepool-id}. You can use the cluster ID or node pool ID to search for the target scaling group.​
  1. Click the Lifecycle hook tab. Click Create lifecycle hook to configure a custom lifecycle hook for this node pool. For details, see Creating lifecycle hooks.​
  1. Click Confirm.​
Validating results​
After you configure a custom lifecycle hook for the node pool, manual node deletion or automatic scale-in triggers that lifecycle hook. Node deletion is performed only after the hook performs the defined actions and ends.​
​
​
Last updated: 2026.07.23 11:53:58