创建BEC容器服务
更新时间:2022-05-17
接口描述
本接口用于创建BEC容器服务。
请求结构
POST /v2/service/create?clientToken={clientToken} HTTP/1.1
Host: bec.baidubce.com
Authorization: authorization string
{
"bandwidth": 0,
"containerGroupName": "",
"containers": [
{
"args": [],
"commands": [],
"cpu": 0,
"envs": [
{
"name": "",
"value": "",
"valueFrom": {
"configMapKeyRef": {
"key": "",
"name": "",
"optional": true
},
"fieldRef": {
"apiVersion": "",
"fieldPath": ""
},
"resourceFieldRef": {
"containerName": "",
"divisor": "",
"resource": ""
},
"secretKeyRef": {
"key": "",
"name": "",
"optional": true
}
}
}
],
"imageAddress": "",
"imageVersion": "",
"memory": 0,
"name": "",
"ports": [
{
"containerPort": 0,
"hostIP": "",
"hostPort": 0,
"name": "",
"protocol": ""
}
],
"volumeMounts": [
{
"mountPath": "",
"mountPropagation": "",
"name": "",
"readOnly": true,
"subPath": ""
}
],
"workingDir": ""
}
],
"deployInstances": [
{
"city": "",
"region": "",
"regionId": "",
"replicas": 0,
"serviceProvider": ""
}
],
"imageRegistrySecrets": [
{
"name": ""
}
],
"kernelParam": "",
"needIpv6PublicIp": true,
"needPublicIp": true,
"paymentMethod": "",
"serviceName": "",
"volumes": {
"configMap": [
{
"name": ""
}
],
"emptyDir": [
{
"name": ""
}
],
"secret": [
{
"name": ""
}
],
"volumeClaimTemplates": [
{
"diskType": "",
"name": "",
"storageSize": 0
}
]
}
}
请求参数
参数名称 | 参数说明 | 请求类型 | 是否必须 | 数据类型 |
---|---|---|---|---|
request | 创建Service请求体 | body | 是 | PurchaseRequest |
bandwidth | 当needPublicIp为true时,用于设置外网带宽,取值范围为1Mps~2048Mps, 可开通白名单上限增加到5120Mps。 |
否 | integer | |
containerGroupName | 容器组名称 | 是 | string | |
containers | 容器组信息 | 是 | array | |
args | 容器启动参数 | 否 | array | |
commands | 容器启动命令 | 否 | array | |
cpu | 容器申请的CPU核数 | 否 | integer | |
envs | 容器环境变量 | 否 | array | |
imageAddress | 镜像地址 | 否 | string | |
imageVersion | 镜像版本 | 否 | string | |
memory | 容器申请的内存大小 | 否 | integer | |
name | 容器的名称 | 否 | string | |
ports | 容器端口协议 | 否 | array | |
containerPort | 容器暴露在POD上的端口,取值范围 0 ~ 65536. | 是 | integer | |
protocol | 容器暴露端口协议,必须是UDP、TCP、SCTP其中一种。默认是TCP。 | 否 | string | |
volumeMounts | 容器数据卷信息 | 否 | array | |
mountPath | 容器数据卷挂载路径 | 是 | string | |
name | 容器数据卷名称。 | 是 | string | |
readOnly | 容器数据卷是否只读,默认否 | 否 | boolean | |
workingDir | 容器工作目录 | 否 | string | |
deployInstances | 部署地域信息。 | 是 | array | |
city | 服务部署的城市 | 否 | string | |
region | 服务部署的地域 | 否 | string | |
regionId | 服务部署的节点ID | 否 | string | |
replicas | 服务部署的副本数 | 否 | integer | |
serviceProvider | 服务部署的运营商,可用值:BGP,CHINA_MOBILE,CHINA_UNICOM, CHINA_TELECOM,TRIPLE_LINE,INTRA |
否 | string | |
imageRegistrySecrets | 镜像仓库凭据 | 否 | array | |
name | 镜像仓库凭据名称 | 否 | string | |
needIpv6PublicIp | 是否开通IPv6公网。true:开通;false:不开通。缺省为false。 | 否 | boolean | |
needPublicIp | 是否购买公网IP。true:购买;false:未购买;缺省为false。 | 否 | boolean | |
paymentMethod | 付费方式,只支持后付费postpay | 否 | string | |
serviceName | 服务名称 | 是 | string | |
volumes | 存储卷信息 | 否 | Volume | |
configMap | configMap存储卷 | 否 | array | |
name | 存储卷名称 | 否 | string | |
emptyDir | emptyDir存储卷 | 否 | array | |
name | 存储卷名称 | 否 | string | |
secret | 密钥 & 凭据存储卷 | 否 | array | |
name | 存储卷名称 | 否 | string | |
volumeClaimTemplates | 数据盘存储卷 | 否 | array | |
diskType | 数据盘存储卷类型(HDD类型:NVME,SSD类型:SATA), 可用值:NVME,SATA,CDS_HDD,CDS_SSD,RBD_SSD,HDD_PASSTHROUGH,SSD_PASSTHROUGH |
否 | string | |
name | 存储卷名称 | 否 | string | |
storageSize | 数据盘存储卷容量大小 | 否 | integer | |
clientToken | 幂等性Token,是一个长度不超过64位的ASCII字符串 | query | 否 | string |
响应头域
除公共头域外,无其它特殊头域。
响应参数
参数名称 | 参数说明 | 类型 |
---|---|---|
deployInstances | 服务部署实例信息 | array |
city | 城市 | string |
cityName | 城市中文名 | string |
country | 国家 | string |
countryName | 国家中文名 | string |
networkType | 网络类型 | string |
region | 区域 | string |
regionName | 区域中文名 | string |
replicas | 副本数量 | integer |
serviceProvider | 运营商,可用值:BGP,CHINA_MOBILE,CHINA_UNICOM, CHINA_TELECOM,TRIPLE_LINE,INTRA |
string |
spName | 运营商中文名 | string |
lastUpdateTime | string | |
regions | 服务部署区域个数 | integer |
runningPods | 服务RUNNING POD数 | integer |
serviceId | 服务Id | string |
serviceName | 服务名称 | string |
status | 资源状态,可用值:STARTING,RUNNING,PENDING,EXCEPTION, FAILED,UNKNOWN,TERMINATED,WAITING,STOP,BINDING,STOPPING, TERMINATING,DELETING,NORMAL |
string |
totalCpu | 服务CPU总数 | integer |
totalDisk | 服务磁盘总数 | integer |
totalGpu | 服务GPU总数 | integer |
totalMem | 服务内存总数 | integer |
totalPods | 服务POD总数 | integer |
错误码
请参照错误返回章节的内容。
请求示例
POST /v2/service/create HTTP/1.1
Host: bec.baidubce.com
Authorization: authorization string
{
"serviceName": "baidu-bec",
"paymentMethod": "postpay",
"containerGroupName": "baidu-bec-pod",
"needPublicIp": true,
"needIpv6PublicIp": false,
"bandwidth": 100,
"containers": [{
"name": "containers1",
"imageAddress": "nginx",
"imageVersion": "v1.0",
"cpu": 4,
"memory": 8,
"workingDir": "/home",
"commands": [
"/bin/sh"
],
"args": [
"sleep 3600"
],
"ports": [{
"containerPort": 80,
"protocol": "TCP"
}],
"envs": [{
"name": "name",
"value": "baidu"
}],
"volumeMounts": [{
"name": "baidu-config",
"readOnly": false,
"mountPath": "/temp"
}]
}],
"tags": [{
"tagKey": "service",
"tagValue": "bec"
}],
"deployInstances": [{
"regionId":"cn-shanghai-ct",
"region":"EAST_CHINA",
"city":"SHANGHAI",
"serviceProvider": "CHINA_TELECOM",
"replicas": 1
}],
"volume": {
"secret": [{
"name": ""
}],
"configMap": [{
"name": "baidu-config"
}],
"volumeClaimTemplates": [{
"name": "volume",
"storageSize": 1,
"diskType": "NVME"
}],
"emptyDir": [{
"name": ""
}]
},
"imageRegistrySecrets": [{
"name": ""
}]
}
响应示例
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Date: Wed, 08 Jul 2015 03:28:11 GMT
x-bce-request-id: d8752367-38e8-45e4-b4c7-e53be3137ce5
Server: BWS
{
"result": true,
"action": "Create service",
"details": {
"serviceId": "s-ux1yo52o",
"serviceName": "test-**-**",
"level": null,
"status": "RUNNING",
"totalCpu": 1,
"totalMem": 2,
"totalGpu": 0,
"totalDisk": 0,
"regions": 1,
"totalPods": 1,
"runningPods": 1,
"tagsMap": null,
"deployInstances": [
{
"regionId": "cn-**-cm",
"replicas": 1,
"region": "**",
"serviceProvider": "**",
"city": "**",
"regionName": "**",
"spName": "**",
"cityName": "**",
"country": "CHINA",
"countryName": "**"
}
],
"createTime": null,
"lastUpdateTime": null
}
}