-
Notifications
You must be signed in to change notification settings - Fork 28
api usage
#1 GET
- http://localhost:8589/v1/groups/{groupid}/engines
获取集群中某个 Group
下所有 Docker
节点的信息和状态。
Engines
: 为数组结构,包含 Group
下所有已在 Humpback
站点分组中注册的 Docker
服务节点
ID
: 节点唯一标识,可在 Docker
节点本地使用 docker info | grep ID
查看
Name
: 节点宿主机名称,由节点自动获取注册
IP
: 节点宿主机IP地址,由节点自动获取注册
APIAddr
: 节点运行的 Humpback-Agent
容器服务 API
地址
Cpus
: 节点 CPU
核数
Memory
: 节点物理内存大小,单位:MB
Labels
: 节点 Docker Daemon
部分标识,可在 Docker
启动时或在配置中添加 --label=xxx
来设置
StateText
: 节点状态描述,状态分为如下几种:
- Pending 节点正在加入集群状态
- Unhealthy 节点保留状态,后期扩展
- Healthy 节点在集群中,正常状态
- Disconnected 节点离线状态
/*Response*/
{
"Code": 0,
"Error": "request successed",
"Contnet": "group engines response",
"ResponseID": "b4116080-b954-4105-939e-86395399c40d",
"Data": {
"GroupId": "4d8c8b31-eba2-4882-bd61-6579d051a518",
"Engines": [
{
"ID": "6PBX:LVJJ:L3QG:DHWD:BWOU:XHDN:CRGB:CNVW:LKKB:S3JI:EDVQ:YSZL",
"Name": "BOBLIU1.DOCKER",
"IP": "192.168.2.80",
"APIAddr": "192.168.2.80:8500",
"Cpus": 4,
"Memory": 990,
"Labels": {
"kernelversion": "3.10.5-12.1.x86_64",
"location": "wh7",
"operatingsystem": "<unknown>",
"os": "centos6",
"storagedirver": "aufs"
},
"StateText": "Healthy"
},
{
"ID": "PHTU:CCAI:XFGP:G6BZ:WOPE:74HH:P6QK:I3GF:UQCL:SCWY:WP6U:67FN",
"Name": "BOBLIU2.DOCKER",
"IP": "192.168.2.81",
"APIAddr": "192.168.2.81:8500",
"Cpus": 4,
"Memory": 990,
"Labels": {
"kernelversion": "3.10.5-12.1.x86_64",
"location": "wh7",
"operatingsystem": "<unknown>",
"os": "centos6",
"storagedirver": "aufs"
},
"StateText": "Healthy"
}
]
}
}
#2 GET - http://localhost:8589/v1/groups/engines/192.168.2.81
根据一个 Docker
节点 IP
来获取集群中节点的信息和状态。
这个响应体中没有 GroupID
属性,意味着没有在 Humpback
站点分组中注册的节点只要加入集群,都可以被查询到。
/*Response*/
{
"Code": 0,
"Error": "request successed",
"Contnet": "engine response",
"ResponseID": "4f1f09f0-d095-43f0-ab0e-cdb25bacb332",
"Data": {
"Engine": {
"ID": "PHTU:CCAI:XFGP:G6BZ:WOPE:74HH:P6QK:I3GF:UQCL:SCWY:WP6U:67FN",
"Name": "BOBLIU2.DOCKER",
"IP": "192.168.2.81",
"APIAddr": "192.168.2.81:8500",
"Cpus": 4,
"Memory": 990,
"Labels": {
"kernelversion": "3.10.5-12.1.x86_64",
"location": "wh7",
"operatingsystem": "<unknown>",
"os": "centos6",
"storagedirver": "aufs"
},
"StateText": "Healthy"
}
}
}
#3 GET - http://localhost:8589/v1/groups/{groupid}/collections
获取集群中某个 Group
下所有被调度的容器信息,获取的数据中只包含通过集群模式创建的容器信息。
关于 Metas
属性,每次通过集群模式创建容器,系统会根据实例数创建一批容器并分散调度到不同的 Docker
节点上,该批次容器都统一由一个MetaData
结构来描述,并生成一个唯一的 MetaID
,以后涉及到该 Meta
的操作都会处理这些容器。
Metas
: 一个数组结构,Group
中会创建多批次容器,因此一个 Group
会存在多个 MetaData
MetaId
: MetaData
的唯一编号,代表某次创建的容器集合
Instances
: 容器实例数,正常情况下与 Containers
数量保持一致
WebHooks
: Hook API
回调路径
Config
: 初次创建 MetaData
时的配置信息,以后设计容器调度、迁移或修改实例数,系统都会以该 Config
信息来构造容器
Containers
: 包含MetaData
中所有容器实例信息和隶属节点情况,通过 IP
或 HostName
可以查到具体分配到了某个节点上
关于容器名称规则是按组编号前8位+Meta.ConfigName+索引方式组合,避免容器名称冲突。
/*Response*/
{
"Code": 0,
"Error": "request successed",
"Contnet": "group containers response",
"ResponseID": "017a3149-16d9-421c-8528-9d2379ec6556",
"Data": {
"GroupId": "4d8c8b31-eba2-4882-bd61-6579d051a518",
"Metas": [
{
"MetaId": "b2778cd3-9a8a-4ffe-9fd1-e5f14fd176c1",
"Instances": 2,
"WebHooks": [
{
"Url": "http://127.0.0.1:8871/api/hook/redis",
"SecretToken": ""
}
],
"Config": {
"Id": "",
"Image": "redis:3.2.9",
"Command": "",
"Name": "redis",
"Ports": [
{
"PrivatePort": 6379,
"PublicPort": 0,
"Type": "tcp",
"Ip": ""
}
],
"Volumes": null,
"Dns": null,
"Env": [
"env=dev"
],
"HostName": "testhostname",
"NetworkMode": "bridge",
"RestartPolicy": "always",
"RestartRetryCount": 2,
"Extrahosts": [
"hostname:IP"
],
"Links": null,
"Ulimits": null
},
"Containers": [
{
"IP": "192.168.2.82",
"HostName": "BOBLIU3.DOCKER",
"Container": {
"Id": "0c95c527ca1d5378ced1e9c8c6479d2cb1fa224d164b736444ee8d36e5890de0",
"Image": "redis:3.2.9",
"Command": "",
"Name": "CLUSTER-4d8c8b31-redis-1",
"Ports": [
{
"PrivatePort": 6379,
"PublicPort": 32684,
"Type": "tcp",
"Ip": "0.0.0.0"
}
],
"Volumes": [],
"Dns": null,
"Env": [
"env=dev",
"HUMPBACK_CLUSTER_GROUPID=4d8c8b31-eba2-4882-bd61-6579d051a518",
"HUMPBACK_CLUSTER_METAID=b2778cd3-9a8a-4ffe-9fd1-e5f14fd176c1",
"HUMPBACK_CLUSTER_CONTAINER_INDEX=1",
"HUMPBACK_CLUSTER_CONTAINER_ORIGINALNAME=CLUSTER-4d8c8b31-redis-1",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"HostName": "testhostname",
"NetworkMode": "bridge",
"Status": {
"Status": "",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 8921,
"ExitCode": 0,
"Error": "",
"StartedAt": "2017-04-10T14:38:02.179547213Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"RestartPolicy": "always",
"RestartRetryCount": 2,
"Extrahosts": [
"hostname:IP"
],
"Links": null,
"Ulimits": null
}
},
{
"IP": "192.168.2.80",
"HostName": "BOBLIU1.DOCKER",
"Container": {
"Id": "f493995421ffd924d18a697070c4aa8bfe148e1a0ebe9ed7665110be3f7a53b3",
"Image": "redis:3.2.9",
"Command": "",
"Name": "CLUSTER-4d8c8b31-redis-2",
"Ports": [
{
"PrivatePort": 5000,
"PublicPort": 32679,
"Type": "tcp",
"Ip": "0.0.0.0"
}
],
"Volumes": [],
"Dns": null,
"Env": [
"env=dev",
"HUMPBACK_CLUSTER_GROUPID=4d8c8b31-eba2-4882-bd61-6579d051a518",
"HUMPBACK_CLUSTER_METAID=b2778cd3-9a8a-4ffe-9fd1-e5f14fd176c1",
"HUMPBACK_CLUSTER_CONTAINER_INDEX=2",
"HUMPBACK_CLUSTER_CONTAINER_ORIGINALNAME=CLUSTER-4d8c8b31-redis-2",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"HostName": "testhostname",
"NetworkMode": "bridge",
"Status": {
"Status": "",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 8677,
"ExitCode": 0,
"Error": "",
"StartedAt": "2017-04-10T14:38:02.534519018Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"RestartPolicy": "always",
"RestartRetryCount": 2,
"Extrahosts": [
"hostname:IP"
],
"Links": null,
"Ulimits": null
}
}
]
}
]
}
}
#4 GET - http://localhost:8589/v1/groups/collections/{metaid}
获取集群中单个 MetaData
信息,在加载某个MetaData
详细页时可调用该接口
/*response*/
{
"Code": 0,
"Error": "request successed",
"Contnet": "group containers response",
"ResponseID": "2c43219e-d8b6-452f-b32c-96314bcbf09a",
"Data": {
"Meta": {
"MetaId": "b2778cd3-9a8a-4ffe-9fd1-e5f14fd176c1",
"Instances": 2,
"WebHooks": [
{
"Url": "http://127.0.0.1:8871/api/hook/redis",
"SecretToken": ""
}
],
"Config": {
"Id": "",
"Image": "redis:3.2.9",
"Command": "",
"Name": "redis",
"Ports": [
{
"PrivatePort": 6379,
"PublicPort": 0,
"Type": "tcp",
"Ip": ""
}
],
"Volumes": null,
"Dns": null,
"Env": [
"env=dev"
],
"HostName": "testhostname",
"NetworkMode": "bridge",
"RestartPolicy": "always",
"RestartRetryCount": 2,
"Extrahosts": [
"hostname:IP"
],
"Links": null,
"Ulimits": null
},
"Containers": [
{
"IP": "192.168.2.82",
"HostName": "BOBLIU3.DOCKER",
"Container": {
"Id": "0c95c527ca1d5378ced1e9c8c6479d2cb1fa224d164b736444ee8d36e5890de0",
"Image": "redis:3.2.9",
"Command": "",
"Name": "CLUSTER-4d8c8b31-redis-1",
"Ports": [
{
"PrivatePort": 6379,
"PublicPort": 32684,
"Type": "tcp",
"Ip": "0.0.0.0"
}
],
"Volumes": [],
"Dns": null,
"Env": [
"env=dev",
"HUMPBACK_CLUSTER_GROUPID=4d8c8b31-eba2-4882-bd61-6579d051a518",
"HUMPBACK_CLUSTER_METAID=b2778cd3-9a8a-4ffe-9fd1-e5f14fd176c1",
"HUMPBACK_CLUSTER_CONTAINER_INDEX=1",
"HUMPBACK_CLUSTER_CONTAINER_ORIGINALNAME=CLUSTER-4d8c8b31-redis-1",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"HostName": "testhostname",
"NetworkMode": "bridge",
"Status": {
"Status": "",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 8921,
"ExitCode": 0,
"Error": "",
"StartedAt": "2017-04-10T14:38:02.179547213Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"RestartPolicy": "always",
"RestartRetryCount": 2,
"Extrahosts": [
"hostname:IP"
],
"Links": null,
"Ulimits": null
}
},
{
"IP": "192.168.2.80",
"HostName": "BOBLIU1.DOCKER",
"Container": {
"Id": "f493995421ffd924d18a697070c4aa8bfe148e1a0ebe9ed7665110be3f7a53b3",
"Image": "redis:3.2.9",
"Command": "",
"Name": "CLUSTER-4d8c8b31-redis-2",
"Ports": [
{
"PrivatePort": 5000,
"PublicPort": 32679,
"Type": "tcp",
"Ip": "0.0.0.0"
}
],
"Volumes": [],
"Dns": null,
"Env": [
"env=dev",
"HUMPBACK_CLUSTER_GROUPID=4d8c8b31-eba2-4882-bd61-6579d051a518",
"HUMPBACK_CLUSTER_METAID=b2778cd3-9a8a-4ffe-9fd1-e5f14fd176c1",
"HUMPBACK_CLUSTER_CONTAINER_INDEX=2",
"HUMPBACK_CLUSTER_CONTAINER_ORIGINALNAME=CLUSTER-4d8c8b31-redis-2",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"HostName": "testhostname",
"NetworkMode": "bridge",
"Status": {
"Status": "",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 8677,
"ExitCode": 0,
"Error": "",
"StartedAt": "2017-04-10T14:38:02.534519018Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"RestartPolicy": "always",
"RestartRetryCount": 2,
"Extrahosts": [
"hostname:IP"
],
"Links": null,
"Ulimits": null
}
}
]
}
}
}
#5 GET - http://localhost:8589/v1/groups/collections/{metaid}/base
获取集群中单个 MetaData
的基础配置信息,不包括容器信息和分配的节点信息
/*response*/
{
"Code": 0,
"Error": "request successed",
"Contnet": "group containers meta response",
"ResponseID": "bfa76604-1a69-4fa3-8afa-b236f6c9b777",
"Data": {
"MetaBase": {
"GroupId": "4d8c8b31-eba2-4882-bd61-6579d051a518",
"MetaId": "b2778cd3-9a8a-4ffe-9fd1-e5f14fd176c1",
"Instances": 2,
"WebHooks": [
{
"Url": "http://127.0.0.1:8871/api/hook/redis",
"SecretToken": ""
}
],
"ImageTag": "3.2.9",
"Id": "",
"Image": "redis:3.2.9",
"Command": "",
"Name": "redis",
"Ports": [
{
"PrivatePort": 6379,
"PublicPort": 0,
"Type": "tcp",
"Ip": ""
}
],
"Volumes": null,
"Dns": null,
"Env": [
"env=gdev"
],
"HostName": "testhostname",
"NetworkMode": "bridge",
"RestartPolicy": "always",
"RestartRetryCount": 2,
"Extrahosts": [
"hostname:IP"
],
"Links": null,
"Ulimits": null
}
}
}