tencent cloud

文档反馈

CreateCluster

最后更新时间:2023-09-18 16:00:30

1. API Description

Domain name for API request: tke.tencentcloudapi.com.

This API is used to create a cluster.

A maximum of 20 requests can be initiated per second for this API.

We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

2. Input Parameters

The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

Parameter Name Required Type Description
Action Yes String Common Params. The value used for this API: CreateCluster.
Version Yes String Common Params. The value used for this API: 2018-05-25.
Region No String Common Params. This parameter is not required for this API.
ClusterCIDRSettings Yes ClusterCIDRSettings Container networking configuration information for the cluster
ClusterType Yes String Cluster type. Managed cluster: MANAGED_CLUSTER; self-deployed cluster: INDEPENDENT_CLUSTER.
RunInstancesForNode.N No Array of RunInstancesForNode Pass-through parameter for CVM creation in the format of a JSON string. For more information, see the API for creating a CVM instance.
ClusterBasicSettings No ClusterBasicSettings Basic configuration information of the cluster
ClusterAdvancedSettings No ClusterAdvancedSettings Advanced configuration information of the cluster
InstanceAdvancedSettings No InstanceAdvancedSettings Advanced configuration information of the node
ExistedInstancesForNode.N No Array of ExistedInstancesForNode The configuration information for existing instances. All instances must be in the same VPC. Up to 100 instances are allowed in one VPC. Spot instances are not supported.
InstanceDataDiskMountSettings.N No Array of InstanceDataDiskMountSetting CVM type and the corresponding data disk mounting configuration information.
ExtensionAddons.N No Array of ExtensionAddon Information of the add-on to be installed

3. Output Parameters

Parameter Name Type Description
ClusterId String Cluster ID
RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

4. Example

Example1 Creating a managed cluster

This example shows you how to create a managed cluster.

Input Example

POST / HTTP/1.1
Host: tke.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateCluster
<Common request parameters>

{
    "ClusterCIDRSettings": {
        "ServiceCIDR": "xx",
        "ClaimExpiredSeconds": 0,
        "MaxClusterServiceNum": 1,
        "MaxNodePodNum": 1,
        "EniSubnetIds": [
            "xx"
        ],
        "ClusterCIDR": "xx",
        "IgnoreServiceCIDRConflict": true,
        "IgnoreClusterCIDRConflict": true
    },
    "ClusterAdvancedSettings": {
        "AuditEnabled": true,
        "DeletionProtection": true,
        "RuntimeVersion": "xx",
        "IsDualStack": true,
        "IsNonStaticIpMode": true,
        "KubeProxyMode": "xx",
        "AuditLogTopicId": "xx",
        "ExtraArgs": {
            "KubeAPIServer": [
                "xx"
            ],
            "KubeScheduler": [
                "xx"
            ],
            "KubeControllerManager": [
                "xx"
            ],
            "Etcd": [
                "xx"
            ]
        },
        "AuditLogsetId": "xx",
        "EnableCustomizedPodCIDR": true,
        "CiliumMode": "xx",
        "AsEnabled": true,
        "ContainerRuntime": "xx",
        "VpcCniType": "xx",
        "NetworkType": "xx",
        "NodeNameType": "xx",
        "IPVS": true,
        "BasePodNumber": 0
    },
    "ClusterBasicSettings": {
        "AutoUpgradeClusterLevel": {
            "IsAutoUpgrade": true
        },
        "VpcId": "xx",
        "ClusterVersion": "xx",
        "TagSpecification": [
            {
                "ResourceType": "xx",
                "Tags": [
                    {
                        "Value": "xx",
                        "Key": "xx"
                    }
                ]
            }
        ],
        "ClusterName": "xx",
        "ProjectId": 0,
        "ClusterDescription": "xx",
        "NeedWorkSecurityGroup": true,
        "SubnetId": "xx",
        "OsCustomizeType": "xx",
        "ClusterLevel": "xx",
        "ClusterOs": "xx"
    },
    "RunInstancesForNode": [
        {
            "InstanceAdvancedSettingsOverrides": [
                {
                    "PreStartUserScript": "xx",
                    "DockerGraphPath": "xx",
                    "Labels": [
                        {
                            "Name": "xx",
                            "Value": "xx"
                        }
                    ],
                    "ExtraArgs": {
                        "Kubelet": [
                            "xx"
                        ]
                    },
                    "Taints": [
                        {
                            "Value": "xx",
                            "Key": "xx",
                            "Effect": "xx"
                        }
                    ],
                    "Unschedulable": 0,
                    "UserScript": "xx",
                    "DesiredPodNumber": 0,
                    "GPUArgs": {
                        "MIGEnable": true,
                        "CustomDriver": {
                            "Address": "xx"
                        },
                        "Driver": {
                            "Version": "xx",
                            "Name": "xx"
                        },
                        "CUDA": {
                            "Version": "xx",
                            "Name": "xx"
                        },
                        "CUDNN": {
                            "DocName": "xx",
                            "Version": "xx",
                            "Name": "xx",
                            "DevName": "xx"
                        }
                    },
                    "MountTarget": "xx",
                    "DataDisks": [
                        {
                            "DiskPartition": "xx",
                            "DiskType": "xx",
                            "DiskSize": 0,
                            "FileSystem": "xx",
                            "AutoFormatAndMount": true,
                            "MountTarget": "xx"
                        }
                    ]
                }
            ],
            "NodeRole": "xx",
            "RunInstancesPara": [
                "{\"VirtualPrivateCloud\":{\"SubnetId\":\"subnet-xxx\",\"VpcId\":\"vpc-xxx\"},\"Placement\":{\"Zone\":\"ap-region-1\",\"ProjectId\":1032509},\"InstanceType\":\"S3.LARGE8\",\"SystemDisk\":{\"DiskType\":\"CLOUD_PREMIUM\"},\"DataDisks\":[{\"DiskType\":\"CLOUD_PREMIUM\",\"DiskSize\":50}],\"InstanceCount\":1,\"InternetAccessible\":{\"PublicIpAssigned\":true,\"InternetMaxBandwidthOut\":1},\"LoginSettings\":{\"Password\":\"YourPassword\"},\"UserData\":\"IyEvYmluL3NoCgplY2hvIGFhYQo=\"}"
            ]
        }
    ],
    "ExtensionAddons": [
        {
            "AddonName": "xx",
            "AddonParam": "xx"
        }
    ],
    "ClusterType": "xx",
    "InstanceAdvancedSettings": {
        "PreStartUserScript": "xx",
        "DockerGraphPath": "xx",
        "Labels": [
            {
                "Name": "xx",
                "Value": "xx"
            }
        ],
        "ExtraArgs": {
            "Kubelet": [
                "xx"
            ]
        },
        "Taints": [
            {
                "Value": "xx",
                "Key": "xx",
                "Effect": "xx"
            }
        ],
        "Unschedulable": 0,
        "UserScript": "xx",
        "DesiredPodNumber": 0,
        "GPUArgs": {
            "MIGEnable": true,
            "CustomDriver": {
                "Address": "xx"
            },
            "Driver": {
                "Version": "xx",
                "Name": "xx"
            },
            "CUDNN": {
                "DocName": "xx",
                "Version": "xx",
                "Name": "xx",
                "DevName": "xx"
            }
        },
        "MountTarget": "xx",
        "DataDisks": [
            {
                "DiskPartition": "xx",
                "DiskType": "xx",
                "DiskSize": 0,
                "FileSystem": "xx",
                "AutoFormatAndMount": true,
                "MountTarget": "xx"
            }
        ]
    },
    "ExistedInstancesForNode": [
        {
            "ExistedInstancesPara": {
                "InstanceAdvancedSettings": {
                    "PreStartUserScript": "xx",
                    "DockerGraphPath": "xx",
                    "Labels": [
                        {
                            "Name": "xx",
                            "Value": "xx"
                        }
                    ],
                    "ExtraArgs": {
                        "Kubelet": [
                            "xx"
                        ]
                    },
                    "Taints": [
                        {
                            "Value": "xx",
                            "Key": "xx",
                            "Effect": "xx"
                        }
                    ],
                    "Unschedulable": 0,
                    "UserScript": "xx",
                    "DesiredPodNumber": 0,
                    "GPUArgs": {
                        "MIGEnable": true,
                        "CustomDriver": {
                            "Address": "xx"
                        },
                        "CUDNN": {
                            "DocName": "xx",
                            "Version": "xx",
                            "Name": "xx",
                            "DevName": "xx"
                        }
                    },
                    "MountTarget": "xx",
                    "DataDisks": [
                        {
                            "DiskPartition": "xx",
                            "DiskType": "xx",
                            "DiskSize": 0,
                            "FileSystem": "xx",
                            "AutoFormatAndMount": true,
                            "MountTarget": "xx"
                        }
                    ]
                },
                "HostName": "xx",
                "LoginSettings": {
                    "Password": "xx",
                    "KeepImageLogin": "xx",
                    "KeyIds": [
                        "xx"
                    ]
                },
                "SecurityGroupIds": [
                    "xx"
                ],
                "EnhancedService": {
                    "SecurityService": {
                        "Enabled": true
                    },
                    "MonitorService": {
                        "Enabled": true
                    },
                    "AutomationService": {
                        "Enabled": true
                    }
                },
                "InstanceIds": [
                    "xx"
                ]
            },
            "DesiredPodNumbers": [
                0
            ],
            "NodeRole": "xx"
        }
    ],
    "InstanceDataDiskMountSettings": [
        {
            "InstanceType": "xx",
            "Zone": "xx",
            "DataDisks": [
                {
                    "DiskPartition": "xx",
                    "DiskType": "xx",
                    "DiskSize": 0,
                    "FileSystem": "xx",
                    "AutoFormatAndMount": true,
                    "MountTarget": "xx"
                }
            ]
        }
    ]
}

Output Example

{
    "Response": {
        "ClusterId": "cls-xxx",
        "RequestId": "eac6b301-a322-493a-8e36-83b295459397"
    }
}

Example2 Creating a self-deployed cluster

This example shows you how to create a self-deployed cluster.

Input Example

https://tke.tencentcloudapi.com/?Action=CreateCluster
&ClusterType=INDEPENDENT_CLUSTER
&ClusterCIDRSettings.ClusterCIDR=10.4.0.0/14
&RunInstancesForNode.0.NodeRole=MASTER_ETCD
&RunInstancesForNode.0.RunInstancesPara.0={"VirtualPrivateCloud":{"SubnetId":"subnet-xxx","VpcId":"vpc-xxx"},"Placement":{"Zone":"ap-region-1","ProjectId":1032509},"InstanceType":"S3.LARGE8","SystemDisk":{"DiskType":"CLOUD_PREMIUM"},"DataDisks":[{"DiskType":"CLOUD_PREMIUM","DiskSize":50}],"InstanceCount":3,"InternetAccessible":{"PublicIpAssigned":true,"InternetMaxBandwidthOut":1},"LoginSettings":{"Password":"YourPassword"},"UserData":"IyEvYmluL3NoCgplY2hvIGFhYQo="}
&RunInstancesForNode.1.NodeRole=WORKER
&RunInstancesForNode.1.RunInstancesPara.0={"VirtualPrivateCloud":{"SubnetId":"subnet-xxx","VpcId":"vpc-xxx"},"Placement":{"Zone":"ap-region-1","ProjectId":1032509},"InstanceType":"S3.LARGE8","SystemDisk":{"DiskType":"CLOUD_PREMIUM"},"DataDisks":[{"DiskType":"CLOUD_PREMIUM","DiskSize":50}],"InstanceCount":1,"InternetAccessible":{"PublicIpAssigned":true,"InternetMaxBandwidthOut":1},"LoginSettings":{"Password":"YourPassword"},"UserData":"IyEvYmluL3NoCgplY2hvIGFhYQo="}
&ExtensionAddons.0.AddonName=GameApp
&ExtensionAddons.0.AddonParam={"kind":"GameApp","apiVersion":"platform.tke/v1","metadata":{"generateName":"ga"},"spec":{"clusterName":"xxx"}}
&<Common request parameters>

Output Example

{
    "Response": {
        "ClusterId": "cls-xxx",
        "RequestId": "eac6b301-a322-493a-8e36-83b295459397"
    }
}

5. Developer Resources

SDK

TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

Command Line Interface

6. Error Code

The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

Error Code Description
FailedOperation.AccountCommon Failed to obtain user authentication information.
FailedOperation.AccountUserNotAuthenticated The account is not verified.
FailedOperation.CamNoAuth Not authorized to access this API
FailedOperation.ComponentClientHttp Internal HTTP client error.
FailedOperation.CvmCommon Failed to create the node due to a CVM error
FailedOperation.CvmNumberNotMatch Some of the specified CVMs are not found.
FailedOperation.CvmVpcidNotMatch The CVM does not match the VPC ID.
FailedOperation.DbRecordNotFound Record not found.
FailedOperation.DfwGetUSGQuota Failed to obtain security group quota.
FailedOperation.NodeExistsSecondaryNetworkInterface The node has a secondary ENI.
FailedOperation.OsNotSupport The image OS is not supported.
FailedOperation.Param Invalid parameter.
FailedOperation.QuotaMaxClsLimit Reached the quota limit.
FailedOperation.QuotaMaxNodLimit Reached the quota limit.
FailedOperation.QuotaUSGLimit Insufficient security group quota.
FailedOperation.TradeCommon Query failed.
FailedOperation.VpcCommon VPC error.
FailedOperation.VpcRecodrNotFound VPC record not found.
FailedOperation.WhitelistUnexpectedError Allowlist error.
InternalError Internal error.
InternalError.AccountCommon Failed to obtain the user authentication information
InternalError.AccountUserNotAuthenticated Account not verified.
InternalError.AsCommon Error creating scaling group resource.
InternalError.CidrConflictWithOtherCluster CIDR conflicts with the CIDR of another cluster.
InternalError.CidrConflictWithOtherRoute CIDR conflicts with another route.
InternalError.CidrConflictWithVpcCidr CIDR conflicts with VPC.
InternalError.CidrConflictWithVpcGlobalRoute CIDR conflicts with global route.
InternalError.CidrInvali Invalid CIDR.
InternalError.CidrMaskSizeOutOfRange Invalid CIDR mask.
InternalError.ComponentClinetHttp Error while requesting (HTTP) other Tencent Cloud services
InternalError.CreateMasterFailed Failed to create cluster.
InternalError.CvmCommon Error in node creation.
InternalError.CvmNumberNotMatch Some of the CVMs cannot be found
InternalError.CvmStatus Exceptional CVM status.
InternalError.Db DB error.
InternalError.DbAffectivedRows Database error.
InternalError.DbRecordNotFound Record not found.
InternalError.DfwGetUSGCount Failed to obtain total number of current security groups.
InternalError.DfwGetUSGQuota Failed to obtain security group quota.
InternalError.InitMasterFailed Failed to initialize Master.
InternalError.InvalidPrivateNetworkCidr Invalid CIDR.
InternalError.OsNotSupport Image OS not supported.
InternalError.Param Parameter error.
InternalError.PublicClusterOpNotSupport Cluster does not support the current operation.
InternalError.QuotaMaxClsLimit Quota limit exceeded.
InternalError.QuotaMaxNodLimit Quota limit exceeded.
InternalError.QuotaUSGLimit Insufficient security group quota.
InternalError.TaskCreateFailed Failed to create the task.
InternalError.TradeCommon Query failed
InternalError.UnexceptedInternal Internal error.
InternalError.UnexpectedInternal Unknown internal error.
InternalError.VpcCommon VPC error
InternalError.VpcRecodrNotFound VPC record not found
InvalidParameter Parameter error.
InvalidParameter.CIDRInvalid Invalid CIDR block.
InvalidParameter.CIDRMaskSizeOutOfRange Invalid CIDR block mask (valid range: 10 to 24).
InvalidParameter.CidrConflictWithOtherCluster The CIDR block conflicts with the CIDR blocks of other clusters.
InvalidParameter.CidrConflictWithOtherRoute The route to create conflicts with existing routes.
InvalidParameter.CidrConflictWithVpcCidr The CIDR block conflicts with the VPC’s CIDR block.
InvalidParameter.CidrConflictWithVpcGlobalRoute The created route conflicts with the existing global route under the VPC.
InvalidParameter.CidrInvali Invalid CIDR block.
InvalidParameter.CidrInvalid Parameter error. The CIDR block does not meet the specification.
InvalidParameter.InvalidPrivateNetworkCIDR Invalid private CIDR block.
LimitExceeded Quota limit is exceeded.
ResourceInsufficient.SpecifiedInstanceType Insufficient CVM resources.
联系我们

联系我们,为您的业务提供专属服务。

技术支持

如果你想寻求进一步的帮助,通过工单与我们进行联络。我们提供7x24的工单服务。

7x24 电话支持