Used to let the Agent call the BCS API through bk-cli bcs . Before starting, first read ../bk-cli-shared/SKILL.md. The shared skill handles common invocation rules such as authentication, context, tenant, stage, dry-run, verbose, header/body, etc.
Currently available command hierarchy:
bk-cli bcs cluster_manager <action>
If the user wants to operate other BCS modules, first run bk-cli bcs -h to check whether a corresponding subsystem already exists.
Action list
cluster_manager currently includes:
- Clusters:
create_cluster、import_cluster、update_cluster - Auto scaling:
update_auto_scaling_option、update_auto_scaling_status - Nodes:
delete_nodes_from_cluster、batch_delete_nodes_from_cluster、add_nodes_to_cluster_v2、add_subnet_to_cluster、update_node_annotations、check_node_in_cluster、cordon_node、drain_node、check_drain_node、update_node_labels、update_node_taints、un_cordon_node - Node groups:
create_node_group、update_node_group、disable_node_group_auto_scale、enable_node_group_auto_scale、update_group_min_max_size、update_group_desired_node、update_group_desired_size、clean_nodes_in_group、clean_nodes_in_group_v2 - Node templates:
create_node_template、update_node_template、trans_node_group_to_node_template - Tasks and configuration:
retry_task、skip_task、create_template_config、delete_template_config、update_virtual_cluster_quota
Invocation steps
- Find action:
bk-cli bcs cluster_manager -h - View the default help for the target action. By default,
-hwill showUsage、Examples, flags, and whether there is a body schema:bk-cli bcs cluster_manager create_cluster -h - If the default help indicates that the body schema can be viewed, use
-h --body-schemato view the complete request body schema:bk-cli bcs cluster_manager create_cluster -h --body-schema - Construct the command according to
Examples. Complex request bodies are uniformly passed through--body '<json>'. Do not guess body fields. - Before the first execution or a write operation, first add
--dry-run, and confirmrequest.url、request.params、request.body、request.headers。
Input rules
- Path parameters and query parameters are ordinary flags, for example
--clusterID、--nodeGroupID、--nodes、--isForce=true。 - The query string of a DELETE action is also passed in as flags.
- Some write operations require
--body; when missing, it returnsmissing_paramandrequired parameter --body is missing。 -h --body-schemaonly displays the schema and does not execute the request.
Common examples
Update cluster:
bk-cli bcs cluster_manager update_cluster \
--clusterID BCS-K8S-12345 \
--body '{"clusterID":"BCS-K8S-12345"}'
Remove cluster nodes:
bk-cli bcs cluster_manager delete_nodes_from_cluster \
--clusterID BCS-K8S-12345 \
--nodes 10.0.0.1,10.0.0.2 \
--deleteMode terminate \
--isForce=true \
--operator admin
Create node group:
bk-cli bcs cluster_manager create_node_group -h
bk-cli bcs cluster_manager create_node_group -h --body-schema
bk-cli bcs cluster_manager create_node_group \
--body '{"name":"node-group","clusterID":"BCS-K8S-12345","region":"ap-guangzhou","autoScaling":{"vpcID":"vpc-id","zones":["ap-guangzhou-1"],"maxSize":1},"launchTemplate":{"CPU":1,"GPU":0,"Mem":1},"creator":"admin","nodeOS":"linux"}'
Reclaim node group nodes V2:
bk-cli bcs cluster_manager clean_nodes_in_group_v2 \
--nodeGroupID node-group-id \
--clusterID BCS-K8S-12345 \
--nodes 10.0.0.1,10.0.0.2 \
--operator admin
Troubleshooting
missing_param: check whether a required flag is missing, for example--clusterID、--nodeGroupID、--projectID、--body。required parameter --body is missing: first run the action's-h, and according toExamplesadd--body '<json>'。- body JSON parsing failed: compress the JSON into one line, or use a script to generate valid JSON before passing it to
--body。 - Unsure about body fields: run
bk-cli bcs cluster_manager <action> -h --body-schema。 - Request does not meet expectations: add
--dry-runto inspect the final request.