0

I recently went through the tutorial for load balancing apps in DCOS using marathon-lb (in the example they balance some nginx containers: https://dcos.io/docs/1.9/networking/marathon-lb/marathon-lb-advanced-tutorial/). I am trying to use this approach to internally load balance my own custom application. The custom app I am using is a play scala app. I have the internal marathon-lb set up and can successfully use it for the nginx container but when I try to use my own docker image I cannot get this to work. I start up my service with my custom image and I can access the service fine by using the IP and port that gets assigned to it (i.e. if the service gets deployed on 10.0.0.0 and is available on port 1234 then curl http://10.0.0.0:1234/ works as expected and I can also make my api calls as defined in my application routes). However, when I try to access the app through the load balancer (curl -i http://marathon-lb-internal.marathon.mesos:10002, where 10002 is the service port) then I get this message:

HTTP/1.0 503 Service Unavailable
Cache-Control: no-cache
Connection: close
Content-Type: text/html

<html><body><h1>503 Service Unavailable</h1>
No server is available to handle this request.
</body></html>

For reference, here is my json file I'm using to start my custom service:

  {
  "id": "my-app",
  "container": {
    "type": "DOCKER",
    "docker": {
      "image": "my_repo/my_image:1.0.0",
      "network": "BRIDGE",
      "portMappings": [
        { "hostPort": 0, "containerPort": 9000, "servicePort": 10002, "protocol": "tcp" }
      ],
      "parameters": [
        { "key": "env", "value": "USER_NAME=user" },
        { "key": "env", "value": "USER_PASSWORD=password" }
      ],
      "forcePullImage": true
    }
  },
  "instances": 1,
  "cpus": 1,
  "mem": 1000,
  "healthChecks": [{
      "protocol": "HTTP",
      "path": "/v1/health",
      "portIndex": 0,
      "timeoutSeconds": 10,
      "gracePeriodSeconds": 10,
      "intervalSeconds": 2,
      "maxConsecutiveFailures": 10
  }],
  "labels":{
    "HAPROXY_GROUP":"internal"
  },
  "uris": [ "https://s3.amazonaws.com/my_bucket/my_docker_credentials" ]
}
st33l3rf4n
  • 11
  • 2
  • 5

1 Answers1

0

I had the same problem and found the solution here

marathon-lb health check failing on all spray.io containers

Need to add "HAPROXY_0_BACKEND_HTTP_HEALTHCHECK_OPTIONS": " http-send-name-header Host\n timeout check {healthCheckTimeoutSeconds}s\n"

To your config so that the REST layer doesn't bark on the health check from marathon

clloyd
  • 1