1. 接口描述
接口请求域名: tke.tencentcloudapi.com 。
创建集群
默认接口请求频率限制:20次/秒。
推荐使用 API Explorer
点击调试
API Explorer 提供了在线调用、签名验证、SDK 代码生成和快速检索接口等能力。您可查看每次调用的请求内容和返回结果以及自动生成 SDK 调用示例。
2. 输入参数
以下请求参数列表仅列出了接口请求参数和部分公共参数,完整公共参数列表见 公共请求参数。
参数名称 | 必选 | 类型 | 描述 |
---|---|---|---|
Action | 是 | String | 公共参数,本接口取值:CreateCluster。 |
Version | 是 | String | 公共参数,本接口取值:2018-05-25。 |
Region | 是 | String | 公共参数,详见产品支持的 地域列表。 |
ClusterType | 是 | String | 集群类型,托管集群:MANAGED_CLUSTER,独立集群:INDEPENDENT_CLUSTER。 示例值:MANAGED_CLUSTER |
ClusterCIDRSettings | 是 | ClusterCIDRSettings | 集群容器网络配置信息 |
RunInstancesForNode.N | 否 | Array of RunInstancesForNode | CVM创建透传参数,json化字符串格式,详见CVM创建实例接口。总机型(包括地域)数量不超过10个,相同机型(地域)购买多台机器可以通过设置参数中RunInstances中InstanceCount来实现。 |
ClusterBasicSettings | 否 | ClusterBasicSettings | 集群的基本配置信息 |
ClusterAdvancedSettings | 否 | ClusterAdvancedSettings | 集群高级配置信息 |
InstanceAdvancedSettings | 否 | InstanceAdvancedSettings | 节点高级配置信息 |
ExistedInstancesForNode.N | 否 | Array of ExistedInstancesForNode | 已存在实例的配置信息。所有实例必须在同一个VPC中,最大数量不超过100,不支持添加竞价实例。 |
InstanceDataDiskMountSettings.N | 否 | Array of InstanceDataDiskMountSetting | CVM类型和其对应的数据盘挂载配置信息 |
ExtensionAddons.N | 否 | Array of ExtensionAddon | 需要安装的扩展组件信息 |
3. 输出参数
参数名称 | 类型 | 描述 |
---|---|---|
ClusterId | String | 集群ID 示例值:cls-7ph3twqu |
RequestId | String | 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 |
4. 示例
示例1 创建托管集群示例
创建托管集群
输入示例
POST / HTTP/1.1
Host: tke.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateCluster
<公共请求参数>
{
"ClusterCIDRSettings": {
"ServiceCIDR": "xyz",
"ClaimExpiredSeconds": 0,
"MaxClusterServiceNum": 1,
"MaxNodePodNum": 1,
"EniSubnetIds": [
"subnet-abcdef"
],
"ClusterCIDR": "xyz",
"IgnoreServiceCIDRConflict": true,
"IgnoreClusterCIDRConflict": true
},
"ClusterAdvancedSettings": {
"AuditEnabled": true,
"DeletionProtection": true,
"RuntimeVersion": "xyz",
"IsDualStack": true,
"IsNonStaticIpMode": true,
"KubeProxyMode": "xyz",
"AuditLogTopicId": "xyz",
"ExtraArgs": {
"KubeAPIServer": [
"xyz"
],
"KubeScheduler": [
"xyz"
],
"KubeControllerManager": [
"xyz"
],
"Etcd": [
"xyz"
]
},
"AuditLogsetId": "xyz",
"EnableCustomizedPodCIDR": true,
"CiliumMode": "xyz",
"AsEnabled": true,
"ContainerRuntime": "xyz",
"VpcCniType": "xyz",
"NetworkType": "xyz",
"NodeNameType": "xyz",
"IPVS": true,
"BasePodNumber": 0
},
"ClusterBasicSettings": {
"AutoUpgradeClusterLevel": {
"IsAutoUpgrade": true
},
"VpcId": "xyz",
"ClusterVersion": "xyz",
"TagSpecification": [
{
"ResourceType": "xyz",
"Tags": [
{
"Value": "xyz",
"Key": "xyz"
}
]
}
],
"ClusterName": "xyz",
"ProjectId": 0,
"ClusterDescription": "xyz",
"NeedWorkSecurityGroup": true,
"SubnetId": "xyz",
"OsCustomizeType": "xyz",
"ClusterLevel": "xyz",
"ClusterOs": "xyz"
},
"RunInstancesForNode": [
{
"InstanceAdvancedSettingsOverrides": [
{
"PreStartUserScript": "xyz",
"DockerGraphPath": "xyz",
"Labels": [
{
"Name": "xyz",
"Value": "xyz"
}
],
"ExtraArgs": {
"Kubelet": [
"xyz"
]
},
"Taints": [
{
"Value": "xyz",
"Key": "xyz",
"Effect": "xyz"
}
],
"Unschedulable": 0,
"UserScript": "xyz",
"DesiredPodNumber": 0,
"GPUArgs": {
"MIGEnable": true,
"CustomDriver": {
"Address": "xyz"
},
"Driver": {
"Version": "xyz",
"Name": "xyz"
},
"CUDA": {
"Version": "xyz",
"Name": "xyz"
},
"CUDNN": {
"DocName": "xyz",
"Version": "xyz",
"Name": "xyz",
"DevName": "xyz"
}
},
"MountTarget": "xyz",
"DataDisks": [
{
"DiskPartition": "xyz",
"DiskType": "xyz",
"DiskSize": 0,
"FileSystem": "xyz",
"AutoFormatAndMount": true,
"MountTarget": "xyz"
}
]
}
],
"NodeRole": "xyz",
"RunInstancesPara": [
"{\"VirtualPrivateCloud\":{\"SubnetId\":\"subnet-xyzx\",\"VpcId\":\"vpc-xyzx\"},\"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": "xyz",
"AddonParam": "xyz"
}
],
"ClusterType": "xyz",
"InstanceAdvancedSettings": {
"PreStartUserScript": "xyz",
"DockerGraphPath": "xyz",
"Labels": [
{
"Name": "xyz",
"Value": "xyz"
}
],
"ExtraArgs": {
"Kubelet": [
"xyz"
]
},
"Taints": [
{
"Value": "xyz",
"Key": "xyz",
"Effect": "xyz"
}
],
"Unschedulable": 0,
"UserScript": "xyz",
"DesiredPodNumber": 0,
"GPUArgs": {
"MIGEnable": true,
"CustomDriver": {
"Address": "xyz"
},
"Driver": {
"Version": "xyz",
"Name": "xyz"
},
"CUDNN": {
"DocName": "xyz",
"Version": "xyz",
"Name": "xyz",
"DevName": "xyz"
}
},
"MountTarget": "xyz",
"DataDisks": [
{
"DiskPartition": "xyz",
"DiskType": "xyz",
"DiskSize": 0,
"FileSystem": "xyz",
"AutoFormatAndMount": true,
"MountTarget": "xyz"
}
]
},
"ExistedInstancesForNode": [
{
"ExistedInstancesPara": {
"InstanceAdvancedSettings": {
"PreStartUserScript": "xyz",
"DockerGraphPath": "xyz",
"Labels": [
{
"Name": "xyz",
"Value": "xyz"
}
],
"ExtraArgs": {
"Kubelet": [
"xyz"
]
},
"Taints": [
{
"Value": "xyz",
"Key": "xyz",
"Effect": "xyz"
}
],
"Unschedulable": 0,
"UserScript": "xyz",
"DesiredPodNumber": 0,
"GPUArgs": {
"MIGEnable": true,
"CustomDriver": {
"Address": "xyz"
},
"CUDNN": {
"DocName": "xyz",
"Version": "xyz",
"Name": "xyz",
"DevName": "xyz"
}
},
"MountTarget": "xyz",
"DataDisks": [
{
"DiskPartition": "xyz",
"DiskType": "xyz",
"DiskSize": 0,
"FileSystem": "xyz",
"AutoFormatAndMount": true,
"MountTarget": "xyz"
}
]
},
"HostName": "xyz",
"LoginSettings": {
"Password": "xyz",
"KeepImageLogin": "xyz",
"KeyIds": [
"xyz"
]
},
"SecurityGroupIds": [
"xyz"
],
"EnhancedService": {
"SecurityService": {
"Enabled": true
},
"MonitorService": {
"Enabled": true
},
"AutomationService": {
"Enabled": true
}
},
"InstanceIds": [
"xyz"
]
},
"DesiredPodNumbers": [
0
],
"NodeRole": "xyz"
}
],
"InstanceDataDiskMountSettings": [
{
"InstanceType": "xyz",
"Zone": "xyz",
"DataDisks": [
{
"DiskPartition": "xyz",
"DiskType": "xyz",
"DiskSize": 0,
"FileSystem": "xyz",
"AutoFormatAndMount": true,
"MountTarget": "xyz"
}
]
}
]
}
输出示例
{
"Response": {
"ClusterId": "cls-7ph3twqe",
"RequestId": "eac6b301-a322-493a-8e36-83b295459397"
}
}
示例2 创建独立集群示例
创建独立集群
输入示例
POST / HTTP/1.1
Host: tke.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateCluster
<公共请求参数>
{
"ClusterCIDRSettings": {
"ClusterCIDR": "10.4.0.0/14"
},
"ExtensionAddons": [
{
"AddonName": "GameApp",
"AddonParam": "{\"kind\":\"GameApp\",\"apiVersion\":\"platform.tke/v1\",\"metadata\":{\"generateName\":\"ga\"},\"spec\":{\"clusterName\":\"xxx\"}}"
}
],
"ClusterType": "INDEPENDENT_CLUSTER",
"RunInstancesForNode": [
{
"NodeRole": "WORKER",
"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=\"}"
]
},
{
"NodeRole": "MASTER_ETCD",
"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\":3,\"InternetAccessible\":{\"PublicIpAssigned\":true,\"InternetMaxBandwidthOut\":1},\"LoginSettings\":{\"Password\":\"YourPassword\"},\"UserData\":\"IyEvYmluL3NoCgplY2hvIGFhYQo=\"}"
]
}
]
}
输出示例
{
"Response": {
"ClusterId": "cls-xxx",
"RequestId": "eac6b301-a322-493a-8e36-83b295459397"
}
}
5. 开发者资源
腾讯云 API 平台
腾讯云 API 平台 是综合 API 文档、错误码、API Explorer 及 SDK 等资源的统一查询平台,方便您从同一入口查询及使用腾讯云提供的所有 API 服务。
API Inspector
用户可通过 API Inspector 查看控制台每一步操作关联的 API 调用情况,并自动生成各语言版本的 API 代码,也可前往 API Explorer 进行在线调试。
SDK
云 API 3.0 提供了配套的开发工具集(SDK),支持多种编程语言,能更方便的调用 API。
- Tencent Cloud SDK 3.0 for Python: GitHub Gitee
- Tencent Cloud SDK 3.0 for Java: GitHub Gitee
- Tencent Cloud SDK 3.0 for PHP: GitHub Gitee
- Tencent Cloud SDK 3.0 for Go: GitHub Gitee
- Tencent Cloud SDK 3.0 for Node.js: GitHub Gitee
- Tencent Cloud SDK 3.0 for .NET: GitHub Gitee
- Tencent Cloud SDK 3.0 for C++: GitHub Gitee
- Tencent Cloud SDK 3.0 for Ruby: GitHub Gitee
命令行工具
6. 错误码
以下仅列出了接口业务逻辑相关的错误码,其他错误码详见 公共错误码。
错误码 | 描述 |
---|---|
FailedOperation.AccountCommon | 获取用户认证信息失败。 |
FailedOperation.AccountUserNotAuthenticated | 账户未通过认证。 |
FailedOperation.CamNoAuth | 无该接口CAM权限。 |
FailedOperation.ComponentClientHttp | 内部HTTP客户端错误。 |
FailedOperation.CvmCommon | cvm创建节点报错。 |
FailedOperation.CvmNumberNotMatch | 存在云服务器在CVM侧查询不到。 |
FailedOperation.CvmVpcidNotMatch | CVM 和 VPC ID 不匹配。 |
FailedOperation.DbRecordNotFound | 记录未找到。 |
FailedOperation.DfwGetUSGQuota | 获得安全组配额失败。 |
FailedOperation.NodeExistsSecondaryNetworkInterface | 节点存在辅助网卡 |
FailedOperation.OsNotSupport | 镜像OS不支持。 |
FailedOperation.Param | 参数错误。 |
FailedOperation.QuotaMaxClsLimit | 超过配额限制。 |
FailedOperation.QuotaMaxNodLimit | 超过配额限制。 |
FailedOperation.QuotaUSGLimit | 安全组配额不足。 |
FailedOperation.TradeCommon | 询价错误。 |
FailedOperation.VpcCommon | VPC报错。 |
FailedOperation.VpcRecodrNotFound | 未发现vpc记录。 |
FailedOperation.WhitelistUnexpectedError | 白名单错误。 |
InternalError | 内部错误。 |
InternalError.AccountCommon | 获取用户认证信息失败。 |
InternalError.AccountUserNotAuthenticated | 账户未通过认证。 |
InternalError.AsCommon | 伸缩组资源创建报错。 |
InternalError.CidrConflictWithOtherCluster | CIDR和其他集群CIDR冲突。 |
InternalError.CidrConflictWithOtherRoute | CIDR和其他路由冲突。 |
InternalError.CidrConflictWithVpcCidr | CIDR和vpc冲突。 |
InternalError.CidrConflictWithVpcGlobalRoute | CIDR和全局路由冲突。 |
InternalError.CidrInvali | CIDR无效。 |
InternalError.CidrMaskSizeOutOfRange | CIDR掩码无效。 |
InternalError.ComponentClinetHttp | 请求(http请求)其他云服务失败。 |
InternalError.CreateMasterFailed | 创建集群失败。 |
InternalError.CvmCommon | cvm创建节点报错。 |
InternalError.CvmNumberNotMatch | 存在云服务器在CVM侧查询不到。 |
InternalError.CvmStatus | cvm状态不正常。 |
InternalError.Db | db错误。 |
InternalError.DbAffectivedRows | DB错误。 |
InternalError.DbRecordNotFound | 记录未找到。 |
InternalError.DfwGetUSGCount | 获得当前安全组总数失败。 |
InternalError.DfwGetUSGQuota | 获得安全组配额失败。 |
InternalError.InitMasterFailed | 初始化master失败。 |
InternalError.InvalidPrivateNetworkCidr | 无效CIDR。 |
InternalError.OsNotSupport | 镜像OS不支持。 |
InternalError.Param | Param。 |
InternalError.PublicClusterOpNotSupport | 集群不支持当前操作。 |
InternalError.QuotaMaxClsLimit | 超过配额限制。 |
InternalError.QuotaMaxNodLimit | 超过配额限制。 |
InternalError.QuotaUSGLimit | 安全组配额不足。 |
InternalError.TaskCreateFailed | 创建任务失败。 |
InternalError.TradeCommon | 计费错误。 |
InternalError.UnexceptedInternal | 内部错误。 |
InternalError.UnexpectedInternal | 未知的内部错误。 |
InternalError.VpcCommon | VPC报错。 |
InternalError.VpcRecodrNotFound | 未发现vpc记录。 |
InvalidParameter | 参数错误。 |
InvalidParameter.CIDRInvalid | 非法的CIDR。 |
InvalidParameter.CIDRMaskSizeOutOfRange | CIDR掩码超出范围(集群CIDR范围 最小值: 10 最大值: 24)。 |
InvalidParameter.CidrConflictWithOtherCluster | CIDR和其他集群CIDR冲突。 |
InvalidParameter.CidrConflictWithOtherRoute | 创建的路由与已存在的其他路由产生冲突。 |
InvalidParameter.CidrConflictWithVpcCidr | CIDR和vpc的CIDR冲突。 |
InvalidParameter.CidrConflictWithVpcGlobalRoute | 创建的路由与VPC下已存在的全局路由产生冲突。 |
InvalidParameter.CidrInvali | CIDR无效。 |
InvalidParameter.CidrInvalid | 参数错误,CIDR不符合规范。 |
InvalidParameter.InvalidPrivateNetworkCIDR | 无效的私有CIDR网段。 |
LimitExceeded | 超过配额限制。 |
ResourceInsufficient.SpecifiedInstanceType | CVM资源不足。 |