Using Chef to add new Nodes to an nginx LB

Hey All,

So for a while now we have been using Amazon ELB as our LB for our server
and we have an internal cookbook that adds new nodes to a particular ELB
using fog. Well now it seems due to some requirement changes we might need
to move away from ELB to nginx. Now one of the things that is bugging me
is a dynaimc way of adding new nodes to nginx. I have in the past setup
simple round robin load balancers with nginx but we would like an way to
make sure everytime we deploy a server its automatically added to the nginx
LB and before I go out and reinvent the wheel I am wondering if anyone else
has done this or at lest has something that can point me in the right
directions so I can write my own.

Thanks
Zuhaib

On Jan 23, 2012, at 9:06 PM, zuhaib siddique wrote:

So for a while now we have been using Amazon ELB as our LB for our server and we have an internal cookbook that adds new nodes to a particular ELB using fog. Well now it seems due to some requirement changes we might need to move away from ELB to nginx. Now one of the things that is bugging me is a dynaimc way of adding new nodes to nginx. I have in the past setup simple round robin load balancers with nginx but we would like an way to make sure everytime we deploy a server its automatically added to the nginx LB and before I go out and reinvent the wheel I am wondering if anyone else has done this or at lest has something that can point me in the right directions so I can write my own.

We built a simple search-based method for use with haproxy. Every time that chef-client executes on the proxy server(s), it does a search of all nodes that have a certain role (e.g., "role[web]"), and all the nodes that come back as matching that search get put into the set of machines to be load balanced.

We're now switching away from haproxy, and we've looked at both nginx and lighttpd for this function. Both look useful, but since we're also switching away from apache/httpd to lighttpd for web serving, we're going to try going with lighttpd as the reverse proxy as well. That way we can kill two birds with one stone, and remove one package from our list of dependencies that we may not really need.

But we'll still use the search-based method of updating our load-balancing rules, at least until we find a better solution.

--
Brad Knowles bknowles@ihiji.com
SAGE Level IV, Chef Level 0.0.1

hi,
As Brad has already mentioned you can use search to get the list of
webservers , but this has to be part of the nginx recipe, which means there
will be a delay. Every time you add or remove a webserver u need to wait
till the nginx chef client runs. You can automate this via invoking
chef-client --once , through knife ssh, as a after hook to webserver
creation/deletion. Also, you can use something like mcollective to model
the exact scenario.

regards
ranjib

On Tue, Jan 24, 2012 at 9:13 AM, Brad Knowles bknowles@ihiji.com wrote:

On Jan 23, 2012, at 9:06 PM, zuhaib siddique wrote:

So for a while now we have been using Amazon ELB as our LB for our
server and we have an internal cookbook that adds new nodes to a particular
ELB using fog. Well now it seems due to some requirement changes we might
need to move away from ELB to nginx. Now one of the things that is bugging
me is a dynaimc way of adding new nodes to nginx. I have in the past setup
simple round robin load balancers with nginx but we would like an way to
make sure everytime we deploy a server its automatically added to the nginx
LB and before I go out and reinvent the wheel I am wondering if anyone else
has done this or at lest has something that can point me in the right
directions so I can write my own.

We built a simple search-based method for use with haproxy. Every time
that chef-client executes on the proxy server(s), it does a search of all
nodes that have a certain role (e.g., "role[web]"), and all the nodes that
come back as matching that search get put into the set of machines to be
load balanced.

We're now switching away from haproxy, and we've looked at both nginx and
lighttpd for this function. Both look useful, but since we're also
switching away from apache/httpd to lighttpd for web serving, we're going
to try going with lighttpd as the reverse proxy as well. That way we can
kill two birds with one stone, and remove one package from our list of
dependencies that we may not really need.

But we'll still use the search-based method of updating our load-balancing
rules, at least until we find a better solution.

--
Brad Knowles bknowles@ihiji.com
SAGE Level IV, Chef Level 0.0.1