You can call the CreateCluster operation to create a serverless Kubernetes (ASK) cluster.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request syntax

POST /clusters HTTP/1.1
Content-Type:application/json
{
  "cluster_type" : "String",
  "profile": "String",
  "cluster_spec" : "String",
  "name" : "String",
  "kubernetes_version" : "String",
  "private_zone" : Boolean,
  "region_id" : "String",
  "endpoint_public_access" : Boolean,
  "service_discovery_types" : [ "String" ],
  "zoneid" : "String",
  "logging_type" : "String",
  "tags" : [ {
    "key" : "String",
    "value" : "String"
  } ],
  "deletion_protection" : Boolean,
  "service_cidr" : "String",
  "timezone" : "String",
  "addons" : [ {
    "name" : "String",
    "config" : "String",
    "disabled" : Boolean
  } ],
  "snat_entry" : Boolean,
  "vpcid" : "String",
  "vswitch_ids" : [ "String" ],
  "security_group_id" : "String"
}

Request parameters

Table 1. Request body parameters
Parameter Type Required Example Description
cluster_type String Yes ManagedKubernetes

The type of the cluster. If you set this parameter to ManagedKubernetes and the profile parameter to Serverless, an ASK cluster is created.

profile String Yes Serverless The profile of the cluster. If you set this parameter to Serverless and the cluster_type parameter to ManagedKubernetes, an ASK cluster is created.
cluster_spec String No ack.pro.small
The specification of the ASK cluster. Valid values:
  • ack.pro.small: professional ASK cluster
  • ack.standard: standard ASK cluster

Default value: ack.standard. If you leave this parameter empty, a standard ASK cluster is created.

For more information, see ASK Pro cluster overview.

name String Yes cluster-demo

The name of the cluster.

The name must be 1 to 63 characters in length, and can contain digits, letters, and hyphens (-). It cannot start with a hyphen (-).

kubernetes_version String No 1.16.9-aliyun.1

The Kubernetes version of the cluster. Container Service for Kubernetes (ACK) supports all open source Kubernetes versions. We recommend that you specify the latest Kubernetes version. If you do not set this parameter, the latest Kubernetes version is used.

You can create two types of clusters that run the latest Kubernetes version in the ACK console. If you want to create clusters that run earlier Kubernetes versions, use the API. For more information about Kubernetes versions that are supported by ACK, see Overview of Kubernetes versions supported by ACK.

private_zone Boolean No false Specifies whether to enable Alibaba Cloud DNS PrivateZone for service discovery. Valid values:
  • true: enables Alibaba Cloud DNS PrivateZone for service discovery.
  • false: disables Alibaba Cloud DNS PrivateZone for service discovery.
For more information, see Use the service discovery feature based on Alibaba Cloud DNS PrivateZone in ASK clusters.
region_id String Yes cn-beijing The ID of the region in which you want to deploy the cluster.
endpoint_public_access Boolean No true

Specifies whether to enable Internet access for the API server. Valid values:

  • true: enables Internet access for the API server.
  • false: disables Internet access for the API server. The API server is accessible only within the internal network.

Default value: true.

service_discovery_types Array of String No PrivateZone

The type of service discovery that is implemented in the ASK cluster.

  • CoreDNS: a standard service discovery component provided by open source Kubernetes. You must provision CoreDNS pods to use the DNS resolution service. By default, two elastic container instances are used. The specification of each instance is 0.25 vCores and 512 MiB of memory.
  • PrivateZone: a DNS resolution service provided by Alibaba Cloud. You must activate Alibaba Cloud DNS PrivateZone before you can use it for service discovery.

By default, this parameter is not specified.

zoneid String No cn-beiji****
The ID of the zone in which the cluster is deployed.
Notice If you do not set the vpcid or vswitch_ids parameter, you must configure the zoneid parameter.
logging_type String No SLS

Specifies whether to enable Log Service for the cluster. Set the value to SLS. This parameter takes effect only for ASK clusters.

tags Array of tag No [{"key": "env", "value": "prod"}] The labels that you want to add to the cluster. A label consists of the following elements:
  • key: the key of the label.
  • value: the value of the label.
deletion_protection Boolean No true

Specifies whether to enable deletion protection for the cluster. After deletion protection is enabled, the cluster cannot be deleted in the ACK console or by calling the API. Valid values:

  • true: enables deletion protection for the cluster.
  • false: disables deletion protection for the cluster.

Default value: false.

service_cidr String No 172.21.0.0/20

The CIDR block of Services. Valid values: 10.0.0.0/16-24, 172.16-31.0.0/16-24, and 192.168.0.0/16-24.

The CIDR block of Services cannot overlap with the CIDR block of the VPC (10.1.0.0/21) or the CIDR blocks of existing clusters in the VPC. You cannot modify the CIDR block of Services after the cluster is created.

By default, the CIDR block of Services is set to 172.19.0.0/20.

timezone String No Asia/Shanghai

The time zone of the cluster. For more information, see Time zones.

addons Array of addon No [{"name":"logtail-ds","config":"{"sls_project_name":"your_sls_project_name"}"}]

The components that you want to install in the cluster. Parameter description:

  • name: required. This parameter specifies the name of the component.
  • config: optional. If this parameter is left empty, no configurations are specified.
  • disabled: optional. This parameter specifies whether to disable automatic installation.

Network plug-in: required. Supported network plug-ins are Flannel and Terway. Select one of the plug-ins for the cluster.

  • Specify the Flannel plug-in in the following format: [{"name":"flannel","config":""}].
  • Specify the Terway plug-in in the following format: [{"name": "terway-eniip","config": ""}].

Volume plug-in: required. Supported volume plug-ins are CSI and FlexVolume.

  • Specify the CSI plug-in in the following format: [{"name":"csi-plugin","config": ""},{"name": "csi-provisioner","config": ""}].
  • Specify the FlexVolume plug-in in the following format: [{"name": "flexvolume","config": ""}].

Log Service component: optional.

Note If Log Service is disabled, you cannot use the cluster auditing feature.
  • To use an existing Log Service project, specify the component in the following format: [{"name": "logtail-ds","config": "{\"IngressDashboardEnabled\":\"true\",\"sls_project_name\":\"your_sls_project_name\"}"}].
  • To create a Log Service project, specify the component in the following format: [{"name": "logtail-ds","config": "{\"IngressDashboardEnabled\":\"true\"}"}].

Ingress controller: optional. By default, the nginx-ingress-controller component is installed in dedicated Kubernetes clusters.

  • To install nginx-ingress-controller and enable Internet access, specify the Ingress controller in the following format: [{"name":"nginx-ingress-controller","config":"{\"IngressSlbNetworkType\":\"internet\"}"}].
  • If you do not want to install nginx-ingress-controller, specify the component in the following format: [{"name": "nginx-ingress-controller","config": "","disabled": true}.

Event center: optional. By default, the event center feature is enabled. You can use Kubernetes event centers to store and query events, and configure alert rules. You can use the Logstores that are associated with Kubernetes event centers for free within 90 days. For more information, see Create and use an event center.

To enable the event center feature, specify the ack-node-problem-detector component in the following format: [{"name":"ack-node-problem-detector","config":"{\"sls_project_name\":\"

your_sls_project_name\"}"}].

snat_entry Boolean No true

Specifies whether to create a NAT gateway and configure Source Network Address Translation (SNAT) rules when the system creates the ASK cluster. Valid values:

  • true: automatically creates a NAT gateway and configures SNAT rules. This enables Internet access for the virtual private cloud (VPC) in which the cluster is deployed.
  • false: does not create a NAT gateway or configure SNAT rules. In this case, the cluster in the VPC cannot access the Internet.

Default value: false.

vpcid String No vpc-2zeik9h3ahvv2zz95**** The VPC in which you want to deploy the cluster. You must specify a VPC when you create a cluster.
Note If you specify the vpcid parameter, you must also specify the vswitch_ids parameter.
vswitch_ids Array of String No ["vsw-2ze97jwri7cei0mpw****"] The ID of the vSwitch. You can specify one to three vSwitches.
security_group_id String No sg-bp1bdue0qc1g7k****

The ID of the existing security group that you want to use for the cluster. You must set this parameter or the is_enterprise_security_group parameter. The nodes in the cluster are automatically added to the specified security group.

resource_group_id String No rg-acfm3mkrure**** The ID of the resource group to which the cluster belongs. You can use this parameter to isolate different clusters.

Response syntax

HTTP/1.1 200
Content-Type:application/json
{
  "cluster_id" : "String",
  "request_id" : "String",
  "task_id" : "String"
}

Response parameters

Table 2. Response body parameters
Parameter Type Example Description
cluster_id String cb95aa626a47740afbf6aa099b650****

The ID of the cluster.

request_id String 687C5BAA-D103-4993-884B-C35E4314A1E1

The ID of the request.

task_id String T-5a54309c80282e39ea00002f

The ID of the task.

Example 1: Create an ASK cluster in an automatically created VPC

Sample requests

POST /clusters HTTP/1.1
<Common request headers>
{
    "cluster_type":"ManagedKubernetes",
    "profile":"Serverless",
    "cluster_spec":"ack.standard",  
    "name":"test-ask",
    "region_id":"cn-hangzhou",
    "endpoint_public_access":false,
    "logging_type" : "SLS",
    "private_zone":false,
    "snat_entry":true,
    "tags":[
        {
            "key":"k-aa",
            "value":"v-aa"
        }
    ],
    "deletion_protection":false,
    "addons":[
        {
            "name":"logtail-ds"
        }
    ],
    "zoneid":"cn-hangzhou-i"
}

Sample responses

{
    "cluster_id": "cb95aa626a47740afbf6aa099b650****",
    "RequestId": "687C5BAA-D103-4993-884B-C35E4314A1E1",
    "task_id": "T-5a54309c80282e39ea00002f",
}

Example 2: Create an ASK cluster in an existing VPC

Sample requests

POST /clusters HTTP/1.1
<Common request headers>
{
    "cluster_type":"ManagedKubernetes",
    "profile":"Serverless",
    "cluster_spec":"ack.pro.small", 
    "name":"ask-cluster",
    "region_id":"cn-shenzhen",
    "endpoint_public_access":true,
    "logging_type": "SLS",
    "private_zone":true,
    "tags":[
        {
            "key":"tier",
            "value":"frontend"
        }
    ],
    "deletion_protection":true,
    "addons":[
        {
            "name":"logtail-ds"
        }
    ],
    "vpcid":"vpc-wz984yvbd6lck22z3****",
    "vswitch_ids":[
        "vsw-wz9uwxhawmtzg7u9h****"
    ],
    "security_group_id":"sg-wz9b86l4s7nthi1k****"
}

Sample responses

{
    "cluster_id": "cb95aa626a47740afbf6aa099b650****",
    "RequestId": "687C5BAA-D103-4993-884B-C35E4314A1E1",
    "task_id": "T-5a54309c80282e39ea00002f",
}

Error codes

For a list of error codes, visit the API Error Center.