我最近使用marathon-lb(在示例中他们平衡了一些nginx容器:https://dcos.io/docs/1.9/networking/marathon-lb/marathon-lb-advanced-tutorial/)完成了DCOS中负载均衡应用程序的教程。我试图使用这种方法内部负载平衡我自己的自定义应用程序。我正在使用的自定义应用是一个播放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" ]
}
答案 0 :(得分:0)
我遇到了同样的问题并在此处找到了解决方案
marathon-lb health check failing on all spray.io containers
需要添加 &#34; HAPROXY_0_BACKEND_HTTP_HEALTHCHECK_OPTIONS&#34;:&#34; http-send-name-header主机\ n超时检查{healthCheckTimeoutSeconds} s \ n&#34;
到您的配置,以便REST层不会在马拉松健康检查中吠叫