DC/OS marathon Virtual network not working

287 views Asked by At

I installed DC/OS with 3 masters and 3 agents and face a problem with virtual networking. Here is my Marathon app spec:

{
  "id": "/nginx",
  "cmd": null,
  "cpus": 1,
  "mem": 128,
  "disk": 0,
  "instances": 1,
  "container": {
    "type": "DOCKER",
    "volumes": [],
    "docker": {
      "image": "nginx",
      "network": "BRIDGE",
      "portMappings": [
        {
          "containerPort": 80,
          "hostPort": 0,
          "servicePort": 10002,
          "protocol": "tcp",
          "name": "main1",
          "labels": {
            "VIP_0": "9.0.0.0:34562"
          }
        }
      ],
      "privileged": false,
      "parameters": [],
      "forcePullImage": false
    }
  },
  "portDefinitions": [
    {
      "port": 10002,
      "protocol": "tcp",
      "labels": {}
    }
  ]
}

I see the following in the DC/OS virtual network section:

VIRTUAL NETWORK NAME | SUBNET | AGENT PREFIX LENGTH

dcos 9.0.0.0/8 24

The containers stays in waiting for a long time. If I remove the port mapping section it runs successfully.

Basically I need to know how to work with this new virtual network, and fix the service discovery and load balancing without using any extra stuff.

1

There are 1 answers

0
Leo On

Took me some time to figure it out as well...

You need to:

  • Remove all ports assignment in the task definition
  • Describe the name of the network to attach to (default network created is named "dcos")

    {
        "id": "yourtask",
        "container": {
            "type": "DOCKER",
            "docker": {
                "image": "your/image",
                "network": "USER"
            }
        },
        "acceptedResourceRoles" : [
            "slave_public"
        ],
        "ipAddress": {
            "networkName": "dcos"
        },
        "instances": 2,
        "cpus": 0.2,
        "mem": 128
    }