1

Is it possible to scale up and down number of docker containers/instances using Mesosphere Marathon REST API?

Endpoint GET /deployments seems to be only option to see the next possible operation. How to scale up the instances using REST API (programmatically: possibly using curl script and without using the Marathon Web interface)?

janisz
  • 6,292
  • 4
  • 37
  • 70
ramanKC
  • 197
  • 1
  • 3
  • 16

1 Answers1

6

You should use PUT with JSON with only field "instances" with desired instances count (e.g., 2) and application ID (e.g., /foo).

PUT <marathon-url>/v2/apps/foo

{ "id": "/foo", "instances": 2 }

Note: Marathon 1.4 deprecates PUT semantic.

A PUT on /v2/apps has a PATCH like semantic: All values that are not defined in the json, will not update existing values. This was always the default behaviour in Marathon versions. For backward compatibility, we will not change this behaviour, but let users opt in for a proper PUT. The next version of Marathon will use PATCH and PUT as two separate actions.

janisz
  • 6,292
  • 4
  • 37
  • 70
  • Thanks @janisz. One thing I observed that url becomes something like : /v2/apps//foo. So with "/" in front of appid. – ramanKC Jun 27 '17 at 06:47
  • Hi @janisz, one more question. How to know number of running instances of specific appid (say /foo).? – ramanKC Jun 27 '17 at 07:02
  • AppID is prefixed with `/` to ensure it's absolute group ID. To get current instances you need to call `GET /v2/apps/foo`. If you want to get running/staged/killing instances try `GET /v2/apps/foo?embed=app.counts` and look for tasksStaged, tasksRunning, tasksHealthy, tasksUnhealthy – janisz Jun 27 '17 at 08:36