如何使用Marathon Rest API知道容器名称 [英] how know container name with marathon rest API

查看:339
本文介绍了如何使用Marathon Rest API知道容器名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Apache Mesos + Marathon + Zookeeper来部署我的rails应用程序. 我需要在Rails应用程序和其他容器之间共享数据.我在这里找到了一些与马拉松比赛有关的参考,如下所示:

I'm using Apache Mesos + Marathon + Zookeeper to deploy my rails app. I need share data between rails app and other container. I found some reference here to do it with marathon as follow:

marathon/docs/native-docker.html

{
"id": "privileged-job",
"container": {
    "docker": {
        "image": "mesosphere/inky"
        "privileged": true,
        "parameters": [
            { "key": "hostname", "value": "a.corp.org" },
            { "key": "volumes-from", "value": "another-container" },
            { "key": "lxc-conf", "value": "..." }
        ]
    },
    "type": "DOCKER",
    "volumes": []
},
"args": ["hello"],
"cpus": 0.2,
"mem": 32.0,
"instances": 1
}

但是我找不到找到我的Rails应用程序容器名称的方法,因为马拉松比赛使用以下格式分配名称:"mesos-uuid".有解决的办法吗?还是通过马拉松从容器中共享体积的另一种方法?

But I can't found a way to discover a name of my rails app container because marathon assign names with format: "mesos-uuid". Any idea to solve it? or another way to share volume from containers with marathon?

推荐答案

您可以添加约束添加到您的应用中,以将其强制放置到特定主机上.

You can add constraints to your app to force them onto specific hosts.

在简单的情况下,您可以执行以下操作将应用强制到特定主机上:

In a simple case, you could do something like this to force an app onto a specific host:

{
 "instances": 1,
 "constraints": [["hostname", "LIKE", "worker-1"]]
}

下一个选项引入属性. 您可以使用一些自定义标签来标记已知数量的主机(比方说3个).

The next option brings in attributes. You can tag a known number of hosts (let's say 3) with some custom tag.

然后您的应用程序定义如下:

Then your app definition could look like this:

{
 "instances": 3,
 "constraints": [
   ["hostname", "UNIQUE"],
   ["your-custom-tag", "GROUP_BY"]
 ]
}

您要将其添加到两个应用程序的应用程序定义中,从而导致每个实例的一个实例都在您标记的所有三个从属服务器上运行.

You'd add this to the app definition for both of your apps, resulting in one instance of each running on all three slaves you tagged.

有关设置属性的信息,请参见参考文档.

See the a reference doc on setting attributes.

这篇关于如何使用Marathon Rest API知道容器名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆