创建服务
更新时间:2025-05-26
接口描述
创建服务
请求结构
Bash
1POST ?action=CreateService
2HTTP/1.1
3Host:aihc.bj.baidubce.com
4version: v2
5Authorization:authorization string
6{
7 "log": {
8 "persistent": persistent
9 },
10 "instanceCount": instanceCount,
11 "misc": {
12 "podAnnotations": podAnnotations,
13 "podLabels": podLabels,
14 "gracePeriodSec": gracePeriodSec,
15 "fedPodsPerIns": fedPodsPerIns
16 },
17 "resourcePool": {
18 "resourcePoolId": resourcePoolId,
19 "resourcePoolName": resourcePoolName,
20 "queueName": queueName,
21 "resourcePoolType": resourcePoolType
22 },
23 "deploy": {
24 "schedule": {
25 "priority": priority
26 },
27 "canaryStrategy": {
28 "maxSurge": maxSurge,
29 "maxUnavailable": maxUnavailable
30 }
31 },
32 "name": name,
33 "acceleratorType": acceleratorType,
34 "workloadType": workloadType,
35 "containers": [
36 {
37 "name": name,
38 "cpus": cpus,
39 "memory": memory,
40 "acceleratorCount": acceleratorCount,
41 "command": command,
42 "ports": [
43 {
44 "name": name,
45 "port": port
46 }
47 ],
48 "envs": envs,
49 "image": {
50 "imageType": imageType,
51 "imageUrl": imageUrl
52 },
53 "volumeMounts": volumeMounts,
54 "startupsProbe": startupsProbe,
55 "readinessProbe": readinessProbe,
56 "livenessProbe": livenessProbe
57 }
58 ],
59 "access": {
60 "publicAccess": publicAccess,
61 "networkType": networkType,
62 "aiGateway": {
63 "enableAuth": enableAuth
64 }
65 }
66}
请求头域
除公共头域外,无其它特殊头域。
请求参数
参数名称 | 参数类型 | 是否必须 | 参数位置 | 参数说明 |
---|---|---|---|---|
clientToken | String | 否 | query | clientToken保证请求的幂等性 |
serviceConf | ServiceConf | 是 | body | 服务详情 |
返回头域
除公共头域,无其它特殊头域。
返回参数
参数名称 | 类型 | 说明 |
---|---|---|
requestId | String | 标识唯一请求,用于日志排查,在body返回 |
serviceId | String | 服务ID |
请求示例
Bash
1POST /?action=CreateService
2HTTP/1.1
3Host:aihc.bj.baidubce.com
4version: v2
5Authorization:authorization string
6{
7 "log": {
8 "persistent": false
9 },
10 "instanceCount": 1,
11 "misc": {
12 "podAnnotations": {
13 "prometheus.io/scrape": "false"
14 },
15 "podLabels": {
16 "scheduling.volcano.sh/group-min-member": "1"
17 },
18 "gracePeriodSec": 30,
19 "fedPodsPerIns": 0
20 },
21 "resourcePool": {
22 "resourcePoolId": "cce-7t7mqjci",
23 "resourcePoolName": "aihc-pom",
24 "queueName": "default",
25 "resourcePoolType": ""
26 },
27 "deploy": {
28 "schedule": {
29 "priority": "high"
30 },
31 "canaryStrategy": {
32 "maxSurge": 25,
33 "maxUnavailable": 25
34 }
35 },
36 "name": "openapi-test-3",
37 "acceleratorType": "",
38 "workloadType": "",
39 "containers": [
40 {
41 "name": "custom-container",
42 "cpus": 1,
43 "memory": 2,
44 "acceleratorCount": 0,
45 "command": [
46 "/bin/sh",
47 "-c",
48 "sleep inf"
49 ],
50 "ports": [
51 {
52 "name": "HTTP",
53 "port": 10088
54 }
55 ],
56 "envs": {},
57 "image": {
58 "imageType": 0,
59 "imageUrl": "registry.baidubce.com/inference/vllm-openai:v0.8.3"
60 },
61 "volumeMounts": [],
62 "startupsProbe": null,
63 "readinessProbe": null,
64 "livenessProbe": null
65 }
66 ],
67 "access": {
68 "publicAccess": false,
69 "networkType": "aiGateway",
70 "aiGateway": {
71 "enableAuth": true
72 }
73 }
74}
返回示例
Bash
1HTTP/1.1 200 OK
2x-bce-request-id: 0ed611a9-b3bd-416c-9f7f-a05be5c2091d
3Date: Fri, 16 Aug 2024 06:29:48 GMT
4Content-Type: application/json;charset=UTF-8
5Server: Service
6{
7 "requestId": "0ed611a9-b3bd-416c-9f7f-a05be5c2091d",
8 "serviceId": "s-rb7bcd92fe75"
9}