All Products
Search
Document Center

Container Service for Kubernetes:Create an ACK serverless cluster by calling Alibaba Cloud APIs

Last Updated:Oct 16, 2024

You can call the CreateCluster operation to create a Container Service for Kubernetes (ACK) Serverless cluster.

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 parameters

Parameter

Type

Required

Example

Description

cluster_type

String

Yes

ManagedKubernetes

The type of the cluster. Set the value to ManagedKubernetes. In this case, if you set the profile parameter to Serverless, an ACK Serverless cluster is created.

profile

String

Yes

Serverless

The identifier of the cluster. If you set this parameter to Serverless and the cluster_type parameter to ManagedKubernetes, an ACK Serverless cluster is created.

cluster_spec

String

No

ack.pro.small

The type of the ACK Serverless cluster. Valid values:

  • ack.pro.small: a professional ACK Serverless cluster.

  • ack.standard: a standard ACK Serverless cluster.

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

For more information, see ACK Serverless Pro cluster overview.

name

String

Yes

cluster-demo

The cluster name.

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

kubernetes_version

String

No

1.30.1-aliyun.1

The Kubernetes version of the cluster. ACK supports all open source Kubernetes versions. We recommend that you specify the latest Kubernetes version. If you do not specify 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, call API operations. For more information about Kubernetes versions that are supported by ACK, see Support for Kubernetes versions.

private_zone

Boolean

No

false

Specifies whether to enable service discovery based on Alibaba Cloud DNS PrivateZone. Valid values:

  • true: enables service discovery based on Alibaba Cloud DNS PrivateZone.

  • false: disables service discovery based on Alibaba Cloud DNS PrivateZone.

For more information, see Enable service discovery based on Alibaba Cloud DNS PrivateZone.

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 allow the cluster to access the API server over the Internet. Valid values:

  • true: allows the cluster to access the API server over the Internet.

  • false: does not allow the cluster to access the API server over the Internet. In this case, the cluster can access the API server only over the specified virtual private cloud (VPC).

Default value: true.

service_discovery_types

Array of String

No

PrivateZone

The type of service discovery that is implemented in the ACK Serverless cluster. Valid values:

  • CoreDNS: a Kubernetes-native standard service discovery component. You must deploy a set of containers to use the DNS resolution service. By default, two elastic container instances (ECIs) that have 0.25 CPU cores and 512 MiB of memory are used.

  • 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 resides.

Important

If you do not specify the vpc_id or vswitch_ids parameter, you must specify the zoneid parameter.

logging_type

String

No

SLS

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

tags

Array of tag

No

[{"key": "env", "value": "prod"}]

The tags that you want to add to the cluster. A tag consists of the following elements:

  • key: the tag key.

  • value: the tag value.

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 API operations. 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 Service CIDR block. Valid values: 10.0.0.0/16-24, 172.16-31.0.0/16-24, and 192.168.0.0/16-24.

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

Default value: 172.19.0.0/20.

timezone

String

No

Asia/Shanghai

The time zone of the cluster. For more information, see Supported 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. You can specify the following parameters:

  • name: required. This parameter indicates the name of the component.

  • config: optional. If this parameter is left empty, no configurations are required.

  • disabled: optional. This parameter specifies whether to disable automatic installation.

Network plug-in: required. You can select Flannel or Terway when you create 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: optional. Set the value to csi.

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

Log Service component: optional.

Note

If Simple Log Service is not enabled for the cluster, you cannot use the cluster auditing feature.

  • To use an existing Simple 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 Simple 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 ACK dedicated 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 alerts. You can use the Logstores that are associated with Kubernetes event centers free of charge 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 you create the ACK Serverless cluster. Valid values:

  • true: automatically creates a NAT gateway and configures SNAT rules. If you set this parameter to true, the cluster in the VPC can access the Internet.

  • false: does not create a NAT gateway or configure SNAT rules. If you set this parameter to false, 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 the 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 IDs of vSwitches. 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 specify 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 parameters

Parameter

Type

Example

Description

cluster_id

String

cb95aa626a47740afbf6aa099b650****

The cluster ID.

request_id

String

687C5BAA-D103-4993-884B-C35E4314A1E1

The request ID.

task_id

String

T-5a54309c80282e39ea00002f

The task ID.

Example 1: Create an ACK Serverless cluster in a VPC that is automatically created

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 ACK Serverless 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, see Service error codes.