2
votes

In my environment running mesos-slave, mesos-master marathon and mesos-dns in standalone mode. I deployed mysql app to marathon to run as docker container.

MySql app configurations as follows.

{
    "id": "mysql",
    "cpus": 0.5,
    "mem": 512,
    "instances": 1,
    "container": {
        "type": "DOCKER",
        "docker": {
            "image": "mysql:5.6.27",
            "network": "BRIDGE",            
              "portMappings": [
                {
                  "containerPort": 3306,
                  "hostPort": 32000,
                  "protocol": "tcp"
                }
                ]
        }
    },
    "constraints": [
            [
              "hostname",
              "UNIQUE"
            ]],
    "env": {
        "MYSQL_ROOT_PASSWORD": "password"   
    },
      "minimumHealthCapacity" :0,
      "maximumOverCapacity" : 0.0
}

Then I deploy app called mysql client. Mysql client app needs to connect to mysql app.

mysql app config as follows.

{
    "id": "mysqlclient",
    "cpus": 0.3,
    "mem": 512.0,
    "cmd": "/scripts/create_mysql_dbs.sh",
    "instances": 1,
    "container": {
        "type": "DOCKER",
        "docker": {
            "image": "mysqlclient:latest",
            "network": "BRIDGE",            
            "portMappings": [{
                "containerPort": 3306,
                "hostPort": 0,
                "protocol": "tcp"
            }]
        }
    },
    "env": {
        "MYSQL_ENV_MYSQL_ROOT_PASSWORD": "password",
        "MYSQL_PORT_3306_TCP_ADDR": "mysql.marathon.slave.mesos.",
        "MYSQL_PORT_3306_TCP_PORT": "32000"     
    },
      "minimumHealthCapacity" :0,
      "maximumOverCapacity" : 0.0
}

My mesos-dns config.json. as follows

{
  "zk": "zk://127.0.0.1:2181/mesos",
  "masters": ["127.0.0.1:5050"],
  "refreshSeconds": 60,
  "ttl": 60,
  "domain": "mesos",
  "port": 53,
  "resolvers": ["127.0.0.1"],
  "timeout": 5,
  "httpon": true,
  "dnson": true,
  "httpport": 8123,
  "externalon": true,
  "listener": "127.0.0.1",
  "SOAMname": "ns1.mesos",
  "SOARname": "root.ns1.mesos",
  "SOARefresh": 60,
  "SOARetry":   600,
  "SOAExpire":  86400,
  "SOAMinttl": 60,
  "IPSources": ["mesos", "host"]
}
I can ping with service name mysql.marathon.slave.mesos. from host machine. But when I try to ping from mysql docker container I get host unreachable. Why docker container cannot resolve hsot name?

I tried with set dns parameter to apps. But its not work.

EDIT:

I can ping mysql.marathon.slave.mesos. from master/slave hosts. But I cannot ping from mysqlclient docker container. It says unreachable. How can I fix this?

1
What is your question?user149341

1 Answers

0
votes

Not sure what your actual question is, by guessing I think you want to know how you can resolve a Mesos DNS service name to an actual endpoint the MySQL client.

If so, you can use my mesosdns-resolver bash script to get the endpoint from Mesos DNS:

mesosdns-resolver.sh -sn mysql.marathon.mesos -s <IP_ADDRESS_OF_MESOS_DNS_SERVER>

You can use this in your create_mysql_dbs.sh script (whatever it does) to get the actual IP address and port where your mysql app is running.

You can pass in an environment variable like

"MYSQL_ENV_SERVICE_NAME": "mysql.marathon.mesos"

and then use it like this in the image/script

mesosdns-resolver.sh -sn $MYSQL_ENV_SERVICE_NAME -s <IP_ADDRESS_OF_MESOS_DNS_SERVER>

Also, please note that Marathon is not necessarily the right tool for running one-off operations (I assume you initialize your DBs with the second app). Chronos would be a better choice for this.