marathon通过api更新update app id

marathon api 方法

发布程序:

1
2
例如: json文件名为  nginx-test.json
curl -X POST http://10.0.0.25:8080/v2/apps -d @nginx-test.json -H "Content-type: application/json”

更新程序:

1
2
3
4
例如: nginx-test 这个app
更新 nginx-test.json
id 为 : /nginx/nginx-test
curl -X PUT http://10.0.0.25:8080/v2/apps/nginx/nginx-test -d @nginx-test.json -H "Content-type: application/json”

强制杀掉 deployment:

1
2
3
4
5
6
marathonAddr="http://ip:8080";
deployment_id="1463-672-414-839-cb32";
apiPath="/v2/deployments/${deployment_id}"
curl -X DELETE ${marathonAddr}${apiPath}?force=true

curl -X DELETE http://localhost:8080/v2/apps/io-test?force=true -H "Content-type: application/json"

更新某个变量:

1
2
3
4
5
6
7
8
9
10
# 更新实例数
curl -XPUT localhost:8080/v2/apps/path/to/app/app123 -d '{"instances":20}'

# 更新节点亲和性
ID=/test/abc123
curl -u user1:passwd -H "Content-type: application/json" -X PUT http://localhost:8080/v2/apps${ID} -d '{"constraints": [["node1", "LIKE", "true"]]}'

# 更新j镜像
ID=/test/abc123
curl -u user1:passwd -H "Content-type: application/json" -X PUT http://localhost:8080/v2/apps${ID} -d '{"container": {"docker": {"image":"nginx:1.13"}}}'

获取 app 信息

1
2
# 获取到所有的id
curl -s http://cmc-marathon.inc-mtime.com/v2/apps | jq .apps[].id

restart

1
2
ID=/test/test-mysql
curl -u user:passwd123 -X POST -H "Content-type: application/json" http://localhost:8080/v2/apps/${ID}/restart
感谢您的支持!