Tuesday, 7 May 2019

Deploying/Updating Marathon Docker image using API

I am writing code to update deployed image on marathon automatically. I use the REST patch method as listed in marathon API reference http://mesosphere.github.io/marathon/api-console/index.html

    url = 'https://<my-hostname>:<my-port>/v2/apps'
    h = {'Content-type': 'application/json', 'Accept': 'application/json'}
    data = {'app': { "id": app,
                'container': {
                    'docker': {
                        'image': image}}}}
    print ('requests.patch(%s, %s)' % (url + app, json.dumps(data)))
    r = requests.patch(url + app, headers = h, auth = auth, data = json.dumps(data))
    if r.status_code == 200:
        print('Deployed %s' % app)

The code ran successfully, I got back a Deployment ID, but nothing was changed from the UI. No new deployment is happening. If I change the patch request into get request without the data, I get back the image I previous updated in using code above.

According to this similar API reference https://docs.mesosphere.com/1.11/deploying-services/marathon-api/#/apps/V2AppsByAppId1

It says " This operation will create a deployment" but nothing happened. From the Marathon GUI, I don't see the configuration getting changed at all. If I restart, it is the same old deployment getting restarted. Am I interpreting the API reference incorrectly?



from Deploying/Updating Marathon Docker image using API

No comments:

Post a Comment