集群API
查看集群鏡像列表
請求 header
GET /api/v1/apps/images
Authorization:Token xxxxxxxxxxxxxx Content-Type:application/json
返回
{ "custom_images": [ { "tag": "v1", "desc": "v1", "weight": 0, "id": 30202, "name": "4638_tomcat2", "constraint": null } ], "public_images": [ { "tag": "latest", "desc": "", "weight": 3, "id": 10005, "name": "centos", "constraint”: { "min_combo": 20, "max_combo": 50, "min_machine_spec": 10, "max_machine_spec": 40 } } ] }
參數說明 | 描述 | 類型 |
---|---|---|
custom_images | 自定義鏡像 | json array |
public_images | 官方鏡像 | json array |
tag | 鏡像 tag | string |
desc | 鏡像描述 | string |
weight | 權重 | int |
id | 鏡像 id | long |
name | 鏡像名稱 | string |
constraint | 鏡像限製 | json |
min_combo | 最小套餐 | int |
max_combo | 最大套餐 | int |
min_machine_spec | 最小機器規格 | int |
min_machine_spec | 最小機器規格 | int |
創建集群
請求 header
POST /api/v1/apps
Authorization:Token xxxxxxxxxxxxxx Content-Type:application/json
請求 payload
{ "name":"name", "desc":"desc", "domain":"www.abc.com", "image_type":1, "image_id":3, //可參考 查看集群鏡像列表 獲取 "spec_id": 1, "replicas":2, "env_var":{"key":"value"}, "version_control":{ "type":"git", "path":"https://github.com/NetEase/c.git", //此處僅為示例代碼,參數說明詳見下方 "subdir":"tomcat", "branch":"online", "version":"xxxx", "account":"example@163.com", "password":"123456" }, "docker_file_type":2, "custom_docker_file":"dockfile", "log_dirs":["dir1","dir2"] }
參數說明 | 描述 | 類型 | 是否必填 |
---|---|---|---|
name | 集群名稱 | string | 必填 |
desc | 集群描述 | string | 可填 |
domain | 域名 | string | 可填 |
image_type | 鏡像類型,1 (官方鏡像) / 2 (自定義鏡像) | int | 必填 |
image_id | 鏡像 id,可通過 查看集群鏡像列表 所述方法獲取 | int | 必填 |
spec_id | 服務規格 id,1 (微小型) / 10 (小型) / 20 (中型) / 30 (大型) / 40 (豪華型) / 50 (旗艦型) | int | 必填 |
replicas | 副本數量,有容量限製,不填默認為1 | int | 可填 |
env_var | 環境變量 | json | 可填 |
version_control | 版本管理 | json | 可填 |
type | 版本管理類型,git / svn | string | 可填 |
path | 代碼路徑 | string | 可填 |
subdir | 代碼子目錄 | string | 可填 |
branch | 代碼分支 | string | 可填 |
version | 代碼版本號 | string | 可填 |
account | 版本管理賬號 | string | 可填 |
password | 版本管理密碼 | string | 可填 |
docker_file_type | docker 文件類型,1 (自動生成) / 2 (自定義) | int | 可填 |
custom_docker_file | 自定義 docker file 在源碼中的路徑 | string | 可填 |
log_dirs | 日誌目錄 | json | 可填 |
- 成功響應
200 Ok { "id":1000, "url":"https://open.c.163.com/api/v1/hooks/app/44684185834f47f5bf6b3902b8fb939b" }
- 失敗響應 詳情請參見 錯誤返回碼。
參數說明 | 描述 | 類型 |
---|---|---|
id | 集群 id | long |
url | 集群 web hook url,當有代碼提交時,可嵌入此 url 進行持續部署發布。 | string |
修改集群
請求 header
PUT /api/v1/apps/{id}
Authorization:Token xxxxxxxxxxxxxx Content-Type:application/json
請求 payload
{ "desc":"appdesc", "env_var":{"key":"value"}, "version_control":{ "type":"git", "path":"https://www.github.com/example/test.git", "subdir":"tomcat", "branch":"online", "version":"xxxx", "account":"example@163.com", "password":"xxxx" }, "custom_docker_file":"dockfile", "log_dirs":["dir1","dir2"] }
參數說明 | 描述 | 類型 | 是否必填 |
---|---|---|---|
id | 集群 id | long | 必填 |
desc | 集群描述 | string | 可填 |
env_var | 環境變量 | json | 可填 |
version_control | 版本控製 | json | 可填 |
type | 版本控製類型,git/svn | string | 可填 |
path | 代碼路徑 | string | 可填 |
subdir | 代碼子目錄 | string | 可填 |
branch | 代碼分支 | string | 可填 |
version | 代碼版本號 | string | 可填 |
account | 版本管理賬號 | string | 可填 |
password | 版本管理密碼 | string | 可填 |
docker_file_type | docker 文件類型,1 (自動生成) / 2 (自定義) | int | 可填 |
custom_docker_file | 自定義 docker file 在源碼中的路徑 | string | 可填 |
log_dirs | 日誌目錄 | json | 可填 |
- 成功響應
200 Ok
- 失敗響應 詳情請參見 錯誤返回碼。
集群列表
請求 header
GET /api/v1/apps
Authorization:Token xxxxxxxxxxxxxx Content-Type:application/json
請求參數
limit=20&offset=0
參數說明 | 描述 | 類型 | 是否必填 |
---|---|---|---|
limit | 大於 0 小於等於 30,默認 20 | int | 可填 |
offset | 偏移量,大於等於 0,默認 0 | int | 可填 |
- 成功響應
200 Ok { "total": 1, "apps": [ { "id": 10702, "name": "ape2", "desc": "appdesc", "domain": "www.abc.com", "status": "create_fail", "replicas": 2, "volumes": [ { "name": "f9eb1b4428064f15b8aa95aad31e1bc4", "mount_path": "dir1", "readonly": false }, { "name": "a439b16783cd469cb66f17254503c72d", "mount_path": "dir2", "readonly": false } ], "charge_type": 2, "spec_id": 1, "created_at": "2016-03-25T04:57:48Z", "updated_at": "2016-03-25T04:57:48Z", "public_ip": null, "private_ip": null, "version_control": { "type": "git", "path": "https://www.github.com/example/test.git", "subdir": "tomcat", "branch": "online", "version": "xxxx", "account": "example@163.com", "password": "bec55f12a60bf849" }, "custom_docker_file": "dockfile", "image_id": 3, "containers": [ { "private_ip": "10.180.194.16", "container_id": 5ae7bfa878b335311434f6aeef60fcfdb55bd8c51c11ed2912b64ad95061efae" } ], "env_var": { "key": "value" }, "web_hook_url": https://open.c.163.com/api/v1/hooks/app/e9c80ebe17464f6d90d3e22f6ac77bad" } ] }
- 失敗響應 詳情請參見 錯誤返回碼。
參數說明 | 描述 | 類型 |
---|---|---|
id | 集群 id | long |
name | 集群名稱 | string |
desc | 集群描述 | string |
domain | 域名 | string |
status | 集群狀態,create_succ (創建成功) / create_fail (創建失敗) | string |
replicas | 副本數量,有容量限製,不填默認為 1 | int |
volumes | 日誌目錄 | json |
name | 日誌目錄名稱 | string |
mount_path | 日誌目錄掛載路徑 | string |
readonly | 是否隻讀 | boolean |
spec_id | 集群規格 id,1 (微小型) / 10 (小型) /20 (中型) /30 (大型) / 40 (豪華型) / 50 (旗艦型) | int |
created_at | 創建時間,使用 UTC(世界標準時間)時間,用 ISO8601 進行格式化 | string |
updated_at | 修改時間,使用 UTC(世界標準時間)時間,用 ISO8601 進行格式化 | string |
private_ip | 內網 ip | string |
public_ip | 外網 ip | string |
version_control | 版本控製 | json |
type | 版本控製類型,git/svn | string |
path | 代碼路徑 | string |
subdir | 代碼子目錄 | string |
branch | 代碼分支 | string |
version | 代碼版本號 | string |
account | 版本管理賬號 | string |
password | 版本管理密碼 | string |
custom_docker_file | 自定義 docker file 在源碼中的路徑 | string |
image_id | 鏡像 id | int |
containers | 容器實例列表 | json |
private_ip | 容器私有網 ip | string |
container_id | 容器 id | long |
env_var | 環境變量 | json |
web_hook_url | web hook url | string |
查看集群
請求 header
GET /api/v1/apps/{id}
Authorization:Token xxxxxxxxxxxxxx Content-Type:application/json
參數說明 | 描述 | 類型 | 是否必填 |
---|---|---|---|
id | 集群 id | long | 必填 |
- 成功響應
200 Ok { "id": 10702, "name": "name", "desc": "desc", "domain": "www.abc.com", "status": "creating", "replicas": 2, "volumes": [ { "name": "f9eb1b4428064f15b8aa95aad31e1bc4", "mount_path": "dir1", "readonly": false }, { "name": "a439b16783cd469cb66f17254503c72d", "mount_path": "dir2", "readonly": false } ], "charge_type": 2, "spec_id": 1, "created_at": "2016-03-25T04:57:48Z", "updated_at": "2016-03-25T04:57:48Z", "public_ip": null, "private_ip": null, "version_control": { "type": "git", "path": "https://www.github.com/example/test.git", "subdir": "tomcat", "branch": "online", "version": "xxxx", "account": "example@163.com", "password": "bec55f12a60bf849" }, "custom_docker_file": "dockfile", "image_id": 3, "containers": [ { "private_ip": "10.180.194.16", "container_id": 5ae7bfa878b335311434f6aeef60fcfdb55bd8c51c11ed2912b64ad95061efae" } ], "env_var": { "key": "value" }, "web_hook_url": "https://open.c.163.com/api/v1/hooks/app/e9c80ebe17464f6d90d3e22f6ac77bad" }
- 失敗響應 詳情請參見 錯誤返回碼。
參數說明 | 描述 | 類型 |
---|---|---|
id | 集群 id | long |
name | 集群名稱 | string |
desc | 集群描述 | string |
domain | 域名 | string |
status | 集群狀態,create_succ (創建成功) / create_fail (創建失敗) | string |
replicas | 副本數量,有容量限製,不填默認為 1 | int |
volumes | 日誌目錄 | json |
name | 日誌目錄名稱 | string |
mount_path | 日誌目錄掛載路徑 | string |
readonly | 是否隻讀 | boolean |
spec_id | 集群規格 id,1 (微小型) / 10 (小型) / 20 (中型) / 30 (大型) / 40 (豪華型) / 50 (旗艦型) | int |
created_at | 創建時間,使用 UTC(世界標準時間)時間,用 ISO8601 進行格式化 | string |
updated_at | 修改時間,使用 UTC(世界標準時間)時間,用 ISO8601 進行格式化 | string |
private_ip | 內網 ip | string |
public_ip | 外網 ip | string |
version_control | 版本控製 | json |
type | 版本控製類型,git/svn | string |
path | 代碼路徑 | string |
subdir | 代碼子目錄 | string |
branch | 代碼分支 | string |
version | 代碼版本號 | string |
account | 版本管理賬號 | string |
password | 版本管理密碼 | string |
custom_docker_file | 自定義 docker file 在源碼中的路徑 | string |
image_id | 鏡像 id | int |
containers | 容器實例列表 | json |
private_ip | 容器私有網 ip | string |
container_id | 容器 id | long |
env_var | 環境變量 | json |
web_hook_url | web hook url | string |
刪除集群
DELETE /api/v1/apps/{id}
請求 header
Authorization:Token xxxxxxxxxxxxxx
參數說明 | 描述 | 類型 | 是否必填 |
---|---|---|---|
id | 集群 id | long | 必填 |
- 成功響應
200 Ok
- 失敗響應 詳情請參見 錯誤返回碼。
集群擴容
請求 header
PUT /api/v1/apps/{id}/replications/{replicas}/actions/resize
Authorization:Token xxxxxxxxxxxxxx Content-Type:application/json
參數說明 | 描述 | 類型 | 是否必填 |
---|---|---|---|
id | 集群 id | long | 必填 |
replicas | 副本數 | int | 必填 |
- 成功響應
200 Ok
- 失敗響應 詳情請參見 錯誤返回碼。
監聽
支持長連接,超時或者對後端容器實例進行修改操作(創建、更新、回滾、重啟、刪除、擴縮容等)後即時返回。
請求 header
GET /api/v1/watch/apps/{id}
Authorization:Token xxxxxxxxxxxxxx Content-Type:application/json
參數說明 | 描述 | 類型 | 是否必填 |
---|---|---|---|
id | 集群 id | long | 必填 |
- 成功響應
200 Ok { { "private_ip": "10.180.194.16", "container_id": "5ae7bfa878b335311434f6aeef60fcfdb55bd8c51c11ed2912b64ad95061efae" } }
- 失敗響應 詳情請參見 錯誤返回碼。
參數說明 | 描述 | 類型 |
---|---|---|
containers | 容器實例列表 | json |
private_ip | 容器私有網 ip | string |
container_id | 容器 id | long |
最後更新:2017-01-03 10:48:53