部署一个新的马拉松应用程序组,其层次结构如下所示(注意显示为yaml而不是json以提高可读性):
id: root_id
groups:
- id: data_center_id
groups:
- id: category_id
groups:
- id: app_or_svc_type_id
apps
- id: app_id
....
- id: app_id
....
- id: app_id
....
- id: app_or_svc_type_id
apps
- id: app_id
....
- id: app_id
....
- id: app_id
....
我现在想在类别级别添加一个额外的子组,所以现在看起来像这样:
id: root_id
groups:
- id: data_center_id
groups:
- id: category_id
groups:
- id: app_or_svc_type_id
apps
- id: app_id
....
- id: app_id
....
- id: app_id
....
- id: app_or_svc_type_id
apps
- id: app_id
....
- id: app_id
....
- id: app_id
....
# this is the new subgroup to add
- id: category_id
groups:
- id: app_or_svc_type_id
apps
- id: app_id
....
- id: app_id
....
- id: app_id
....
- id: app_or_svc_type_id
apps
- id: app_id
....
- id: app_id
....
- id: app_id
....
当我使用Marathon REST API通过PUT尝试此操作时,现有组将被销毁并创建新的子组。也许我在这里遗漏了一些东西,但是为了向现有的应用程序组层次结构添加新的微服务,这个功能至关重要。
感谢任何帮助
答案 0 :(得分:1)
我不太清楚你到底做了什么。告诉我们您确切的HTTP请求可能有所帮助。
您的问题可能是您的论坛和应用的ID不正确。有时,这会导致忽略的群组/应用没有任何错误:https://github.com/mesosphere/marathon/issues/1890
以下HTTP请求对我有用。
使用一个子组创建初始组:
PUT /v2/groups/group HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 185
Content-Type: application/json
Host: localhost:8080
User-Agent: HTTPie/0.9.2
{
"groups": [
{
"apps": [
{
"cmd": "python -m SimpleHTTPServer $PORT",
"id": "/group/subgroup1/app"
}
],
"id": "/group/subgroup1"
}
],
"id": "/group"
}
HTTP/1.1 200 OK
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache
Server: Jetty(8.1.15.v20140411)
Transfer-Encoding: chunked
X-Marathon-Leader: http://localhost:8080
{
"deploymentId": "6c59b425-49e2-4db8-8de0-a29020a34be7",
"version": "2015-07-28T12:00:01.171Z"
}
使用包含其他子组的新定义更新组:
PUT /v2/groups/group HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 335
Content-Type: application/json
Host: localhost:8080
User-Agent: HTTPie/0.9.2
{
"groups": [
{
"apps": [
{
"cmd": "python -m SimpleHTTPServer $PORT",
"id": "/group/subgroup1/app"
}
],
"id": "/group/subgroup1"
},
{
"apps": [
{
"cmd": "python -m SimpleHTTPServer $PORT",
"id": "/group/subgroup2/app"
}
],
"id": "/group/subgroup2"
}
],
"id": "/group"
}
HTTP/1.1 200 OK
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache
Server: Jetty(8.1.15.v20140411)
Transfer-Encoding: chunked
X-Marathon-Leader: http://localhost:8080
{
"deploymentId": "b72801f7-8a18-434e-bebb-81d55e698ef1",
"version": "2015-07-28T12:03:17.109Z"
}
现有的应用程序/组保持不变。
或者,您也可以对PUT
使用/v2/groups/group/subgroup2
请求,仅包含该子组的定义。
答案 1 :(得分:0)
要添加子组,只需PUT
或POST
完全指定其ID的子组,在您的案例/root_id/data_center_id/category_id
中。