Closed aktarali closed 8 years ago
Hi @aktarali,
The way it should be done is to create a wrapper cookbook which includes zookeeper and mesos and calculate the values in the attributes.
Example recipe for the masters [1]:
include_recipe 'zookeeper'
include_recipe 'mesos::master'
Example recipe for the slaves:
include_recipe 'mesos::slave'
Example attributes [2]:
# doc: http://www.rubydoc.info/github/opscode/chef/Chef/Search/Query#search-instance_method
zks = "zk://#{Chef::Search::Query.new.search(:node, 'recipes:zookeeper\:\:default').first.map { |zk| "#{zk['hostname']}:#{zk['zookeeper']['config']['clientPort']}" }.sort.join(',')}/#{node['mesos']['zookeeper_path'] }"
# set up mesos attributes
default['mesos']['master']['flags']['zk'] = zks
default['mesos']['slave']['flags']['master'] = zks
[1] Note that for the zookeeper cookbook you'll have to set up the attribute [zookeeper][myid]
per zookeeper master (you can do it inside a node file).
[2] You are strongly encouraged to implement error checking for the search as you might have grave consequences with nil values. This is only a proof of concept.
@rveznaver Can't thank you enough for your help. I will test this out and let you know how I get on. For multi-master setup using chef, it should work with chef-search within the slave recipe. It's a much more dynamic approach.
If you have service discovery or dns in your infrastructure you may also point mesos master and slaves to the zookeeper endpoint along with a port and a chroot if you use one. So for instance all of my zookeeper instances in my infrastructure are behind an endpoint labeled zookeeper.service.consul which will always resolve to one of my zookeeper nodes so I set my mesos master and slave endpoints to zookeeper.service.consul:2181/mesos-prod01 which will always make sure mesos master and slaves can find each other via zookeeper metadata. This is a more advanced set up but one you will be more likely to find in a production environment.
On Mon, Dec 21, 2015 at 11:51 AM, aktarali notifications@github.com wrote:
@rveznaver https://github.com/rveznaver Can't thank you enough for your help. I will test this out and let you know how I get on. For multi-master setup using chef, it should work with chef-search within the slave recipe. It's a much more dynamic approach.
— Reply to this email directly or view it on GitHub https://github.com/mdsol/mesos_cookbook/issues/120#issuecomment-166356920 .
Hi;
Thank you guys for all your help, i know this issue has now been closed, but I have 1 additional question: I am using chef-search to populate these values using the suggestion below:
zks = "zk://#{Chef::Search::Query.new.search(:node, 'recipes:zookeeper::default').first.map { |zk| "#{zk['hostname']}:#{zk['zookeeper']['config']['clientPort']}" }.sort.join(',')}/#{node['mesos']['zookeeper_path'] }"
default['mesos']['master']['flags']['zk'] = zks default['mesos']['slave']['flags']['master'] = zks [1] Note that for the zookeeper cookbook you'll have to set up the attribute [zookeeper][myid] per zookeeper master (you can do it inside a node file).
**Where do I set this [zookeeper][myid] ? Where is the nodefile? I am using the following to complete my zookeeper configs in a wrapper cookbook: include_recipe 'zookeeper' include_recipe 'zookeeper::service' i = 0 search(:node, "chef_environment:#{node.chef_environment} AND " \ 'roles:zookeeper').map do |n| i += 1 node.set['zookeeper']['config']["server.#{i}"] = "#{n['fqdn']}:2888:3888" end
I would like to use the chef-search for zookeeper and mesos to work hand in hand. If anyone can provide a step by step guide on achieving this, I would be greatly appreciative of this. Cheers gents.
Ali.
There are different ways of managing node files, the most manual being writing a JSON describing your node and setting it with knife. Check out the knife node docs.
Hi Guys,
This is probably a mesos and zookeeper question.
If I have 3 masters, what does my master override attributes look like?
And what does my slave override attribute look it? To make them all join the mesos cluster. Would would be great is to use chef-search to add the master node IP's to the slave configs dynamically by searching through chef and checking for nodes that have 'master' role attached to them and adding them dynamically to the zk slave config.
Anyone know how to do this?
Really appreciate any help you guy can provide.
Cheers Ali.