You can call CreateCluster to create a managed Kubernetes cluster that contains a specified number of nodes.

Request information

Request line

POST /clusters HTTP/1.1 

Custom request headers

No custom request headers are used. For more information, see Public request headers.

Request body

Note You must set parameters correctly. Otherwise, you may fail to create the cluster. When you create a cluster in the Container Service console, you can click Generate API Request Parameters on the Create Kubernetes Cluster page to view all parameters. For more information, see Generate API parameters.
{
"disable_rollback":"Specifies whether to retain all resources if the operation fails.",
"name":"The name of the cluster.",
"timeout_mins":"The timeout interval for creating a cluster.",
"cluster_type":"The type of the cluster. Set this parameter to ManagedKubernetes.",
"region_id":"The ID of the region.",
"vpcid": "VPC ID",
"worker_vswitch_ids":"The IDs of VSwitches. Specify one to three VSwitch IDs.",
"container_cidr":"The CIDR block of pods.",
"service_cidr":"The service CIDR block.", R",
"cloud_monitor_flags":"Specifies whether to install the CloudMonitor agent.",
"login_password":"The SSH logon password. Set login_password or key_pair.",
"key_pair":"The name of the key pair. You must set key_pair or login_password.",
"worker_instance_charge_type":"The billing method of worker nodes. Valid values: PrePaid and PostPaid.",
"worker_period_unit":"The unit of the subscription duration of worker nodes. Valid values: Month and Year. This parameter takes effect only if worker_instance_charge_type is set to PrePaid.",
"worker_period":"The subscription duration of worker nodes. This parameter takes effect only if worker_instance_charge_type is set to PrePaid.",
"worker_auto_renew":"Specifies whether to enable auto renewal for worker nodes. Valid values: true and false.",
"worker_auto_renew_period":"The auto renewal period for worker nodes.",
"worker_instance_types":"The ECS instance types of worker nodes.", ",
"worker_system_disk_category":"The system disk type of worker nodes.",
"worker_system_disk_size":"The system disk size of a worker node.",
"worker_data_disk":"Specifies whether to mount data disks to worker nodes. Valid values: true and false.",
"worker_data_disks":"The data disk configurations of worker nodes.",
"num_of_nodes":"The number of worker nodes.",
"snat_entry":"Specifies whether to enable Source Network Address Translation (SNAT).",
"endpoint_public_access":"Specifies whether to enable Internet access to the endpoint of the cluster.",
"proxy_mode":"The kube-proxy mode. Valid values: iptables and ipvs.",
"addons":"The add-ons to be installed for the cluster. This parameter must be an array.", 
"tags":"The tags of the cluster. This parameter must be an array.",
"security_group_id":"The ID of the security group to which the ECS instances in the cluster belong.",
"taints":"The taints to be added to nodes in the cluster. This parameter must be an array."
"cpu_policy":"The CPU policy. Valid values: static and none.",
"runtime":"The container runtime. Default value: docker.",
"platform":"The architecture of the nodes that run pods.",
"os_type":"The operating system of the nodes that run pods. For example, Linux and Windows.",
"node_cidr_mask":"The prefix length of the node IP address.",
"kubernetes_version":"The version of the cluster. The default value is the latest version.",
"deletion_protection":"Specifies whether to enable cluster deletion protection. After this option is enabled, the cluster cannot be deleted by operations in the console or API operations."
}
Table 1. Request body parameters
Parameter Type Required Description
cluster_type string Yes The type of the cluster.
key_pair string Yes The name of the key pair. You must specify login_password or key_pair.
login_password string Yes The SSH logon password. The password must be 8 to 30 characters in length and contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. You must specify login_password or key_pair.
name string Yes The name of the cluster. The name can contain uppercase letters, lowercase letters, Chinese characters, digits, and hyphens (-).
num_of_nodes int Yes The number of worker nodes. Valid values: 0 to 100.
region_id string Yes The ID of the region where the cluster is deployed.
snat_entry bool Yes Specifies whether to enable SNAT. If the VPC is automatically created, set the value to true. If an existing VPC is specified, set the value based on whether the VPC has Internet access.
vswitch_ids list Yes The IDs of VSwitches. Specify one to three VSwitch IDs.
worker_system_disk_category string Yes The system disk type of worker nodes.
worker_system_disk_size int Yes The system disk size of a worker node.
addons list No The add-ons to be installed for the cluster.
  • Add-ons parameters:
    • name: Required. The name of the add-on.
    • version: Optional. If you do not specify this parameter, the latest version is used.
    • config: Optional.
  • Network plug-in: Select Flannel or Terway.
  • Log Service: Optional. If Log Service is disabled, the cluster audit feature is unavailable.
  • Ingress: The nginx-ingress-controller component is installed by default.
container_cidr string No The CIDR block of containers. This CIDR block cannot overlap with that of the VPC. If the VPC is automatically created by the system, the CIDR block of containers is set to 172.16.0.0/16.
cloud_monitor_flags bool No Specifies whether to install the CloudMonitor agent.
disable_rollback bool No Specifies whether to retain all resources if the operation fails. Valid values:
  • true: retains the resources.
  • false: releases the resources.
We recommend that you use the default value.
public_slb bool No Specifies whether to enable Internet access to the API server. Valid values:
  • true: enables Internet access to the API server. Default value: true.
  • false: disables Internet access to the API server. The API server allows requests from the internal network only.
Note The parameter is obsolete and replaced by the endpoint_public_access parameter.
proxy_mode string No The kube-proxy mode. Valid values: iptables and ipvs. Default value: iptables.
endpoint_public_access bool No Specifies whether to enable Internet access to the API server. Valid values:
  • true: enables Internet access to the API server. Default value: true.
  • false: disables Internet access to the API server. The API server allows requests from the internal network only.
security_group_id string No The ID of the security group to which the ECS instances in the cluster belong.
service_cidr string No The CIDR block of services. This CIDR block cannot overlap with that of the VPC or containers. If the VPC is automatically created by the system, the CIDR block of services is set to 172.19.0.0/20.
tags list No The tags of the cluster.
  • key: the name of the tag.
  • value: the value of the tag.
taints list No The taints that are added to nodes to ensure appropriate scheduling of pods. If a pod has a toleration that matches the taint on a node, this pod can be scheduled to the node.
timeout_mins int No The timeout period in minutes during which a resource creation operation must be completed. Default value: 60.
vpcid string Yes You must specify the VPC ID.
Note You can specify both the vpcid and vswitchid parameters.
worker_auto_renew bool No Specifies whether to enable auto renewal for worker nodes. Valid values:
  • true: enables auto renewal.
  • false: disables auto renewal.
worker_auto_renew_period int No The auto renewal period for worker nodes. This parameter takes effect and is required only if worker_instance_charge_type is set to PrePaid. If worker_period_unit is set to Month, valid values of worker_auto_renew_period include 1, 2, 3, 6, and 12.
worker_data_disk string No Specifies whether to mount data disks to worker nodes.
  • true: mounts data disks to worker nodes.
  • false: does not mount data disks to worker nodes.
worker_data_disks list No The data disk configurations of worker nodes, such as the disk type and disk size. This parameter takes effect only if worker_data_disk is set to true.
  • category: the type of data disks. Valid values:
    • cloud: basic disks.
    • cloud_efficiency: ultra disks.
    • cloud_ssd: SSDs.
  • size: the size of a data disk. Unit: GiB.
worker_data_disk_category int No The type of data disks.
Note This parameter is obsolete and replaced by the category parameter in worker_data_disks.
worker_data_disk_size string No The size of a data disk.
Note This parameter is obsolete and replaced by the size parameter in worker_data_disks.
worker_instance_charge_type string No The billing method of worker nodes. Valid values:
  • PrePaid: subscription.
  • PostPaid: pay-as-you-go.
worker_period int No The subscription duration of worker nodes. This parameter takes effect and is required only if worker_instance_charge_type is set to PrePaid. If worker_period_unit is set to Month, valid values of worker_period include 1, 2, 3, 6, and 12.
worker_period_unit string No The unit of the subscription duration. This parameter is required if worker_instance_charge_type is set to PrePaid.
Note A value of Month indicates that the subscription duration is measured in months.
worker_instance_types list Yes The ECS instance types of worker nodes. For more information, see Instance families.
cpu_policy string No The CPU policy. For Kubernetes 1.12.6 and later, valid values of cpu_policy include static and none. Default value: none.
runtime json No The runtime of containers. Default value: docker. Specify the name and version.
  • name: The name of the container runtime.
  • version: The version of the container runtime.
platform string No The architecture of the nodes that run pods.
os_type string No The operating system of the nodes that run pods. For example, Linux and Windows.
node_cidr_mask int No The prefix length of the node CIDR block. This parameter specifies the maximum number of pods that can run containers. If you set this parameter to 24, each node can run a maximum of 256 pods. If you set this parameter to 25, each pod can run a maximum of 128 nodes. The formula is described as follows: Maximum number of pods on each node = 2^(32 - node_cidr_mask)
kubernetes_version string No The version of Kubernetes. The default value is the latest version.
deletion_protection bool No Specifies whether to enable cluster deletion protection. After this option is enabled, the cluster cannot be deleted by operations in the console or API operations.

Response information

Response line

HTTP/1.1 202 Accepted

Custom response headers

No custom response headers are used. For more information, see Public response headers.

Response body

{
"cluster_id":"string",
"request_id":"string",
"task_id":"string"
}

Examples

Sample requests

POST /clusters HTTP/1.1
<Common request headers>
{
"name":"test",
"cluster_type":"my-test-Kubernetes-cluster",
"disable_rollback":true,
"timeout_mins":60,
"kubernetes_version":"1.12.6-aliyun.1",
"region_id":"cn-beijing",
"snat_entry":true,
"cloud_monitor_flags":false,
"endpoint_public_access":false,
"node_cidr_mask":"25",
"proxy_mode":"ipvs",
"tags":[],
"addons": [{"name": "flannel"},{"name": "aliyun-log-controller","config": "{\"sls_project_name\":\"k8s-log-c64f6eab6a1764d3dbee3dc2b9e41****\"}"},{"name": "nginx-ingress-controller", "config": "{\"IngressSlbNetworkType\":\"internet\"}"}],
"worker_instance_types":["ecs.hfc5.xlarge"],
"num_of_nodes":3,
"worker_system_disk_category":"cloud_efficiency",
"worker_system_disk_size":120,
"worker_instance_charge_type":"PostPaid",
"vpcid":"vpc-2zegvl5etah5requ09nec",
"container_cidr":"172.20.0.0/16",
"service_cidr":"172.21.0.0/20",
"vswitch_ids":["vsw-2ze48rkq464rsdts1****"],
"worker_data_disks": [{"category": "cloud_ssd", "size": 500}],
"login_password":"test@19****",
"taint":[{"key": "special", "value": "true", "effect": "NoSchedule"}]
}

Sample responses

HTTP/1.1 202 Accepted
<Common response headers>
{
    "cluster_id": "cb95aa626a47740afbf6aa099b65****",
    "request_id": "687C5BAA-D103-4993-884B-C35E4314A1E1",
    "task_id": "T-5a54309c80282e39ea00002f"
}