Manage Serverless Kubernetes clusters using the Alibaba Cloud CLI
Updated at:
You can use the Alibaba Cloud command-line interface (CLI) to automatically create a Serverless Kubernetes cluster and retrieve cluster information.
About this tutorial
The following steps and examples are integrated into Alibaba Cloud Shell. Click Open in Cloud Shell to use the Alibaba Cloud CLI to create a Serverless Kubernetes cluster and retrieve cluster information.
When you complete this tutorial, the following resources are created by default:
- NAT Gateway
- Number of instances: 1
- Billing method: pay-as-you-go
Note For more information about billing, see Pay-as-you-go NAT Gateway.
Limits
Before you start this tutorial, make sure that you understand the following limits and meet the requirements:
- Make sure that you have enabled the following services:
- Alibaba Cloud Serverless Kubernetes is in public preview. You can apply to join the public preview and try Serverless Kubernetes for free.
- Make sure your account has a balance of at least CNY 100 and has completed identity verification.
- Each account has a default quota for the cloud resources that can be created. If you exceed the quota, the cluster creation fails. To increase your quota, submit a ticket.
- By default, you can create a maximum of 100 security groups per account.
- By default, you can create a maximum of 60 pay-as-you-go SLB instances per account.
- By default, you can create a maximum of 20 EIPs per account.
Create a Serverless Kubernetes cluster
Execute the following command to create a Serverless Kubernetes cluster:
aliyun cs POST /clusters --header "Content-Type=application/json" --body "$(cat create.json)"
The parameters for creating the Serverless Kubernetes cluster are saved in the create.json file. The code is as follows:
{
"cluster_type": "Ask",
"name": "example-serverless-kubernetes",
"region_id": "cn-shanghai",
"private_zone": false,
"vpc_id": "",
"vswitch_id": ""
}
You can customize your Serverless Kubernetes cluster using the following parameters:
cluster_type
- The cluster type. For a Serverless Kubernetes cluster, set this parameter to 'Ask'.
name
- The name of the cluster. The name can contain uppercase letters, lowercase letters, Chinese characters, digits, and hyphens.
region_id
- The ID of the region where you want to create the cluster.
private_zone
- Specifies whether to enable PrivateZone.
vpc_id
- The VPC ID. This parameter can be left empty. If you do not set this parameter, the system automatically creates a VPC with the 192.168.0.0/16 CIDR block. The system also automatically creates a NAT Gateway and configures SNAT rules in the VPC.
Note You must set both vpc_id and vswitch_id, or leave them both empty.
- The VPC ID. This parameter can be left empty. If you do not set this parameter, the system automatically creates a VPC with the 192.168.0.0/16 CIDR block. The system also automatically creates a NAT Gateway and configures SNAT rules in the VPC.
vswitch_id
- The vSwitch ID. This parameter can be left empty. If you do not set this parameter, the system automatically creates a vSwitch with the 192.168.0.0/16 CIDR block.
After the cluster is created, the following output is displayed in the console:
{
"cluster_id": "c61cf530524474386a7a******",
"request_id": "348D4C9C-9105-4A1B-A86E-******",
"task_id": "T-5ad724ab94a2b109e*****"
}
In the output, cluster_id is the unique ID of the cluster that you created.You can now log on to the Container Service console to view the Serverless Kubernetes cluster that you created using the Alibaba Cloud CLI.
Get information about a Serverless Kubernetes cluster
Execute the following command to query information about the cluster that you created.
aliyun cs GET /clusters/<cluster_id>
Note Replace <cluster_id> with the ID of the cluster that you want to query.
After the command is executed, the following output is displayed in the console:
{
"agent_version": "string",
"cluster_id": "string",
"created": "datetime",
"external_loadbalancer_id": "string",
"master_url": "string",
"name": "string",
"network_mode": "string",
"region_id": "string",
"security_group_id": "string",
"size": "numbers",
"state": "string",
"updated": "datetime",
"vpc_id": "string",
"vswitch_id": "string",
...
}
Is this page helpful?