すべてのプロダクト
Search
ドキュメントセンター

Container Service for Kubernetes:クラスターの管理

最終更新日:Jan 07, 2025

このトピックでは、クラスターを作成、スケールアウト、削除する方法、クラスターのステータスとノードを照会する方法など、基本的なクラスター操作を実行する方法の例を示します。

説明

クラスターの管理に使用する前に、Container Service for Kubernetes (ACK) SDKをインストールする必要があります。 詳細については、「ACK SDKのインストール」をご参照ください。

サンプルコード

// This file is auto-generated, don't edit it. Thanks.
package aliyun.com.alibabacloud.CS20151215;
import com.aliyun.tea.*;
public class Client {
    /**
     * Use your AccessKey ID and AccessKey secret to initialize the client.
     * @param accessKeyId
     * @param accessKeySecret
     * @param regionId
     * @param endpoint
     * @return Client
     * @throws Exception
     */
    public static com.aliyun.cs20151215.Client createClient(String accessKeyId, String accessKeySecret, String regionId) throws Exception {
        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config();      
        config.accessKeyId = accessKeyId;
        config.accessKeySecret = accessKeySecret;
        config.regionId = regionId;
        return new com.aliyun.cs20151215.Client(config);
    }
    /**
     * Create an ACK cluster.
     * @param client
     * @return CreateClusterResponse
     * @throws Exception
     */
    public static com.aliyun.cs20151215.models.CreateClusterResponse createCluster(com.aliyun.cs20151215.Client client) throws Exception {
        com.aliyun.cs20151215.models.CreateClusterRequest createClusterRequest = new com.aliyun.cs20151215.models.CreateClusterRequest()
                .setName("my-test-Kubernetes-cluster")
                .setTimeoutMins((long)60)
                .setClusterType("ManagedKubernetes")
                .setRegionId("cn-beijing")
                .setVpcid("vpc-2zegvl5etah5requ0****")
                .setContainerCidr("172.20.0.0/16")
                .setServiceCidr("172.21.0.0/20")
                .setLoginPassword("Test_1234")
                .setWorkerInstanceChargeType("PostPaid")
                .setWorkerInstanceTypes(java.util.Arrays.asList(
            "ecs.sn2.3xlarge"
        ))
                .setWorkerVswitchIds(java.util.Arrays.asList(
            "vsw-2ze48rkq464rsdts****"
        ))
                .setWorkerSystemDiskCategory("cloud_efficiency")
                .setWorkerSystemDiskSize(120)
                .setNumOfNodes(3)
                .setOsType("Linux");
        return client.createCluster(createClusterRequest);
    }
    /**
     * Query the status of an ACK cluster.
     * @param client
     * @param clusterId
     * @return DescribeClusterDetailResponse
     * @throws Exception
     */
    public static com.aliyun.cs20151215.models.DescribeClusterDetailResponse describeClusterDetail(com.aliyun.cs20151215.Client client, String clusterId) throws Exception {
        return client.describeClusterDetail(clusterId);
    }
    /**
     * Scale out an ACK cluster.
     * @param client
     * @param clusterId
     * @return ScaleOutClusterResponse
     * @throws Exception
     */
    public static com.aliyun.cs20151215.models.ScaleOutClusterResponse scaleOutCluster(com.aliyun.cs20151215.Client client, String clusterId) throws Exception {
        com.aliyun.cs20151215.models.ScaleOutClusterRequest scaleOutClusterRequest = new com.aliyun.cs20151215.models.ScaleOutClusterRequest()
                .setLoginPassword("Test_1234")
                .setVswitchIds(java.util.Arrays.asList(
            "vsw-uf684tfrpwup8gcsw****"
        ))
                .setWorkerInstanceTypes(java.util.Arrays.asList(
            "ecs.c5.xlarge"
        ))
                .setWorkerSystemDiskCategory("cloud_efficiency")
                .setWorkerSystemDiskSize(120L)
                .setCount(3L);
        return client.scaleOutCluster(clusterId, scaleOutClusterRequest);
    }
    /**
     * Query the nodes in an ACK cluster.
     * @param client
     * @param clusterId
     * @return DescribeClusterNodesResponse
     * @throws Exception
     */
    public static com.aliyun.cs20151215.models.DescribeClusterNodesResponse describeClusterNodes(com.aliyun.cs20151215.Client client, String clusterId) throws Exception {
        com.aliyun.cs20151215.models.DescribeClusterNodesRequest describeClusterNodesRequest = new com.aliyun.cs20151215.models.DescribeClusterNodesRequest()
                .setPageSize("18")
                .setPageNumber("1")
                .setNodepoolId("nodepool_id")
                .setState("running");
        return client.describeClusterNodes(clusterId, describeClusterNodesRequest);
    }
    /**
     * Delete an ACK cluster.
     * @param client
     * @param clusterId
     * @return DescribeClusterDetailResponse
     * @throws Exception
     */
    public static com.aliyun.cs20151215.models.DeleteClusterResponse deleteCluster(com.aliyun.cs20151215.Client client, String clusterId) throws Exception {
        com.aliyun.cs20151215.models.DeleteClusterRequest deleteClusterRequest = new com.aliyun.cs20151215.models.DeleteClusterRequest()
                .setRetainResources(java.util.Arrays.asList(
            "sg-2ze6ess9kho6fdn9****"
        ));
        return client.deleteCluster(clusterId, deleteClusterRequest);
    }
    public static void main(String[] args) throws Exception {
        // 1. Initialize the client.
        // Make sure that the following environment variables are specified: ALIBABA_CLOUD_ACCESS_KEY_ID, ALIBABA_CLOUD_ACCESS_KEY_SECRET, and ALIBABA_CLOUD_REGION_ID. 
        // If the project code is leaked, the AccessKey pair may be disclosed and security issues may occur in all resources that belong to your Alibaba Cloud account. The following sample code shows how to use environment variables to obtain an AccessKey pair and use the AccessKey pair to call operations of the ACK API. The sample code is for reference only. We recommend that you use Security Token Service (STS). For more information, see Configure credentials. 
        com.aliyun.cs20151215.Client client = Client.createClient(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"), System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"),System.getenv("ALIBABA_CLOUD_REGION_ID"));
        // 2. Create an ACK cluster.
        com.aliyun.cs20151215.models.CreateClusterResponse createClusterRes = Client.createCluster(client);
        String clusterId = createClusterRes.body.clusterId;
        // 3. Query the status of an ACK cluster.
        com.aliyun.cs20151215.models.DescribeClusterDetailResponse describeClusterDetailRes = Client.describeClusterDetail(client, clusterId);
        // 4. Scale out an ACK cluster when it is in the running state.
        while (true) {
            if (com.aliyun.teautil.Common.equalString(describeClusterDetailRes.body.state, "initial")) {
                // If the cluster is in the initial state, it indicates that the cluster has not been created. Set the sleep mode to 3 minutes and try again after the cluster wakes.
                com.aliyun.teautil.Common.sleep(180000);
            } else if (com.aliyun.teautil.Common.equalString(describeClusterDetailRes.body.state, "running")) {
                // Scale out the cluster after it is created.
                com.aliyun.cs20151215.models.ScaleOutClusterResponse scaleClusterRes = Client.scaleOutCluster(client, clusterId);
                com.aliyun.teaconsole.Client.log(scaleClusterRes.body.requestId);
                break;
            } else {
                // Exit if the cluster is in other states.
                return ;
            }
        }
        // 5. Query the nodes in an ACK cluster.
        com.aliyun.cs20151215.models.DescribeClusterNodesResponse describeClusterNodesRes = Client.describeClusterNodes(client, clusterId);
        java.util.Map<String, String> describeClusterNodesResHeaders = describeClusterNodesRes.headers;
        com.aliyun.teaconsole.Client.log(describeClusterNodesResHeaders.get("x-acs-request-id"));
        // 6. Delete an ACK cluster.
        com.aliyun.cs20151215.models.DeleteClusterResponse deleteClusterRes = Client.deleteCluster(client, clusterId);
        java.util.Map<String, String> deleteCLusterResHeaders = deleteClusterRes.headers;
        com.aliyun.teaconsole.Client.log(deleteCLusterResHeaders.get("x-acs-request-id"));
    }
}
  
   
# -*-コーディング: utf-8 -*-
# このファイルは自動生成されます。編集しないでください。 ありがとう
インポートsys
インポートリストの入力から
alibabacloud_cs20151215.clientからCSClientとしてのインポートクライアント
alibabacloud_tea_openapiからモデルをopen_api_modelsとしてインポートする
alibabacloud_cs20151215からモデルをcs_modelsとしてインポートする
alibabacloud_tea_util.clientインポートクライアントからUtilClientとして
alibabacloud_tea_console.clientからConsoleClientとしてのインポートクライアント
クラスのクライアント:
    def __init__(self):
        パス
    @staticmethod
    def create_client (
        access_key_id: str,
        access_key_secret: str、
        region_id: str、
    ) -> CSClient:
        """
        AccessKey IDとAccessKeyシークレットを使用して、クライアントを初期化します。
        @ param access_key_id:
        @ param access_key_secret:
        @ param region_id:
        @ paramエンドポイント:
        @return: Client
        @throws Exception
        """
        config = open_api_models.Config()
        config.access_key_id = access_key_id
        config.access_key_secret = access_key_secret
        config.region_id = region_id
        リターンCSClient(config)
    @staticmethod
    async def create_client_async (
        access_key_id: str,
        access_key_secret: str、
        region_id: str、
    ) -> CSClient:
        """
        AccessKey IDとAccessKeyシークレットを使用して、クライアントを初期化します。
        @ param access_key_id:
        @ param access_key_secret:
        @ param region_id:
        @ paramエンドポイント:
        @return: Client
        @throws Exception
        """
        config = open_api_models.Config()
        config.access_key_id = access_key_id
        config.access_key_secret = access_key_secret
        config.region_id = region_id
        リターンCSClient(config)
    @staticmethod
    def create_cluster (
        クライアント: CSClient、
    ) -> cs_models.CreateClusterResponse:
        """
        ACKクラスターを作成します。 
        @ paramクライアント:
        @ return: CreateClusterResponse
        @throws Exception
        """
        create_cluster_request = cs_models.CreateClusterRequest (
            name='my-test-Kubernetes-cluster',
            timeout_mins=60、
            cluster_type='ManagedKubernetes '、
            region_id='cn-beij' 、
            vpcid='vpc-2zegvl5etah5requ0 **** '、
            container_cidr='172.20.0.0/16 '、
            service_cidr='172.21.0.0/20 '、
            login_password='Test_1234 '、
            worker_instance_charge_type='PostPaid' 、
            worker_instance_types=[
                'ecs.sn2.3xlarge'
            ],
            worker_vswitch_ids=[
                'vsw-2ze48rkq464rsdts ****'
            ],
            worker_system_disk_category='cloud_efficiency' 、
            worker_system_disk_size=120、
            num_of_nodes=3、
            os_type='Linux'
        )
        return client.create_cluster(create_cluster_request)
    @staticmethod
    async def create_cluster_async (
        クライアント: CSClient、
    ) -> cs_models.CreateClusterResponse:
        """
        ACKクラスターを作成します。
        @ paramクライアント:
        @ return: CreateClusterResponse
        @throws Exception
        """
        create_cluster_request = cs_models.CreateClusterRequest (
            name='my-test-Kubernetes-cluster',
            timeout_mins=60、
            cluster_type='ManagedKubernetes '、
            region_id='cn-beij' 、
            vpcid='vpc-2zegvl5etah5requ0 **** '、
            container_cidr='172.20.0.0/16 '、
            service_cidr='172.21.0.0/20 '、
            login_password='Test_1234 '、
            worker_instance_charge_type='PostPaid' 、
            worker_instance_types=[
                'ecs.sn2.3xlarge'
            ],
            worker_vswitch_ids=[
                'vsw-2ze48rkq464rsdts ****'
            ],
            worker_system_disk_category='cloud_efficiency' 、
            worker_system_disk_size=120、
            num_of_nodes=3、
            os_type='Linux'
        )
        return await client.create_cluster_async(create_cluster_request)
    @staticmethod
    def describe_cluster_detail (
        クライアント: CSClient、
        cluster_id: str,
    ) -> cs_models.DescribeClusterDetailResponse:
        """
        ACKクラスターのステータスを照会します。
        @ paramクライアント:
        @ param cluster_id:
        @ return: DescribeClusterDetailResponse
        @throws Exception
        """
        return client.de scribe_cluster_detail(cluster_id)
    @staticmethod
    async def describe_cluster_detail_async ()
        クライアント: CSClient、
        cluster_id: str,
    ) -> cs_models.DescribeClusterDetailResponse:
        """
        ACKクラスターのステータスを照会します。
        @ paramクライアント:
        @ param cluster_id:
        @ return: DescribeClusterDetailResponse
        @throws Exception
        """
        return await client.de scribe_cluster_detail_async(cluster_id)
    @staticmethod
    def scale_out_cluster (
        クライアント: CSClient、
        cluster_id: str,
    ) -> cs_modelsScaleOutClusterResponse:
        """
        クラスターの作成後にスケールアウトします。
        @ paramクライアント:
        @ param cluster_id:
        @ return: ScaleOutClusterResponse
        @throws Exception
        """
        scale_out_cluster_request=cs_modelsScaleOutClusterRequest ()
            login_password='Test_1234 '、
            vswitch_ids=[
                'vsw-uf684tfrpwup8gcsw ****'
            ],
            worker_instance_types=[
                'ecs.c5.xlarge'
            ],
            worker_system_disk_category='cloud_efficiency' 、
            worker_system_disk_size=120、
            カウント=3
        )
        return client.scale_out_cluster(cluster_id, scale_out_cluster_request)
    @staticmethod
    async def scale_out_cluster_async (
        クライアント: CSClient、
        cluster_id: str,
    ) -> cs_modelsScaleOutClusterResponse:
        """
        クラスターの作成後にスケールアウトします。
        @ paramクライアント:
        @ param cluster_id:
        @ return: ScaleOutClusterResponse
        @throws Exception
        """
        scale_out_cluster_request=cs_modelsScaleOutClusterRequest ()
            login_password='Test_1234 '、
            vswitch_ids=[
                'vsw-uf684tfrpwup8gcsw ****'
            ],
            worker_instance_types=[
                'ecs.c5.xlarge'
            ],
            worker_system_disk_category='cloud_efficiency' 、
            worker_system_disk_size=120、
            カウント=3
        )
        return await client.scale_out_cluster_async(cluster_id, scale_out_cluster_request)
    @staticmethod
    def describe_cluster_nodes (
        クライアント: CSClient、
        cluster_id: str,
    ) -> cs_models.DescribeClusterNodesResponse:
        """
        ACKクラスター内のノードを照会します。
        @ paramクライアント:
        @ param cluster_id:
        @ return: DescribeClusterNodesResponse
        @throws Exception
        """
        describe_cluster_nodes_request = cs_models.DescribeClusterNodesRequest ()
            page_size='18' 、
            page_number='1' 、
            nodepool_id='nodepool_id' 、
            state='running'
        )
        return client.de scribe_cluster_nodes(cluster_id, describe_cluster_nodes_request)
    @staticmethod
    async def describe_cluster_nodes_async ()
        クライアント: CSClient、
        cluster_id: str,
    ) -> cs_models.DescribeClusterNodesResponse:
        """
        ACKクラスター内のノードを照会します。
        @ paramクライアント:
        @ param cluster_id:
        @ return: DescribeClusterNodesResponse
        @throws Exception
        """
        describe_cluster_nodes_request = cs_models.DescribeClusterNodesRequest ()
            page_size='18' 、
            page_number='1' 、
            nodepool_id='nodepool_id' 、
            state='running'
        )
        return await client.de scribe_cluster_nodes_async(cluster_id, describe_cluster_nodes_request)
    @staticmethod
    def delete_cluster (
        クライアント: CSClient、
        cluster_id: str,
    ) -> cs_models.DeleteClusterResponse:
        """
        ACKクラスターを削除します。
        @ paramクライアント:
        @ param cluster_id:
        @ return: DescribeClusterDetailResponse
        @throws Exception
        """
        delete_cluster_request = cs_models.DeleteClusterRequest ()
            retain_resources=[
                'sg-2ze6ess9kho6fdn9 ****'
            ]
        )
        return client.de lete_cluster(cluster_id, delete_cluster_request)
    @staticmethod
    async def delete_cluster_async (
        クライアント: CSClient、
        cluster_id: str,
    ) -> cs_models.DeleteClusterResponse:
        """
        ACKクラスターを削除します。
        @ paramクライアント:
        @ param cluster_id:
        @ return: DescribeClusterDetailResponse
        @throws Exception
        """
        delete_cluster_request = cs_models.DeleteClusterRequest ()
            retain_resources=[
                'sg-2ze6ess9kho6fdn9 ****'
            ]
        )
        return await client.de lete_cluster_async(cluster_id, delete_cluster_request)
    @staticmethod
    defメイン (
        args: リスト [str] 、
    ) -> なし:
        # 1. クライアントを初期化します。
        # 次の環境変数が指定されていることを確認します。 
        # プロジェクトコードが漏洩した場合、AccessKeyペアが公開され、Alibaba Cloudアカウントに属するすべてのリソースでセキュリティ上の問題が発生する可能性があります。 次のサンプルコードは、環境変数を使用してAccessKeyペアを取得し、AccessKeyペアを使用してACK APIの操作を呼び出す方法を示しています。 このサンプルコードは参考用です。 STSの使用を推奨します。 詳細については、「資格情報の設定」をご参照ください。 
        client = Client.create_client(os.environ['ALIBABA_CLOUD_ACCESS_KEY_ID '], os.environ['ALIBABA_CLOUD_ACCESS_KEY_SECRET']], os.environ['ALIBABA_CLOUD_REGION_ID '])
        # 2. ACKクラスターを作成します。
        create_cluster_res = Client.create_cluster (クライアント)
        cluster_id = create_cluster_res.body.cluster_id
        # 3. ACKクラスターのステータスを照会します。
        describe_cluster_detail_res = Client.de scribe_cluster_detail (クライアント、cluster_id)
        # 4. ACKクラスターが実行中の状態でスケールアウトします。
        while True:
            UtilClient.equal_string(describe_cluster_detail_res.body.state, 'initial'):
                # クラスターが初期状態の場合は、クラスターが作成されていないことを示します。 スリープモードを3分に設定し、クラスターの起動後に再試行します。
                UtilClient.sleep(180000)
            elif UtilClient.equal_string(describe_cluster_detail_res.body.state, 'running'):
                # ACKクラスターの作成後にスケールアウトします。
                scale_cluster_res = Client.scale_out_cluster (クライアント、cluster_id)
                ConsoleClient.log(scale_cluster_res.body.request_id)
                break
            else:
                # ACKクラスターが他の状態の場合は終了します。
                リターン
        #5. ACKクラスター内のノードを照会します。
        describe_cluster_nodes_res = Client.de scribe_cluster_nodes (クライアント、cluster_id)
        describe_cluster_nodes_res_headers = describe_cluster_nodes_res.headers
        ConsoleClient.log(describe_cluster_nodes_res_headers.get('x-acs-request-id'))
        #6. ACKクラスターを削除します。
        delete_cluster_res = Client.de lete_cluster (クライアント、cluster_id)
        delete_cluster_res_headers = delete_cluster_res.headers
        ConsoleClient.log(delete_cluster_res_headers.get('x-acs-request-id'))
    @staticmethod
    async def main_async (
        args: リスト [str] 、
    ) -> なし:
        # 1. クライアントを初期化します。
        # 次の環境変数が指定されていることを確認します。 
        # プロジェクトコードが漏洩した場合、AccessKeyペアが公開され、Alibaba Cloudアカウントに属するすべてのリソースでセキュリティ上の問題が発生する可能性があります。 次のサンプルコードは、環境変数を使用してAccessKeyペアを取得し、AccessKeyペアを使用してACK APIの操作を呼び出す方法を示しています。 このサンプルコードは参考用です。 STSの使用を推奨します。 詳細については、「資格情報の設定」をご参照ください。 
        client = await Client.create_client_async(os.environ['ALIBABA_CLOUD_ACCESS_KEY_ID '], os.environ['ALIBABA_CLOUD_ACCESS_KEY_SECRET']], os.environ['ALIBABA_CLOU_REGION_ID '])
        # 2. ACKクラスターを作成します。
        create_cluster_res = await Client.create_cluster_async (クライアント)
        cluster_id = create_cluster_res.body.cluster_id
        # 3. ACKクラスターのステータスを照会します。
        describe_cluster_detail_res = await Client.de scribe_cluster_detail_async (クライアント、cluster_id)
        # 4. ACKクラスターが実行中の状態でスケールアウトします。
        while True:
            UtilClient.equal_string(describe_cluster_detail_res.body.state, 'initial'):
                # クラスターが初期状態の場合は、クラスターが作成されていないことを示します。 スリープモードを3分に設定し、クラスターの起動後に再試行します。
                await UtilClient.sleep_async(180000)
            elif UtilClient.equal_string(describe_cluster_detail_res.body.state, 'running'):
                # ACKクラスターの作成後にスケールアウトします。
                scale_cluster_res = await Client.scale_out_cluster_async (クライアント、cluster_id)
                ConsoleClient.log(scale_cluster_res.body.request_id)
                break
            else:
                # ACKクラスターが他の状態の場合は終了します。
                リターン
        #5. ACKクラスター内のノードを照会します。
        describe_cluster_nodes_res = await Client.de scribe_cluster_nodes_async (クライアント、cluster_id)
        describe_cluster_nodes_res_headers = describe_cluster_nodes_res.headers
        ConsoleClient.log(describe_cluster_nodes_res_headers.get('x-acs-request-id'))
        #6. ACKクラスターを削除します。
        delete_cluster_res = await Client.de lete_cluster_async (クライアント、cluster_id)
        delete_cluster_res_headers = delete_cluster_res.headers
        ConsoleClient.log(delete_cluster_res_headers.get('x-acs-request-id'))
if __name__ ='__main__':
    Client.main(sys.argv[1:]) 
// このファイルは自動生成されており、編集しないでください。 ありがとう
パッケージメイン
import (import (import)
  "os"
  cs "github.com/alibabacloud-go/cs-20151215/v2/client"
  openapi「github.com/alibabacloud-go/darabonba-openapi/client」
  util "github.com/alibabacloud-go/tea-utils/service"
  コンソール「github.com/alibabacloud-go/tea-console/client」
  「github.com/alibabacloud-go/tea/tea」
)
/**
 * AccessKey IDとAccessKeyシークレットを使用してクライアントを初期化します。 
 * @ param accessKeyId
 * @ param accessKeySecret
 * @ param regionId
 * @ paramエンドポイント
 * @ returnクライアント
 * @ が例外をスロー
 * /
func CreateClient (accessKeyId * string, accessKeySecret * string, regionId * string) (_result * cs.Client, _err error) {
  config := &openapi.Config{}
  config.AccessKeyId = accessKeyId
  config.AccessKeySecret = accessKeySecret
  config.RegionId = regionId
  _result = &cs.Client{}
  _result, _err = cs.NewClient(config)
  return _result, _err
}
/**
 * ACKクラスターを作成します。 
 * @param client
 * @ return CreateClusterResponse
 * @ が例外をスロー
 * /
func CreateCluster (client * cs.Client) (_result * cs.CreateClusterResponse, _err error) {
  createClusterRequest := &cs.CreateClusterRequest {
    // クラスターの名前。 
    名前: tea.String("my-test-Kubernetes-cluster") 、
    // システムがACKクラスターを作成するためのタイムアウト期間。 
    TimeoutMins: tea.Int64(60) 、
    // クラスタータイプ。 この例では、値はManagedKubernetesに設定されています。 
    ClusterType: tea.String("ManagedKubernetes") 、
    // リージョン。 
    RegionId: tea.String("cn-beijing") 、
    // クラスターが存在する仮想プライベートクラウド (VPC) のID。 
    Vpcid: tea.String("vpc-2zegvl5etah5requ0 ****") 、
    // ポッドCIDRブロック。 
    ContainerCidr: tea.String("172.20.0.0/16") 、
    // サービスCIDRブロック。 
    ServiceCidr: tea.String("172.21.0.0/20") 、
    // ワーカーノードのSSHパスワード。 SSH認証またはキーペア認証を選択できます。 
    LoginPassword: tea.String("Test_1234") 、
    // ワーカーノードの課金方法。 有効な値: PrePaidとPostPaid。 
    WorkerInstanceChargeType: tea.String("PostPaid") 、
    // ワーカーノードのインスタンスタイプ。 複数のインスタンスタイプを指定できます。 
    WorkerInstanceTypes: []* string{tea.String("ecs.sn2.3xlarge")} 、
    // 1つ以上のvSwitchのID。 1〜5つのvSwitchを指定できます。 
    WorkerVswitchIds: []* string{tea.String("vsw-2ze48rkq464rsdts ****")} 、
    // ワーカーノードにマウントされているシステムディスクのタイプ。 
    WorkerSystemDiskCategory: tea.String("cloud_efficiency") 、
    // ワーカーノードにマウントされているシステムディスクのサイズ。 
    WorkerSystemDiskSize: tea.Int64(120) 、
    // ワーカーノードの数。 
    NumOfNodes: tea.Int64(3) 、
    // ポッドを実行するノードのオペレーティングシステム。 LinuxまたはWindowsオペレーティングシステムを指定できます。 
    OsType: tea.String("Linux") 、
  }
  _result = &cs.CreateClusterResponse{}
  _body, _err := client.CreateCluster(createClusterRequest)
  if _err! =nil {
    return _result, _err
  }
  _result = _body
  return _result, _err
}
/**
 * ACKクラスターのステータスを照会します。
 * @param client
 * @ param clusterId
 * @ return DescribeClusterDetailResponse
 * @ が例外をスロー
 * /
func DescribeClusterDetail (client * cs.Client, clusterId * string) (_result * cs.DescribeClusterDetailResponse, _err error) {
  _result = &cs.DescribeClusterDetailResponse{}
  _body, _err := client.DescribeClusterDetail(clusterId)
  if _err! =nil {
    return _result, _err
  }
  _result = _body
  return _result, _err
}
/**
 * ACKクラスターをスケールアウトします。
 * @param client
 * @ param clusterId
 * @ return ScaleOutClusterResponse
 * @ が例外をスロー
 * /
func ScaleOutCluster (client * cs.Client, clusterId * string) (_result * cs.ScaleOutClusterResponse, _errエラー) {
  scaleOutClusterRequest := &cs.ScaleOutClusterRequest {
    // ワーカーノードへのログインに使用されるキーペアの名前。 SSH認証またはキーペア認証を選択できます。
    LoginPassword: tea.String("Test_1234") 、
    // 1つ以上のvSwitchのID。 1〜3つのvSwitchを指定できます。
    VswitchIds: []* string{tea.String("vsw-uf684tfrpwup8gcsw ****")} 、
    // ワーカーノードのインスタンスタイプ。 複数のインスタンスタイプを指定できます。
    WorkerInstanceTypes: []* string{tea.String("ecs.c5.xlarge")} 、
    // ワーカーノードにマウントされているシステムディスクのサイズ。
    WorkerSystemDiskCategory: tea.String("cloud_efficiency") 、
    // ワーカーノードにマウントされているシステムディスクのサイズ。
    WorkerSystemDiskSize: tea.Int64(120) 、
    // ACKクラスターに追加されるノードの数。
    カウント: tea Int64(3) 、
  }
  _result = &cs.ScaleOutClusterResponse{}
  _body, _err := client.ScaleOutCluster(clusterId, scaleOutClusterRequest)
  if _err! =nil {
    return _result, _err
  }
  _result = _body
  return _result, _err
}
/**
 * ACKクラスター内のノードを照会します。
 * @param client
 * @ param clusterId
 * @ return DescribeClusterNodesResponse
 * @ が例外をスロー
 * /
func DescribeClusterNodes (client * cs.Client, clusterId * string) (_result * cs.DescribeClusterNodesResponse, _err error) {
  describeClusterNodesRequest := &cs.DescribeClusterNodesRequest {
    // 各ページで返されるエントリの数。 このパラメーターはオプションです。
    PageSize: tea.String("18") 、
    // 返すページの番号。 このパラメーターはオプションです。
    ページ番号: tea.String("1") 、
    // ノードプールID。 このパラメーターはオプションです。
    NodepoolId: tea.String("nodepool_id") 、
    // ノードプールのステータス。 
    状態: お茶文字列 ("ランニング") 、
  }
  _result = &cs.DescribeClusterNodesResponse{}
  _body, _err := client.DescribeClusterNodes(clusterId, describeClusterNodesRequest)
  if _err! =nil {
    return _result, _err
  }
  _result = _body
  return _result, _err
}
/**
 * ACKクラスターを削除します。
 * @param client
 * @ param clusterId
 * @ return DescribeClusterDetailResponse
 * @ が例外をスロー
 * /
func DeleteCluster (client * cs.Client, clusterId * string) (_result * cs.DeleteClusterResponse, _err error) {
  deleteClusterRequest := &cs.DeleteClusterRequest {
    // ACKクラスターが削除された後に保持されるリソース。 このパラメーターはオプションです。
    保持リソース: []* string{tea.String("sg-2ze6ess9kho6fdn9 ****")} 、
  }
  _result = &cs.DeleteClusterResponse{}
  _body, _err := client.DeleteCluster(clusterId, deleteClusterRequest)
  if _err! =nil {
    return _result, _err
  }
  _result = _body
  return _result, _err
}
func_main (args []* string) (_errエラー) {
  // 1. クライアントを初期化します。
  // 次の環境変数が指定されていることを確認します。 
  // プロジェクトコードが漏洩した場合、AccessKeyペアが公開され、Alibaba Cloudアカウントに属するすべてのリソースでセキュリティ上の問題が発生する可能性があります。 次のサンプルコードは、環境変数を使用してAccessKeyペアを取得し、AccessKeyペアを使用してACK APIの操作を呼び出す方法を示しています。 このサンプルコードは参考用です。 STSの使用を推奨します。 詳細については、「資格情報の設定」をご参照ください。 
  client, _err := CreateClient(tea.String(os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_ID")) 、tea.String(os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET")) 、tea.String(os.Getenv("ALIBABA_CLOUD_REGION_ID"))))
  if _err! =nil {
    _errを返す
  }
  // 2. ACKクラスターを作成します。
  createClusterRes, _err := CreateCluster (クライアント)
  if _err! =nil {
    _errを返す
  }
  clusterId := createClusterRes.Body.ClusterId
  // 3. ACKクラスターのステータスを照会します。
  describeClusterDetailRes, _err := DescribeClusterDetail (クライアント、clusterId)
  if _err! =nil {
    _errを返す
  }
  // 4. ACKクラスターが実行中の状態でスケールアウトします。
  true {
    if tea.BoolValue(util.EqualString(describeClusterDetailRes.Body.State, tea.String("initial"))) {
      // クラスターが初期状態の場合、クラスターが作成されていないことを示します。 スリープモードを3分に設定し、クラスターの起動後に再試行します。
      _err = util.Sleep(tea.Int(180000))
      if _err! =nil {
        _errを返す
      }
    } else if tea.BoolValue(util.EqualString(describeClusterDetailRes.Body.State, tea.String("running"))) {
      // クラスターの作成後にスケールアウトします。
      scaleClusterRes、_err := ScaleOutCluster (クライアント、clusterId)
      if _err! =nil {
        _errを返す
      }
      console.Log(scaleClusterRes.Body.RequestId)
      break
    } else {
      // クラスターが他の状態の場合は終了します。
      _errを返す
    }
  }
  // 5. ACKクラスター内のノードを照会します。
  describeClusterNodesRes, _err := DescribeClusterNodes(client, clusterId)
  if _err! =nil {
    _errを返す
  }
  describeClusterNodesResHeaders := describeClusterNodesRes.Headers
  console.Log(describeClusterNodesResHeaders["x-acs-request-id"])
  // 6. ACKクラスターを削除します。
  deleteClusterRes, _err := DeleteCluster(client, clusterId)
  if _err! =nil {
    _errを返す
  }
  deleteCLusterResHeaders := deleteClusterRes.Headers
  console.Log(deleteCLusterResHeaders["x-acs-request-id"])
  _errを返す
}
func main() {
  err := _main(tea.StringSlice(os.Args))
  if err! =nil {
    panic(err)
  }
} 
static async main(args: string[]): Promise<void> {
    // 1. クライアントを初期化します。
    // 次の環境変数が指定されていることを確認します。 
    // プロジェクトコードが漏洩した場合、AccessKeyペアが公開され、Alibaba Cloudアカウントに属するすべてのリソースでセキュリティ上の問題が発生する可能性があります。 次のサンプルコードは、環境変数を使用してAccessKeyペアを取得し、AccessKeyペアを使用してACK APIの操作を呼び出す方法を示しています。 このサンプルコードは参考用です。 STSの使用を推奨します。 詳細については、「資格情報の設定」をご参照ください。 
    let client = await Client.createClient(process.env['ALIBABA_CLOUD_ACCESS_KEY_ID '] 、process.env['ALIBABA_CLOUD_ACCESS_KEY_SECRET']] 、process.env['ALIBABA_CLOUD_REGION_ID ']);
    // 2. ACKクラスターを作成します。
    let createClusterRes = await Client.createCluster (クライアント);
    let clusterId = createClusterRes.body.clusterId;

    // 3. ACKクラスターのステータスを照会します。
    describeClusterDetailRes = await Client.de scribeClusterDetail (クライアント、clusterId!);
    // 4. ACKクラスターが実行中の状態でスケールアウトします。
    一方、(TRUE){
      if (Util.equalString(describeClusterDetailRes.body.state, "initial")) {
        // クラスターが初期状態の場合、クラスターが作成されていないことを示します。 スリープモードを3分に設定し、クラスターの起動後に再試行します。
        wait Util.sleep(180000);
      } else if (Util.equalString(describeClusterDetailRes.body.state, "running")) {
        // クラスターの作成後にスケールアウトします。
        let scaleClusterRes = await Client.scaleOutCluster(client, clusterId!);
        Console.log(scaleClusterRes.body.requestId);
        break;
      } else {
        // クラスターが他の状態の場合は終了します。
        return ;
      }
    }
    // 5. ACKクラスター内のノードを照会します。
    describeClusterNodesRes = await Client.de scribeClusterNodes (クライアント、clusterId!);
    let describeClusterNodesResHeaders = describeClusterNodesRes.headers;
    Console.log(describeClusterNodesResHeaders["x-acs-request-id"]);
    // 6. ACKクラスターを削除します。
    let deleteClusterRes = await Client.de leteCluster(client, clusterId!);
    let deleteCLusterResHeaders = deleteClusterRes.headers;
    Console.log(deleteCLusterResHeaders["x-acs-request-id"]);
  }