【问题标题】:Can't Connect to Service via Marathon-lb using DCOS无法使用 DCOS 通过 Marathon-lb 连接到服务
【发布时间】:2018-02-09 12:04:39
【问题描述】:

我最近浏览了使用 marathon-lb 在 DCOS 中负载平衡应用程序的教程(在示例中,它们平衡了一些 nginx 容器:https://dcos.io/docs/1.9/networking/marathon-lb/marathon-lb-advanced-tutorial/)。我正在尝试使用这种方法在我自己的自定义应用程序内部进行负载平衡。我正在使用的自定义应用程序是一个 play scala 应用程序。我已经设置了内部 marathon-lb,并且可以成功地将它用于 nginx 容器,但是当我尝试使用自己的 docker 映像时,我无法让它工作。我用我的自定义图像启动我的服务,我可以通过使用分配给它的 IP 和端口来访问服务(即,如果服务部署在 10.0.0.0 并且在端口 1234 上可用,那么 curl http://10.0.0.0:1234/ 可以作为预期的,我也可以按照我的应用程序路由中的定义进行我的 api 调用)。但是,当我尝试通过负载均衡器(curl -i http://marathon-lb-internal.marathon.mesos:10002,其中 10002 是服务端口)访问应用程序时,我会收到以下消息:

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>

作为参考,这是我用来启动自定义服务的 json 文件:

  {
  "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" ]
}

【问题讨论】:

  • 嗨,你解决了这个问题吗?没有的话我就发过来!谢谢!

标签: load-balancing haproxy marathon dcos internal-load-balancer


【解决方案1】:

我遇到了同样的问题,在这里找到了解决方案

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

需要添加 "HAPROXY_0_BACKEND_HTTP_HEALTHCHECK_OPTIONS": "http-send-name-header 主机\n 超时检查 {healthCheckTimeoutSeconds}s\n"

到你的配置,这样 REST 层就不会在马拉松的健康检查中吠叫

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-01-30
    • 2017-10-16
    • 2016-07-15
    • 2016-05-24
    • 2013-07-13
    • 2012-02-20
    • 2020-01-01
    相关资源
    最近更新 更多