创建服务
更新时间:2026-01-28
接口描述
创建服务
注意:创建服务挂载BOS存储,需要提前在资源池安装BOSFS,安装请联系技术支持人员。
请求结构
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": [ // 一定要带/bin/sh -c
46 "/bin/sh",
47 "-c",
48 "sleep inf" # 将"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": [ #只使用一种则只填写一种即可,与volumns保持一致
62 {
63 "volumnName": "bos0vc7w305", # bos的volumeName,volumeMounts中挂载的BOS卷名称必须与volumes 中定义的名称保持一致
64 "mountPath": "/mnt/aihc_model_dir", #bos的目标路径
65 "readOnly": false # 是否只读
66 },
67 {
68 "volumnName": "pfsvl4iutqd", # pfs的volumeName,volumeMounts中挂载的pfs卷名称必须与volumes 中定义的名称保持一致
69 "mountPath": "/vllm-works/models", #pfs的目标路径
70 "readOnly": false
71 }
72 ],
73 "startupsProbe": null,
74 "readinessProbe": null,
75 "livenessProbe": null
76 }
77 ],
78 "storage": {
79 "shmSize": 7,
80 "volumns": [
81 {
82 "volumeType": "bos", #bos类型挂载
83 "volumnName": "bos0vc7w305", #bos的volumeName
84 "pfs": null,
85 "hostpath": null,
86 "dataset": {},
87 "bos": {
88 "secret": {
89 "name": "",
90 "namespace": "aihc-pom"
91 },
92 "sourcePath": "aihc-models-bj/Qwen/Qwen3-0.6B-FP8" #bos的源路径
93 }
94 },
95 {
96 "volumeType": "pfs", #pfs类型挂载
97 "volumnName": "pfsvl4iutqd", #pfs的volumeName
98 "pfs": {
99 "instanceId": "pfs-DjKrQp", #pfs实例ID,即资源池页面中存储信息项的PFS ID
100 "instanceType": "",
101 "hostMountPath": "",
102 "mountTargetId": [],
103 "clusterIP": "",
104 "clientID": "pfs-DjKrQp", #pfs实例ID,即资源池页面中存储信息项的PFS ID
105 "clusterPort": "",
106 "sourcePath": "/mnt/model" #pfs的源路径
107 },
108 "hostpath": null
109 }
110 ]
111 },
112 "access": {
113 "publicAccess": false,
114 "networkType": "aiGateway",
115 "aiGateway": {
116 "enableAuth": true
117 }
118 }
119}
返回示例
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}
