访问部署在 apache mesos 代理上的微服务
Accessing microservices deployed on apache mesos agents
客户端如何在不指定主机代理 IP 地址和相关映射端口的情况下访问已部署的微服务。
如果我们将 Mesos-DNS 添加为客户端解析器,我们只能获取代理 ip 地址,但不会return 微服务实例及其相关端口的列表。
假设我们有 webapp1 的三个实例如下:
+---------+---------+
| agent1 | agent2 |
+---------+---------+
| | |
| ins1:11 | ins3:13 |
| | |
| ins2:12 | |
| | |
+---------+---------+
客户端应该能够直接访问其中一个实例(无需引用 agent1 和 agent2 的 IP 地址或那些 11、12 和 13 端口号)。例如:
$ lynx webapp1.marathon.mesos
请检查 header X-Marathon-App-Id
与马拉松负载平衡器。
示例:
curl -v -H "X-Marathon-App-Id: /your-app-id-in-marahton" -X GET \
http://marathon-lb.marathon.mesos:9091/yourAppEndPoint
更多信息marathon-lb docs。
看看this answer
DNS 可以在您设置 DNS SRV request. It's not compatible with most of clients so you need to manually. Mesos DNS has whole section dedicate to SRV records
时提供有关服务端口的信息
下面是来自文档的示例:
SRV Records
An SRV record associates a service name to a hostname and an IP port.
For task task
launched by framework framework
, Mesos-DNS generates an SRV record for service name _task._protocol.framework.domain
, where protocol
is udp
or tcp
.
For example, other Mesos tasks can discover service search
launched by the marathon
framework with a lookup for lookup _search._tcp.marathon.mesos
:
$ dig _search._tcp.marathon.mesos SRV
; <<>> DiG 9.8.4-rpz2+rl005.12-P1 <<>> _search._tcp.marathon.mesos SRV
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 33793
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;_search._tcp.marathon.mesos. IN SRV
;; ANSWER SECTION:
_search._tcp.marathon.mesos. 60 IN SRV 0 0 31302 10.254.132.41.
Mesos-DNS supports the use of a task's DiscoveryInfo for SRV record generation.
If no DiscoveryInfo is available then Mesos-DNS will fall back to those "ports" resources allocated for the task.
The following table illustrates the rules that govern SRV generation:
客户端如何在不指定主机代理 IP 地址和相关映射端口的情况下访问已部署的微服务。
如果我们将 Mesos-DNS 添加为客户端解析器,我们只能获取代理 ip 地址,但不会return 微服务实例及其相关端口的列表。
假设我们有 webapp1 的三个实例如下:
+---------+---------+
| agent1 | agent2 |
+---------+---------+
| | |
| ins1:11 | ins3:13 |
| | |
| ins2:12 | |
| | |
+---------+---------+
客户端应该能够直接访问其中一个实例(无需引用 agent1 和 agent2 的 IP 地址或那些 11、12 和 13 端口号)。例如:
$ lynx webapp1.marathon.mesos
请检查 header X-Marathon-App-Id
与马拉松负载平衡器。
示例:
curl -v -H "X-Marathon-App-Id: /your-app-id-in-marahton" -X GET \
http://marathon-lb.marathon.mesos:9091/yourAppEndPoint
更多信息marathon-lb docs。
看看this answer
DNS 可以在您设置 DNS SRV request. It's not compatible with most of clients so you need to manually. Mesos DNS has whole section dedicate to SRV records
时提供有关服务端口的信息下面是来自文档的示例:
SRV Records
An SRV record associates a service name to a hostname and an IP port. For task
task
launched by frameworkframework
, Mesos-DNS generates an SRV record for service name_task._protocol.framework.domain
, whereprotocol
isudp
ortcp
. For example, other Mesos tasks can discover servicesearch
launched by themarathon
framework with a lookup for lookup_search._tcp.marathon.mesos
:
$ dig _search._tcp.marathon.mesos SRV
; <<>> DiG 9.8.4-rpz2+rl005.12-P1 <<>> _search._tcp.marathon.mesos SRV
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 33793
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;_search._tcp.marathon.mesos. IN SRV
;; ANSWER SECTION:
_search._tcp.marathon.mesos. 60 IN SRV 0 0 31302 10.254.132.41.
Mesos-DNS supports the use of a task's DiscoveryInfo for SRV record generation. If no DiscoveryInfo is available then Mesos-DNS will fall back to those "ports" resources allocated for the task. The following table illustrates the rules that govern SRV generation: