使用MarathonJSON创建新的实现

k3fezbri  于 2021-06-21  发布在  Mesos
关注(0)|答案(1)|浏览(247)

我们一直在探索如何部署到docker集群中。在应用架构中,我们有一个postgresql数据库,应用服务器需要访问该数据库。
在开发阶段,我们依靠fig在docker之间创建链接,然后使用docker施加的环境变量连接到目的地(app server到postgresql)
然而,在marathon中,我们找不到类似的方法,我们尝试使用依赖项,但没有成功,下面是我们的marathon.json文件

{
    "id": "/project",
    "groups": [
        {
            "id": "apps",
            "apps": [
                {
                    "id": "app",
                    "mem": 1024,
                    "env": {
                        "APP_HOME": "/var/lib/app",
                        "GIT_BRANCH": "release/2.0.0",
                        "SETTING_FILE": "development",
                        "BROKER_URL": "redis://redis_1:6379/0"
                    },
                    "dependencies": ["database", "caching", "messaging"],
                    "container": {
                        "type": "DOCKER",
                        "docker": {
                            "image": "xxx/aok:app"
                        }
                    },
                    "volumes": [
                        {
                            "containerPath": "/var/lib/app",
                            "hostPath": ".",
                            "mode": "RW"
                        }
                    ]
                },
                {
                    "id": "celery",
                    "mem": 1024,
                    "env": {
                        "APP_HOME": "/var/lib/app",
                        "GIT_BRANCH": "release/2.0.0",
                        "SETTING_FILE": "development",
                        "BROKER_URL": "redis://redis_1:6379/0"
                    },
                    "container": {
                        "type": "DOCKER",
                        "docker": {
                            "image": "xxx/aok:celery"
                        }
                    },
                    "volumes": [
                        {
                            "containerPath": "/var/lib/app",
                            "hostPath": ".",
                            "mode": "RW"
                        }
                    ]
                },
                {
                    "id": "celeryhb",
                    "mem": 1024,
                    "env": {
                        "APP_HOME": "/var/lib/app",
                        "GIT_BRANCH": "release/2.0.0",
                        "SETTING_FILE": "development",
                        "BROKER_URL": "redis://redis_1:6379/0"
                    },
                    "container": {
                        "type": "DOCKER",
                        "docker": {
                            "image": "xxx/aok:celeryhb"
                        }
                    },
                    "volumes": [
                        {
                            "containerPath": "/var/lib/app",
                            "hostPath": ".",
                            "mode": "RW"
                        }
                    ]
                }
            ]
        },
        {
            "id": "database",
            "apps": [
                {
                    "id": "pg",
                    "mem": 1024,
                    "container": {
                        "type": "DOCKER",
                        "docker": {
                            "image": "mughrabi/aok:pg"
                        },
                        "volumes": [
                            {
                                "containerPath": "/var/lib/postgresql/data",
                                "hostPath": "/tmp/aok-postgres-data",
                                "mode": "RW"
                            }
                        ]
                    }
                }
            ]
        },
        {
            "id": "caching",
            "apps": [
                {
                    "id": "redis",
                    "mem": 1024,
                    "container": {
                        "type": "DOCKER",
                        "docker": {
                            "image": "redis"
                        }
                    }
                }
            ]
        },
        {
            "id": "messaging",
            "apps": [
                {
                    "id": "rabbitmq",
                    "mem": 1024,
                    "container": {
                        "type": "DOCKER",
                        "docker": {
                            "image": "rabbitmq"
                        }
                    }
                }
            ]
        }
    ]
}

有人能告诉我吗?

0s0u357o

0s0u357o1#

研究一下用领事之类的东西https://www.consul.io/ 或etcdhttps://github.com/coreos/etcd

相关问题