简体   繁体   English

AWS Opsworks Docker服务发现

[英]AWS opsworks docker service discovery

AWS opswork can deploy dockers to a cluster and so does ECS(ec2 container services). AWS opswork可以将docker部署到群集,ECS(ec2容器服务)也可以部署。 The service discovery in EC2 can be achieved using weave.net or consul etc... when we use opsworks for docker deployment, any suggestions on how to add dynamic service discovery, so inside of my docker container, I can easily get the end point of other web services deployed? 可以使用weave.net或consul等在EC2中实现服务发现...当我们使用opsworks进行docker部署时,有关如何添加动态服务发现的任何建议,因此在我的docker容器内部,我可以轻松地获得终点部署了其他Web服务?

Inside recipe you can use search that would allow you to search opsworks instances within the current stack with search(:node) . 在配方内部,您可以使用搜索,该搜索将允许您使用search(:node)在当前堆栈中搜索opsworks实例。 This method returns array of chef nodes: 此方法返回厨师节点数组:

> search(:node)
=> [#<Chef::Node:0x000000070a44c8
  @attributes=
   {"aws_opsworks_instance_id"=>"----",
    "hostname"=>"--",
    "os"=>"linux",
    "platform"=>"ubuntu",
    "platform_family"=>"debian",
    "ipaddress"=>"172.31.85.144",
    "fqdn"=>"---.localdomain",
    "domain"=>"localdomain",
    "network"=>{"interfaces"=>{"aws_opsworks_virtual"=>{"addresses"=>{"172.31.85.144"=>{"family"=>"inet"}}}}},
    "kernel"=>{"machine"=>"x86_64"},
    "cloud"=>
     {"public_ips"=>["0.0.0.0"],
      "private_ips"=>["172.31.85.144"],
 ...

You can get all IP's in Opsworks stack with 您可以通过以下方式在Opsworks堆栈中获取所有IP:

> search(:node).map(&:ipaddress)
=> ["172.31.85.144", "172.31.85.31", "172.31.85.16"]

Then you can pass this list to docker resource via env variables. 然后,您可以通过env变量将此列表传递给docker资源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM