DC/OS 通过 Marathon-LB & Edge-LB & HAProxy 提供整个系统的负载均衡服务,所有相关的软件集群都依赖于它们。

marat

可考虑引入Traefik,这是一个更加通用的负载均衡解决方案,Go语言编写,后端支持Kubernetes、Marathon、Etcd,比Marathon-LB更具优势。

Traefik

Marathon-LB一个很好的开始:my-crappy-website.json

{
  "id": "/my-crappy-website",
  "cmd": null,
  "cpus": 0.5,
  "mem": 64,
  "disk": 0,
  "instances": 2,
  "acceptedResourceRoles": [],
  "container": {
    "type": "DOCKER",
    "docker": {
      "forcePullImage": true,
      "image": "brndnmtthws/my-crappy-website",
      "parameters": [],
      "privileged": false
    },
    "volumes": [],
    "portMappings": [
      {
        "containerPort": 80,
        "hostPort": 0,
        "labels": {},
        "protocol": "tcp",
        "servicePort": 10012
      }
    ]
  },
  "healthChecks": [
    {
      "gracePeriodSeconds": 10,
      "ignoreHttp1xx": false,
      "intervalSeconds": 15,
      "maxConsecutiveFailures": 3,
      "path": "/",
      "portIndex": 0,
      "protocol": "HTTP",
      "timeoutSeconds": 2,
      "delaySeconds": 15
    }
  ],
  "labels": {
    "HAPROXY_0_USE_HSTS": "true",
    "HAPROXY_0_REDIRECT_TO_HTTPS": "true",
    "HAPROXY_GROUP": "external",
    "HAPROXY_0_BACKEND_HTTP_OPTIONS": "  option httplogn  option forwardforn  http-request set-header X-Forwarded-Port %[dst_port]n  http-request add-header X-Forwarded-Proto https if { ssl_fc }n",
    "HAPROXY_0_VHOST": "diddyinc.com,www.diddyinc.com"
  },
  "networks": [
    {
      "mode": "container/bridge"
    }
  ],
  "portDefinitions": []
}

192.168.0.249/haproxy?stats 或 http://192.168.0.249:9090/haproxy?stats

# dockr exec -t -i 61a8b98705c2 /bin/bash 进入 Marathon-LB容器

Marathon-LB

一些应用的负载均衡/高可用情况。

Haproxy-statistics-report-01

访问Public Agent:http://192.168.0.249:10012 请求被负载均衡到 240和241两个Private Agent节点上。

关机241节点后,负载均衡节点会自动重建,这样就保证了系统的高可用性。

Haproxy-statistics-report-02


发表评论

OpenID

电子邮件地址不会被公开。 必填项已用*标注

Anonymous

电子邮件地址不会被公开。 必填项已用*标注