This topic describes how to create a cluster and add nodes to the cluster.

For more information about the API operations, see Create a Kubernetes cluster and Create a managed Kubernetes cluster.

API request and response formats

Request format

aliyun cs  POST /clusters --header "Content-Type=application/json" --body "$(cat create.json)"

Parameters

  • In the --header, the Content-Type field must be set to application/json.
  • --body contains the contents that are sent to the server. The contents can be saved in a local file and must be in valid JSON format. The create.json file contains the following contents:
Kubernetes clusters
{ "disable_rollback": "whether to roll back when the operation fails", "name": "cluster name", "timeout_mins": "cluster creation timeout", "cluster_type": "cluster type. Kubernetes", "region_id": "region", "vpcid": "VPC ID", "master_vswitch_ids": "VSwitch IDs of master nodes. Specify three VSwitches in different zones to ensure high availability.", "master_instance_type": "instance types of master nodes. Specify three instance types.", "master_count": "the number of master nodes. Valid values: 3 and 5", "container_cidr": "pod CIDR block", "service_cidr": "service CIDR block", "ssh_flags": "whether to allow Internet access through SSH", "cloud_monitor_flags":"whether to install the CloudMonitor agent", "login_password": "SSH logon password. Select between SSH authentication and key pair authentication", "key_pair":"key pair name. Select between SSH authentication and key pair authentication", "master_instance_charge_type":"billing method of master nodes. PostPaid or PrePaid", "master_period_unit":"unit of the subscription duration of master nodes. Month or Year. This parameter takes effect only when parameter master_instance_charge_type is set to PrePaid", "master_period": "subscription duration of master nodes. This parameter takes effect only when parameter master_instance_charge_type is set to PrePaid", "master_auto_renew":"whether to automatically renew the subscription of master nodes", "master_auto_renew_period":"subscription duration when master nodes are renewed", "master_system_disk_category": "system disk type of master nodes", "master_system_disk_size":"system disk size of master nodes", "master_data_disk": "whether to mount data disks to master nodes.", "master_data_disks":"data disk configurations of master nodes",
"worker_instance_charge_type":"billing method of worker nodes. PrePaid or PostPaid", "worker_period_unit":"unit of the subscription duration of worker nodes. Month or Year. This parameter takes effect only when parameter worker_instance_charge_type is set to PrePaid", "worker_period":"subscription duration of worker nodes. This parameter takes effect only when parameter worker_instance_charge_type is set to PrePaid", "worker_auto_renew":"whether to automatically renew the subscription of worker nodes. Valid values: true and false", "worker_auto_renew_period": "subscription duration when worker nodes are renewed", "worker_instance_types": "instance types of worker nodes", "worker_vswitch_ids": "VSwitch IDs of worker nodes. Specify one to five VSwitches", "worker_system_disk_category": "system disk type of worker nodes", "worker_system_disk_size": "system disk size of worker nodes", "worker_data_disk": "whether to mount data disks to worker nodes.", "worker_data_disks":"data disk configurations of worker nodes", "num_of_nodes": "number of worker nodes", "snat_entry": "whether to configure SNAT entries", "endpoint_public_access": "whether to enable Internet access to the cluster endpoint", "cpu_policy": "CPU policy. Valid values: static and none", "node_port_range": "port range of nodes. Valid values: 30000 to 65535", "proxy_mode": "network mode. Valid values: iptables and ipvs", "addons": "optional add-ons in an array", "tags": "tags in an array", "security_group_id": "security group ID", "taint": "taints in an array" }
Managed Kubernetes clusters
{ "disable_rollback": "whether to roll back when the operation fails", "name": "cluster name", "timeout_mins": "cluster creation timeout", "cluster_type": "cluster type, ManagedKubernetes", "region_id": "region", "vpcid": "VPC ID", "worker_vswitch_ids": "VSwitch IDs. Specify one to five VSwitches", "container_cidr": "pod CIDR block", "service_cidr": "service CIDR block", "cloud_monitor_flags": "whether to install the CloudMonitor agent", "login_password": "SSH logon password. Select between SSH authentication and key pair authentication", "key_pair":"key pair name. Select between SSH authentication and key pair authentication", "worker_instance_charge_type":"billing method of worker nodes. PrePaid or PostPaid", "worker_period_unit":"unit of the subscription duration of worker nodes. Month or Year. This parameter takes effect only when parameter worker_instance_charge_type is set to PrePaid", "worker_period":"subscription duration of worker nodes. This parameter takes effect only when parameter worker_instance_charge_type is set to PrePaid", "worker_auto_renew":"whether to automatically renew the subscription of worker nodes. Valid values: true and false", "worker_auto_renew_period": "subscription duration when worker nodes are renewed", "worker_instance_types": "instance types of worker nodes", "worker_system_disk_category": "system disk type of worker nodes", "worker_system_disk_size": "system disk size of worker nodes", "worker_data_disk": "whether to mount data disks to worker nodes. Valid values: true and false", "worker_data_disks":"data disk configurations of worker nodes", "num_of_nodes": "number of worker nodes", "snat_entry": "whether to configure SNAT entries", "endpoint_public_access": "whether to enable Internet access to the cluster endpoint", "proxy_mode": "network mode. Valid values: iptables and ipvs", "addons": "optional add-ons in an array", "terway": "logging plugin-in, logtail-ds", "tags": "tags in an array", "security_group_id": "security group ID", "taint": "taints in an array" }

Serverless Kubernetes clusters

{ "cluster_type": "Ask", "name": "cluster name", "region_id": "region", "nat_gateway": "true", //whether to create a NAT gateway "private_zone": "true", //whether to enable PrivateZone for service discovery "vpc_id": "VPC ID", //If this parameter is not set, the system automatically creates a VPC network "vswitchid": "VSwitch ID", }

Sample responses

{    "cluster_id": "c61cf530524474386a7ab5a1c192****",
    "request_id": "348D4C9C-9105-4A1B-A86E-B58F0F875575",
    "task_id": "T-5ad724ab94a2b109e8000004"
}