创建集群

最近更新时间:2020-10-21 15:38:58

CreateCluster(创建集群)

接口描述

该接口适用于用户创建容器集群

请求方式

POST

输入参数

参数 类型 是否必选 描述
ClusterName String 集群名称
有效值:2-64个字符,支持中文,英文,数字,以及特殊字符-,.!$^*()%#&+/:;<=>[]_`{}~
ClusterDesc String 集群描述
ClusterManageMode String master管理形态
有效值:DedicatedCluster
默认值:DedicatedCluster
VpcId String 集群所在的vpcid
PodCidr String 集群pod的网段,如:10.0.0.0/16
校验:容器集群pod的网段不能和Service网段和VPC的网段冲突
ServiceCidr String 集群Service的网段,如:10.1.0.0/16
校验:容器集群Service的网段不能和Pod网段和VPC的网段冲突
MaxPodPerNode Integer 每个节点上运行的pod数量上限
默认值:128
可选值:16,32,64,128,256
NetworkType String 集群的网络模型
有效值:Flannel、Canal
K8sVersion String 容器服务支持的k8s的集群版本号
有效值:v1.12.3、v1.13.4、v1.15.5
ReserveSubnetId String 集群所在vpc终端子网id
MasterEtcdSeparate Boolean 该字段仅针对于独立部署集群生效,托管集群不生效。集群Master和Etcd组件部署方式,有效值:
True:Master和Etcd组件独享节点部署
False:Master和Etcd组件共享节点部署
默认值:False
InstanceSet.N InstanceSet.N数据类型 新建虚拟机节点创建集群,定义节点角色和配置,支持普通云主机和专属云主机.
节点配置信息使用云主机/专属云主机创建透传参数,json化字符串格式,详见云主机创建实例接口专属云主机创建示例接口
注意:需要将ImageId替换为容器服务支持的镜像,获取容器服务支持的镜像,详见获取容器服务支持的节点操作系统
ExistedInstanceEpcSet.N ExistedInstanceEpcSet.N数据类型 使用已有的云物理机创建集群,定义节点角色和配置
PublicApiServer String 是否将apiserver暴露到公网。若不需要暴露,则不填写此选项;若选择暴露,则会创建公网SLB和EIP用于开启集群的Api Server公网访问。需要用户传递弹性EIP创建透传参数,json化字符串格,详见创建弹性IP

返回参数

参数 类型 描述
RequestId String 请求id
ClusterId String 集群id

调用示例

示例1 创建普通云服务器集群

输入示例

http://kce.api.ksyun.com/?Action=CreateCluster&Version=2019-08-06
&ClusterName=openapi开机集群
&ClusterDesc=This is a test cluster
&ClusterManageMode=DedicatedCluster
&VpcId=31e21dca-c92e-4b06-a8ce-xxxxx
&PodCidr=10.66.0.0/16
&ServiceCidr=10.254.0.0/16
&NetworkType=Flannel
&K8sVersion=v1.12.3
&ReserveSubnetId=372bdbac-ea1d-4f99-9c30-xxxxxxx
&PublicApiServer={"LineId":"xxxxxxx","BandWidth":"5","ChargeType":"PostPaidByDay"}
&InstanceSet.0.NodeRole=Master_Etcd
&InstanceSet.0.NodePara.0={"MaxCount":3,"MinCount":3,"ImageId":"5bbc21d6-c48c-4c8a-b057-fcbb164bcbf7","SubnetId":"7e23b980-11c2-4bb0-9388-xxxxxxxx","InstancePassword":"Root23123","SecurityGroupId":"d46c7672-7ca9-4f51-bbd9-xxxxxxxx","DataDiskGb":50,"ChargeType":"Daily","InstanceType":"I3.4B","PurchaseTime":0,"InstanceName":"openapi-master","InstanceNameSuffix":1}
&InstanceSet.1.NodeRole=Worker
&InstanceSet.1.NodePara.0={"MaxCount":3,"MinCount":3,"ImageId":"5bbc21d6-c48c-4c8a-b057-fcbb164bcbf7","SubnetId":"7e23b980-11c2-4bb0-9388-xxxxxxxx","InstancePassword":"Root23123","SecurityGroupId":"d46c7672-7ca9-4f51-bbd9-xxxxxxxx","DataDiskGb":50,"ChargeType":"Daily","InstanceType":"I3.4B","PurchaseTime":0,"InstanceName":"openapi-worker","InstanceNameSuffix":1}

返回示例

{
    "RequestId": "c9afa2b9-be8a-49d4-bebf-dd87851456db"
    "ClusterId": "b12d7079-1e59-4626-90eb-xxxxxxx"
}

示例2 创建专属云服务器集群

支持使用专属云服务器创建容器集群

输入示例

http://kce.api.ksyun.com/?Action=CreateCluster&Version=2019-08-06
&ClusterManageMode=DedicatedCluster
&VpcId=31e21dca-c92e-4b06-a8ce-xxxxxx
&PodCidr=10.67.0.0/16
&ServiceCidr=10.254.0.0/16
&NetworkType=Flannel
&K8sVersion=v1.12.3
&ReserveSubnetId=372bdbac-ea1d-4f99-9c30-xxxxxx
&InstanceSet.0.NodeRole=Master_Etcd
&InstanceSet.0.NodePara.0={"DedicatedHostId":"33b44f3e-a037-423e-a850-xxxxxx","InstanceConfigure.VCPU":4,"InstanceConfigure.MemoryGb":8,"MaxCount":3,"MinCount":3,"ImageId":"5bbc21d6-c48c-4c8a-b057-fcbb164bcbf7","SubnetId":"f2ac1919-0e34-4812-8290-xxxxxx","InstancePassword":"Root23123","SecurityGroupId":"d46c7672-7ca9-4f51-bbd9-xxxxxx","DataDiskGb":50,"ChargeType":"Daily","PurchaseTime":0,"InstanceName":"k8s-kdc-master","InstanceNameSuffix":1,"InstanceType":"DVM1.NONE"}
&InstanceSet.1.NodeRole=Worker
&InstanceSet.1.NodePara.0={"DedicatedHostId":"33b44f3e-a037-423e-a850-xxxxxx","InstanceConfigure.VCPU":4,"InstanceConfigure.MemoryGb":8,"MaxCount":3,"MinCount":3,"ImageId":"5bbc21d6-c48c-4c8a-b057-fcbb164bcbf7","SubnetId":"f2ac1919-0e34-4812-8290-xxxxxx","InstancePassword":"Root23123","SecurityGroupId":"d46c7672-7ca9-4f51-bbd9-xxxxxxx","DataDiskGb":50,"ChargeType":"Daily","PurchaseTime":0,"InstanceName":"k8s-kdc-worker","InstanceNameSuffix":1,"InstanceType":"DVM1.NONE"}
&ClusterName=专属云服务器集群
&ClusterDesc=This is a kdc cluster

返回示例

{
    "RequestId": "308b6948-9c74-41b6-8356-7bcced1da043",
    "ClusterId": "52286a83-f317-416d-820e-xxxxxxx"
}

示例3 使用云物理主机创建集群

支持使用已有的云物理主机创建容器集群

输入示例

http://kce.api.ksyun.com/?Action=CreateCluster&Version=2019-08-06
&MaxPodPerNode=256
&ClusterManageMode=DedicatedCluster
&VpcId=31e21dca-c92e-4b06-a8ce-xxxxxx
&PodCidr=10.78.0.0/16
&ServiceCidr=10.254.0.0/16
&NetworkType=Flannel
&K8sVersion=v1.15.5
&ReserveSubnetId=372bdbac-ea1d-4f99-9c30-xxxxxx
&ClusterName=test-cluster
&ClusterDesc=测试
&MasterEtcdSeparate=True
&ExistedInstanceEpcSet.1.NodeRole=Master
&ExistedInstanceEpcSet.1.EpcPara.1={"InstanceId"="70e4807b-3ed0-4bd5-a06f-xxxxxx"}
&ExistedInstanceEpcSet.1.EpcPara.2={"InstanceId"="f3a751bb-4663-4f4f-af01-xxxxxx"}
&ExistedInstanceEpcSet.1.EpcPara.3={"InstanceId"="aadf2c78-bc56-40e3-93db-xxxxxx"}
&ExistedInstanceEpcSet.2.NodeRole=Etcd
&ExistedInstanceEpcSet.2.EpcPara.1={"InstanceId"="4c20cc6c-01e6-4215-99c5-xxxxxx"}
&ExistedInstanceEpcSet.2.EpcPara.2={"InstanceId"="39275b85-fea4-4516-b399-xxxxxx"}
&ExistedInstanceEpcSet.2.EpcPara.3={"InstanceId"="13f363f3-b108-4e60-b15c-xxxxxx"}
&ExistedInstanceEpcSet.3.NodeRole=Worker
&ExistedInstanceEpcSet.3.EpcPara.1={"InstanceId"="cd434dad-77e7-4734-b8a7-xxxxxx"}

返回示例

{
    "RequestId": "c79283f6-49c5-4c18-ba74-xxxxxx",
    "ClusterId": "be502bb4-49e2-4572-ba63-xxxxxx"
}

金山云,开启您的云计算之旅

免费注册