All Products
Search
Document Center

Container Service for Kubernetes:CLI integration example

Last Updated:Mar 25, 2026

Alibaba Cloud CLI is a general-purpose command-line tool built on top of Alibaba Cloud APIs. Use it to manage and automate Container Service for Kubernetes (ACK) resources from a terminal. This topic walks through the full setup and shows you how to call DescribeClusterDetail to query cluster details.

Prerequisites

Before you begin, ensure that you have:

  • A RAM user with the AliyunCSReadOnlyAccess policy attached

  • An AccessKey pair created for that RAM user

  • The region ID of the ACK cluster you want to query

Important

Using your Alibaba Cloud root account to call APIs poses security risks. Create a RAM user and grant permissions based on the principle of least privilege. For supported system policies, see AliyunCSFullAccess and AliyunCSReadOnlyAccess.

Step 1: Install Alibaba Cloud CLI

Quickest option — use Cloud Shell. Cloud Shell comes with Alibaba Cloud CLI pre-installed and automatically configures identity credentials based on your logged-in account. No local setup required. See What is Cloud Shell?

To install locally, download the package for your operating system:

For more information, see What is Alibaba Cloud CLI?

Step 2: Configure Alibaba Cloud CLI

Configure your identity credentials in the AkProfile file using the AccessKey pair of your RAM user.

  1. Create a RAM user and an AccessKey pair for it. See Create a RAM user and Create an AccessKey pair.

  2. Attach the AliyunCSReadOnlyAccess policy to the RAM user. See Grant permissions to a RAM user.

  3. Get the region ID of the cluster. Alibaba Cloud CLI uses the specified region ID to call API operations. See Endpoints for supported regions.

    Note

    Pass --region <region-id> at call time to override the default region in your credential settings and environment variables. See Command line options for API calls.

  4. Configure your AccessKey credentials in the AkProfile configuration file. See Configuration examples.

For all supported credential types, see Credential types.

Step 3: Generate a CLI command

OpenAPI Explorer generates ready-to-run CLI commands so you don't have to construct them manually.

  1. Open the DescribeClusterDetail page in OpenAPI Explorer.

    image

  2. On the Parameters tab, fill in the required parameters.

  3. Click the CLI Example tab to view the generated command.

  4. Run or copy the command:

    • Click image to open Cloud Shell and run the command directly.

    • Click image to copy the command to the clipboard, then paste it into your local shell.

    Note

    - When running in a local shell, check parameter formats. See Parameter formats. - OpenAPI Explorer appends --region to the generated command by default. When present, this option overrides the region in your default credential settings and environment variable settings. Remove or keep it based on your needs.

Step 4: Call ACK API operations

List all supported API operations

Use the --help option to see every API operation available for ACK. For a categorized list, see List of operations by function.

aliyun cs --help

Expected output:

image

Query cluster details using DescribeClusterDetail

Call DescribeClusterDetail with the cluster ID to retrieve full cluster details. Replace cdde1f21ae22e483ebcb068a6eb7f**** with your cluster ID. For field descriptions, see DescribeClusterDetail.

aliyun cs GET /clusters/cdde1f21ae22e483ebcb068a6eb7f****

Expected output:

{
  "cluster_id": "c82e6987e2961451182edacd74faf****",
  "cluster_type": "Kubernetes",
  "created": "2019-11-25T15:50:20+08:00",
  "init_version": "1.16.6-aliyun.1",
  "current_version": "1.16.6-aliyun.1",
  "next_version": "1.18.8-aliyun.1",
  "deletion_protection": true,
  "docker_version": "19.03.5",
  "external_loadbalancer_id": "lb-2zehc05z3b8dwiifh****",
  "meta_data": "\\\"Addons\\\":***",
  "name": "cluster-demo",
  "network_mode": "vpc",
  "region_id": "cn-beijing",
  "resource_group_id": "rg-acfmyvw3wjm****",
  "security_group_id": "sg-25yq****",
  "container_cidr": "172.20.0.0/16",
  "service_cidr": "172.21.0.0/20",
  "proxy_mode": "ipvs",
  "timezone": "Asia/Shanghai",
  "node_cidr_mask": "26",
  "ip_stack": "ipv4",
  "cluster_domain": "cluster.local",
  "size": 5,
  "state": "running",
  "tags": [
    {
      "key": "env",
      "value": "prod"
    }
  ],
  "updated": "2020-01-13T23:01:03+08:00",
  "vpc_id": "vpc-2zecuu62b9zw7a7qn****",
  "vswitch_id": "vsw-2zete8s4qocqg0mf6****,vsw-2zete8s4qocqg0mf6****",
  "vswitch_ids": [
    "vsw-2zete8s4qocqg0mf6****"
  ],
  "subnet_cidr": "172.20.0.0/16",
  "zone_id": "cn-beijing-a",
  "master_url": "{\\\"intranet_api_server_endpoint\\\":\\\"https://192.168.0.251:6443\\\"***}",
  "private_zone": false,
  "profile": "Default",
  "cluster_spec": "ack.pro.small",
  "worker_ram_role_name": "KubernetesWorkerRole-ec87d15b-edca-4302-933f-c8a16bf0****",
  "maintenance_window": {
    "enable": false,
    "maintenance_time": "2020-10-15T12:31:00.000+08:00",
    "duration": "3h",
    "weekly_period": "Monday,Thursday",
    "recurrence": "FREQ=WEEKLY;INTERVAL=4;BYDAY=MO,TU"
  },
  "parameters": {
    "key": "WorkerImageId"
  },
  "operation_policy": {
    "cluster_auto_upgrade": {
      "enabled": true,
      "channel": "patch"
    }
  }
}
Note
  • If an API call returns an error, check that all input parameters and values are valid based on the error code.

  • For self-service diagnostics, go to the OpenAPI problem diagnosis page and enter the request ID or SDK error details.

What's next

References