Skip to content

Examples and Testing

gauripowale edited this page Mar 28, 2018 · 4 revisions

1.9

All tests assume that MARATHON_LB_IP is your marathon-lb ip

Docker - Bridge mode

{
  "id": "/nginx-docker-bridge",
  "cmd": "echo 'nginx-docker-bridge' > /usr/share/nginx/html/index.html; nginx -g 'daemon off;'",
  "container": {
    "portMappings": [
      {
        "containerPort": 80,
        "hostPort": 0,
        "protocol": "tcp"
      }
    ],
    "type": "DOCKER",
    "volumes": [],
    "docker": {
      "image": "nginx",
      "network": "BRIDGE",
      "portMappings": [
        {
          "containerPort": 80,
          "hostPort": 0,
          "protocol": "tcp"
        }
      ]
    }
  },
  "cpus": 0.1,
  "disk": 0,
  "instances": 4,
  "mem": 32,
  "networks": [
    {
      "mode": "container/bridge"
    }
  ],
  "requirePorts": false,
  "labels": {
    "HAPROXY_GROUP": "external",
    "HAPROXY_0_PORT": "10100",
    "HAPROXY_0_VHOST": "nginx-docker-bridge.test"
  }
}

Docker - Host mode

{
  "id": "/nginx-docker-host",
  "cmd": "sed -i \"s/80/${PORT0}/\" /etc/nginx/conf.d/default.conf; echo 'nginx-docker-host' > /usr/share/nginx/html/index.html; nginx -g 'daemon off;'",
  "container": {
    "portMappings": [
      {
        "containerPort": 80,
        "hostPort": 0,
        "protocol": "tcp"
      }
    ],
    "type": "DOCKER",
    "volumes": [],
    "docker": {
      "image": "nginx",
      "network": "HOST"
    }
  },
  "cpus": 0.1,
  "disk": 0,
  "instances": 4,
  "mem": 32,
  "networks": [
    {
      "mode": "container/bridge"
    }
  ],
  "requirePorts": false,
  "labels": {
    "HAPROXY_GROUP": "external",
    "HAPROXY_0_PORT": "10300",
    "HAPROXY_0_VHOST": "nginx-docker-host.test"
  },
  "portDefinitions": [
    {
      "protocol": "tcp",
      "port": 0
    }
  ]
}

Docker - IPPC (Virtual IP)

{
  "id": "/nginx-docker-ippc",
  "cmd": "echo 'nginx-docker-ippc' > /usr/share/nginx/html/index.html; nginx -g 'daemon off;'",
  "container": {
    "portMappings": [
      {
        "containerPort": 80,
        "hostPort": 0,
        "protocol": "tcp"
      }
    ],
    "type": "DOCKER",
    "volumes": [],
    "docker": {
      "image": "nginx",
      "network": "USER",
      "portMappings": [
        {
          "containerPort": 80,
          "hostPort": 0,
          "protocol": "tcp"
        }
      ]
    }
  },
  "cpus": 0.1,
  "disk": 0,
  "instances": 4,
  "mem": 32,
  "networks": [
    {
      "mode": "container/bridge"
    }
  ],
  "requirePorts": false,
  "labels": {
    "HAPROXY_GROUP": "external",
    "HAPROXY_0_PORT": "10200",
    "HAPROXY_0_VHOST": "nginx-docker-ippc.test"
  },
  "ipAddress": {
    "groups": [],
    "networkName": "dcos"
  }
}

UCR - Host

{
  "id": "/nginx-ucr-host",
  "cmd": "sed -i \"s/80/${PORT0}/\" /etc/nginx/conf.d/default.conf; echo 'nginx-ucr-host' > /usr/share/nginx/html/index.html; nginx -g 'daemon off;'",
  "container": {
    "portMappings": [
      {
        "containerPort": 80,
        "hostPort": 0,
        "protocol": "tcp"
      }
    ],
    "type": "MESOS",
    "volumes": [],
    "docker": {
      "image": "nginx"
    }
  },
  "cpus": 0.1,
  "disk": 0,
  "instances": 4,
  "mem": 32,
  "networks": [
    {
      "mode": "container/bridge"
    }
  ],
  "requirePorts": false,
  "portDefinitions": [
    {
      "protocol": "tcp",
      "port": 0
    }
  ],
  "labels": {
    "HAPROXY_GROUP": "external",
    "HAPROXY_0_PORT": "10400",
    "HAPROXY_0_VHOST": "nginx-ucr-host.test"
  }
}

Tests:

## Docker Bridge
curl http://${MARATHON_LB_IP}:10100
curl --resolve nginx-docker-bridge.test:80:${MARATHON_LB_IP} http://nginx-docker-bridge.test/
curl -k --resolve nginx-docker-bridge.test:443:${MARATHON_LB_IP} https://nginx-docker-bridge.test/

## Docker Host
curl http://${MARATHON_LB_IP}:10300
curl --resolve nginx-docker-host.test:80:${MARATHON_LB_IP} http://nginx-docker-host.test/
curl -k --resolve nginx-docker-host.test:443:${MARATHON_LB_IP} https://nginx-docker-host.test/

## Docker Virtual (IP-per-Container)
curl http://${MARATHON_LB_IP}:10200
curl --resolve nginx-docker-ippc.test:80:${MARATHON_LB_IP} http://nginx-docker-ippc.test/
curl -k --resolve nginx-docker-ippc.test:443:${MARATHON_LB_IP} https://nginx-docker-ippc.test/

## UCR Host
curl http://${MARATHON_LB_IP}:10400
curl --resolve nginx-ucr-host.test:80:${MARATHON_LB_IP} http://nginx-ucr-host.test/
curl -k --resolve nginx-ucr-host.test:443:${MARATHON_LB_IP} https://nginx-ucr-host.test/

Test Sample Results:

$ export MARATHON_LB_IP=34.217.127.41
$ ## Docker Bridge
$ curl http://${MARATHON_LB_IP}:10100
nginx-docker-bridge
$ curl --resolve nginx-docker-bridge.test:80:${MARATHON_LB_IP} http://nginx-docker-bridge.test/
nginx-docker-bridge
$ curl -k --resolve nginx-docker-bridge.test:443:${MARATHON_LB_IP} https://nginx-docker-bridge.test/
nginx-docker-bridge

$ ## Docker Host
$ curl http://${MARATHON_LB_IP}:10300
nginx-docker-host
$ curl --resolve nginx-docker-host.test:80:${MARATHON_LB_IP} http://nginx-docker-host.test/
nginx-docker-host
$ curl -k --resolve nginx-docker-host.test:443:${MARATHON_LB_IP} https://nginx-docker-host.test/
nginx-docker-host

$ ## Docker Virtual (IP-per-Container)
$ curl http://${MARATHON_LB_IP}:10200
nginx-docker-ippc
$ curl --resolve nginx-docker-ippc.test:80:${MARATHON_LB_IP} http://nginx-docker-ippc.test/
nginx-docker-ippc
$ curl -k --resolve nginx-docker-ippc.test:443:${MARATHON_LB_IP} https://nginx-docker-ippc.test/
nginx-docker-ippc

$ ## UCR Host
$ curl http://${MARATHON_LB_IP}:10400
nginx-ucr-host
$ curl --resolve nginx-ucr-host.test:80:${MARATHON_LB_IP} http://nginx-ucr-host.test/
nginx-ucr-host
$ curl -k --resolve nginx-ucr-host.test:443:${MARATHON_LB_IP} https://nginx-ucr-host.test/
nginx-ucr-host

1.10+

Docker - Bridge mode

{
  "id": "/nginx-docker-bridge",
  "cmd": "echo 'nginx-docker-bridge' > /usr/share/nginx/html/index.html; nginx -g 'daemon off;'",
  "container": {
    "portMappings": [
      {
        "containerPort": 80,
        "hostPort": 0,
        "protocol": "tcp"
      }
    ],
    "type": "DOCKER",
    "volumes": [],
    "docker": {
      "image": "nginx"
    }
  },
  "cpus": 0.1,
  "instances": 4,
  "labels": {
    "HAPROXY_GROUP": "external",
    "HAPROXY_0_PORT": "10100",
    "HAPROXY_0_VHOST": "nginx-docker-bridge.test"
  },
  "mem": 32,
  "networks": [
    {
      "mode": "container/bridge"
    }
  ],
  "requirePorts": false
}

Docker - Host mode

{
  "id": "/nginx-docker-host",
  "cmd": "sed -i \"s/80/${PORT0}/\" /etc/nginx/conf.d/default.conf; echo 'nginx-docker-host' > /usr/share/nginx/html/index.html; nginx -g 'daemon off;'",
  "container": {
    "type": "DOCKER",
    "volumes": [],
    "docker": {
      "image": "nginx",
      "network": "HOST"
    }
  },
  "cpus": 0.1,
  "disk": 0,
  "instances": 4,
  "mem": 32,
  "requirePorts": false,
  "labels": {
    "HAPROXY_GROUP": "external",
    "HAPROXY_0_PORT": "10300",
    "HAPROXY_0_VHOST": "nginx-docker-host.test"
  },
  "healthChecks": [],
  "fetch": [],
  "constraints": [],
  "portDefinitions": [
    {
      "protocol": "tcp",
      "port": 0
    }
  ]
}

Docker - IPPC (Virtual IP)

{
  "id": "/nginx-docker-ippc",
  "cmd": "echo 'nginx-docker-ippc' > /usr/share/nginx/html/index.html; nginx -g 'daemon off;'",
  "cpus": 0.1,
  "mem": 32,
  "disk": 0,
  "instances": 4,
  "container": {
    "type": "DOCKER",
    "volumes": [],
    "docker": {
      "image": "nginx",
      "parameters": []
    },
    "portMappings": [
      {
        "containerPort": 80
      }
    ]
  },
  "requirePorts": false,
  "labels": {
    "HAPROXY_GROUP": "external",
    "HAPROXY_0_PORT": "10200",
    "HAPROXY_0_VHOST": "nginx-docker-ippc.test"
  },
  "ipAddress": {
    "groups": [],
    "networkName": "dcos"
  }
}

UCR - Host

{
  "id": "/nginx-ucr-host",
  "backoffFactor": 1.15,
  "backoffSeconds": 1,
  "cmd": "sed -i \"s/80/${PORT0}/\" /etc/nginx/conf.d/default.conf; echo 'nginx-ucr-host' > /usr/share/nginx/html/index.html; nginx -g 'daemon off;'",
  "container": {
    "type": "MESOS",
    "volumes": [],
    "docker": {
      "image": "nginx",
      "forcePullImage": false,
      "parameters": []
    }
  },
  "cpus": 0.1,
  "disk": 0,
  "instances": 4,
  "labels": {
    "HAPROXY_GROUP": "external",
    "HAPROXY_0_PORT": "10400",
    "HAPROXY_0_VHOST": "nginx-ucr-host.test"
  },
  "maxLaunchDelaySeconds": 3600,
  "mem": 32,
  "gpus": 0,
  "networks": [
    {
      "mode": "host"
    }
  ],
  "portDefinitions": [
    {
      "protocol": "tcp",
      "port": 10003
    }
  ]
}

UCR - Bridge

{
  "id": "/nginx-ucr-bridge",
  "cmd": "echo 'nginx-ucr-bridge' > /usr/share/nginx/html/index.html; nginx -g 'daemon off;'",
  "container": {
    "portMappings": [
      {
        "containerPort": 80,
        "hostPort": 0,
        "protocol": "tcp"
      }
    ],
    "type": "MESOS",
    "volumes": [],
    "docker": {
      "image": "nginx"
    }
  },
  "cpus": 0.1,
  "disk": 0,
  "instances": 4,
  "mem": 32,
  "requirePorts": false,
  "labels": {
    "HAPROXY_GROUP": "external",
    "HAPROXY_0_PORT": "10500",
    "HAPROXY_0_VHOST": "nginx-ucr-bridge.test"
  },
  "networks": [
    {
      "mode": "container/bridge"
    }
  ]
}

UCR - IPPC (Virtual IP)

{
  "id": "/nginx-ucr-ippc",
  "backoffFactor": 1.15,
  "backoffSeconds": 1,
  "cmd": "echo 'nginx-ucr-ippc' > /usr/share/nginx/html/index.html; nginx -g 'daemon off;'",
  "container": {
    "type": "MESOS",
    "volumes": [],
    "docker": {
      "image": "nginx",
      "forcePullImage": false,
      "parameters": []
    }
  },
  "cpus": 0.1,
  "disk": 0,
  "instances": 4,
  "labels": {
    "HAPROXY_GROUP": "external",
    "HAPROXY_0_PORT": "10600",
    "HAPROXY_0_VHOST": "nginx-ucr-ippc.test",
    "HAPROXY_0_BACKEND_SERVER_OPTIONS": "  server {serverName} {host_ipv4}:80 {cookieOptions}{healthCheckOptions}{otherOptions}\n"
  },
  "mem": 32,
  "gpus": 0,
  "networks": [
    {
      "name": "dcos",
      "mode": "container"
    }
  ]
}

Tests:

## Docker Bridge
curl http://${MARATHON_LB_IP}:10100
curl --resolve nginx-docker-bridge.test:80:${MARATHON_LB_IP} http://nginx-docker-bridge.test/
curl -k --resolve nginx-docker-bridge.test:443:${MARATHON_LB_IP} https://nginx-docker-bridge.test/

## Docker Host
curl http://${MARATHON_LB_IP}:10300
curl --resolve nginx-docker-host.test:80:${MARATHON_LB_IP} http://nginx-docker-host.test/
curl -k --resolve nginx-docker-host.test:443:${MARATHON_LB_IP} https://nginx-docker-host.test/

## Docker Virtual (IP-per-Container)
curl http://${MARATHON_LB_IP}:10200
curl --resolve nginx-docker-ippc.test:80:${MARATHON_LB_IP} http://nginx-docker-ippc.test/
curl -k --resolve nginx-docker-ippc.test:443:${MARATHON_LB_IP} https://nginx-docker-ippc.test/

## UCR Bridge
curl http://${MARATHON_LB_IP}:10400
curl --resolve nginx-ucr-bridge.test:80:${MARATHON_LB_IP} http://nginx-ucr-bridge.test/
curl -k --resolve nginx-ucr-bridge.test:443:${MARATHON_LB_IP} https://nginx-ucr-bridge.test/

## UCR Host
curl http://${MARATHON_LB_IP}:10500
curl --resolve nginx-ucr-host.test:80:${MARATHON_LB_IP} http://nginx-ucr-host.test/
curl -k --resolve nginx-ucr-host.test:443:${MARATHON_LB_IP} https://nginx-ucr-host.test/

## UCR Virtual (IP-per-Container)
curl http://${MARATHON_LB_IP}:10600
curl --resolve nginx-ucr-ippc.test:80:${MARATHON_LB_IP} http://nginx-ucr-ippc.test/
curl -k --resolve nginx-ucr-ippc.test:443:${MARATHON_LB_IP} https://nginx-ucr-ippc.test/

Test Sample Results:

$ export MARATHON_LB_IP=34.214.124.251
$ ## Docker Bridge
$ curl http://${MARATHON_LB_IP}:10100
nginx-docker-bridge
$ curl --resolve nginx-docker-bridge.test:80:${MARATHON_LB_IP} http://nginx-docker-bridge.test/
nginx-docker-bridge
$ curl -k --resolve nginx-docker-bridge.test:443:${MARATHON_LB_IP} https://nginx-docker-bridge.test/
nginx-docker-bridge

$ ## Docker Host
$ curl http://${MARATHON_LB_IP}:10300
nginx-docker-host
$ curl --resolve nginx-docker-host.test:80:${MARATHON_LB_IP} http://nginx-docker-host.test/
nginx-docker-host
$ curl -k --resolve nginx-docker-host.test:443:${MARATHON_LB_IP} https://nginx-docker-host.test/
nginx-docker-host

$ ## Docker Virtual (IP-per-Container)
$ curl http://${MARATHON_LB_IP}:10200
nginx-docker-ippc
$ curl --resolve nginx-docker-ippc.test:80:${MARATHON_LB_IP} http://nginx-docker-ippc.test/
nginx-docker-ippc
$ curl -k --resolve nginx-docker-ippc.test:443:${MARATHON_LB_IP} https://nginx-docker-ippc.test/
nginx-docker-ippc

$ ## UCR Bridge
$ curl http://${MARATHON_LB_IP}:10400
nginx-ucr-host
$ curl --resolve nginx-ucr-bridge.test:80:${MARATHON_LB_IP} http://nginx-ucr-bridge.test/
nginx-ucr-bridge
$ curl -k --resolve nginx-ucr-bridge.test:443:${MARATHON_LB_IP} https://nginx-ucr-bridge.test/
nginx-ucr-bridge

$ ## UCR Host
$ curl http://${MARATHON_LB_IP}:10500
nginx-ucr-bridge
$ curl --resolve nginx-ucr-host.test:80:${MARATHON_LB_IP} http://nginx-ucr-host.test/
nginx-ucr-host
$ curl -k --resolve nginx-ucr-host.test:443:${MARATHON_LB_IP} https://nginx-ucr-host.test/
nginx-ucr-host

$ ## UCR Virtual (IP-per-Container)
$ curl http://${MARATHON_LB_IP}:10600
nginx-ucr-ippc
$ curl --resolve nginx-ucr-ippc.test:80:${MARATHON_LB_IP} http://nginx-ucr-ippc.test/
nginx-ucr-ippc
$ curl -k --resolve nginx-ucr-ippc.test:443:${MARATHON_LB_IP} https://nginx-ucr-ippc.test/
nginx-ucr-ippc