Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Using Weave Net with NGINX+ & Elasticsearch

Using Weave Net with NGINX+ & Elasticsearch

3 VMs, each of these runs:
- an instance of Elasticsearch
- 2 instances of a RESTful app (Node.js)
- NGINX+ load-balancing all 6 instances

Try it yourself: https://github.com/errordeveloper/weave-demos/blob/master/hello-apps/elasticsearch-js/tldr.md

Ilya Dmitrichenko

December 01, 2015
Tweet

More Decks by Ilya Dmitrichenko

Other Decks in Technology

Transcript

  1. $ORIGIN example.com $TTL 86400 @ IN SOA dns1.example.com. hostmaster.example.com. (

    2001062501 ; serial 21600 ; refresh after 6 hours 3600 ; retry after 1 hour 604800 ; expire after 1 week 86400 ) ; minimum TTL of 1 day IN NS dns1.example.com. IN NS dns2.example.com. IN MX 10 mail.example.com. IN MX 20 mail2.example.com. IN A 10.0.1.5 server1 IN A 10.0.1.5 server2 IN A 10.0.1.7 dns1 IN A 10.0.1.2 dns2 IN A 10.0.1.3 ftp IN CNAME server1 mail IN CNAME server1 mail2 IN CNAME server2 www IN CNAME server2
  2. upstream { upstream myapp_backends { zone myapp_backends 64k; server myapp.weave.local

    resolve; } } server { listen 80 default_server; location / { proxy_pass http://myapp_backends; } }
  3. docker run \ -h app.weave.local \ myapp Run any number

    of app instances on any host in Weave Net cluster!
  4. Can I run Elasticsearch on Docker out-of-the-box? • Yes, there

    is an official image: > docker run -d elasticsearch
  5. …and what about clustering? • I don’t see how to

    do it with the official image, but there seems to be another one by @itgz > docker run -d \ -p 9200:9200 -p 9300:9300 itzg/elasticsearch > docker run -d \ -p 9200:9201 -p 9300:9301 itzg/elasticsearch > docker run -d \ -p 9200:9202 -p 9300:9302 itzg/elasticsearch • That’s not “official”, right?
  6. I am still not sure how clustering will work ;’(

    • What are `-p 9200:9201 -p 9300:9301`? • How do I run the instances on different hosts? • Which port should my client use? • What is the “ambassador patter”? • May be I need a kind of orchestrator tool?
  7. I found a few examples of what others did… •

    Mesos + HAProxy + Marathon + Ansible • This one uses Ubuntu in EC2 and I really should be using RedHat in Azure, I am also not sure about switching to Ansible from Puppet, and still need to learn more about all the Mesos stuff… • CoreOS + fleet + etcd • I like the idea of CoreOS, but not sure if my boss likes it and, it still looks a bit complicated… • Kubernetes • Looks also interesting, but I am not sure we can introduce Kubernetes either… I just want to demo proof-of-concept next week
  8. Introducing Weave • Easiest way to build portable Docker app

    clusters • You won't have to change your app • Lean service discovery which doesn't in your way • Simple to use on its own or with an orchestrator
  9. Service Discovery var es = new elasticsearch.Client({ hosts: [ 'es-1.weave.local:9200'

    , 'es-2.weave.local:9200' , 'es-3.weave.local:9200' ] });
  10. Demo • 3 VMs, each of these runs • an

    instance of Elasticsearch • 2 instances of a RESTful app • NGINX+ load-balancing all 6 instances github.com/errordeveloper/weave-demos/blob/master/hello-apps/elasticsearch-js/tldr.md