创建BEC容器服务
更新时间:2022-05-17
接口描述
本接口用于创建BEC容器服务。
请求结构
Plain Text
1POST /v2/service/create?clientToken={clientToken} HTTP/1.1
2Host: bec.baidubce.com
3Authorization: authorization string
4
5{
6 "bandwidth": 0,
7 "containerGroupName": "",
8 "containers": [
9 {
10 "args": [],
11 "commands": [],
12 "cpu": 0,
13 "envs": [
14 {
15 "name": "",
16 "value": "",
17 "valueFrom": {
18 "configMapKeyRef": {
19 "key": "",
20 "name": "",
21 "optional": true
22 },
23 "fieldRef": {
24 "apiVersion": "",
25 "fieldPath": ""
26 },
27 "resourceFieldRef": {
28 "containerName": "",
29 "divisor": "",
30 "resource": ""
31 },
32 "secretKeyRef": {
33 "key": "",
34 "name": "",
35 "optional": true
36 }
37 }
38 }
39 ],
40 "imageAddress": "",
41 "imageVersion": "",
42 "memory": 0,
43 "name": "",
44 "ports": [
45 {
46 "containerPort": 0,
47 "hostIP": "",
48 "hostPort": 0,
49 "name": "",
50 "protocol": ""
51 }
52 ],
53 "volumeMounts": [
54 {
55 "mountPath": "",
56 "mountPropagation": "",
57 "name": "",
58 "readOnly": true,
59 "subPath": ""
60 }
61 ],
62 "workingDir": ""
63 }
64 ],
65 "deployInstances": [
66 {
67 "city": "",
68 "region": "",
69 "regionId": "",
70 "replicas": 0,
71 "serviceProvider": ""
72 }
73 ],
74 "imageRegistrySecrets": [
75 {
76 "name": ""
77 }
78 ],
79 "kernelParam": "",
80 "needIpv6PublicIp": true,
81 "needPublicIp": true,
82 "paymentMethod": "",
83 "serviceName": "",
84 "volumes": {
85 "configMap": [
86 {
87 "name": ""
88 }
89 ],
90 "emptyDir": [
91 {
92 "name": ""
93 }
94 ],
95 "secret": [
96 {
97 "name": ""
98 }
99 ],
100 "volumeClaimTemplates": [
101 {
102 "diskType": "",
103 "name": "",
104 "storageSize": 0
105 }
106 ]
107 }
108}
请求参数
参数名称 | 参数说明 | 请求类型 | 是否必须 | 数据类型 |
---|---|---|---|---|
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 |
错误码
请参照错误返回章节的内容。
请求示例
Plain Text
1 POST /v2/service/create HTTP/1.1
2 Host: bec.baidubce.com
3 Authorization: authorization string
4 {
5 "serviceName": "baidu-bec",
6 "paymentMethod": "postpay",
7 "containerGroupName": "baidu-bec-pod",
8 "needPublicIp": true,
9 "needIpv6PublicIp": false,
10 "bandwidth": 100,
11 "containers": [{
12 "name": "containers1",
13 "imageAddress": "nginx",
14 "imageVersion": "v1.0",
15 "cpu": 4,
16 "memory": 8,
17 "workingDir": "/home",
18 "commands": [
19 "/bin/sh"
20 ],
21 "args": [
22 "sleep 3600"
23 ],
24 "ports": [{
25 "containerPort": 80,
26 "protocol": "TCP"
27 }],
28 "envs": [{
29 "name": "name",
30 "value": "baidu"
31 }],
32 "volumeMounts": [{
33 "name": "baidu-config",
34 "readOnly": false,
35 "mountPath": "/temp"
36
37 }]
38 }],
39 "tags": [{
40 "tagKey": "service",
41 "tagValue": "bec"
42 }],
43 "deployInstances": [{
44 "regionId":"cn-shanghai-ct",
45 "region":"EAST_CHINA",
46 "city":"SHANGHAI",
47 "serviceProvider": "CHINA_TELECOM",
48 "replicas": 1
49 }],
50 "volume": {
51 "secret": [{
52 "name": ""
53 }],
54 "configMap": [{
55 "name": "baidu-config"
56 }],
57 "volumeClaimTemplates": [{
58 "name": "volume",
59 "storageSize": 1,
60 "diskType": "NVME"
61 }],
62 "emptyDir": [{
63 "name": ""
64 }]
65 },
66 "imageRegistrySecrets": [{
67 "name": ""
68 }]
69 }
响应示例
Plain Text
1HTTP/1.1 200 OK
2Content-Type: application/json;charset=UTF-8
3Date: Wed, 08 Jul 2015 03:28:11 GMT
4x-bce-request-id: d8752367-38e8-45e4-b4c7-e53be3137ce5
5Server: BWS
6{
7 "result": true,
8 "action": "Create service",
9 "details": {
10 "serviceId": "s-ux1yo52o",
11 "serviceName": "test-**-**",
12 "level": null,
13 "status": "RUNNING",
14 "totalCpu": 1,
15 "totalMem": 2,
16 "totalGpu": 0,
17 "totalDisk": 0,
18 "regions": 1,
19 "totalPods": 1,
20 "runningPods": 1,
21 "tagsMap": null,
22 "deployInstances": [
23 {
24 "regionId": "cn-**-cm",
25 "replicas": 1,
26 "region": "**",
27 "serviceProvider": "**",
28 "city": "**",
29 "regionName": "**",
30 "spName": "**",
31 "cityName": "**",
32 "country": "CHINA",
33 "countryName": "**"
34 }
35 ],
36 "createTime": null,
37 "lastUpdateTime": null
38 }
39}