User talk:Jch/consul: Difference between revisions
mNo edit summary |
m (→Consul Server) |
||
Line 37: | Line 37: | ||
the default consul is for a stand alone server... | the default consul is for a stand alone server... | ||
It is important to bootstrap the cluster properly before starting agents otherwise agents will never find the consul leader! | |||
=== DNSmasq with consul === | === DNSmasq with consul === |
Revision as of 06:15, 13 May 2015
This material is work-in-progress ... Do not follow instructions here until this notice is removed. |
Consul
Introduction
This page is currently my experimental log about consul on AL.
Downloaded package: consul-0.5.0-r0.apk from http://repos.mauras.ch/alpinelinux/x86_64/
Now in repo edge/testing
We will experiment to find the right spec to allocate the consul servers for 100 to 1000 agents.
We plan to orchestrate our VM fleet based on consul events, envconsul and consul-template. All with ash scripts and smart setup.
We combine our PXE servers and the consul ones to inherit from the consul resilence (consul leader) to offer high-availability (HA) (but still in ram only) to the PXE service.
Install
We will just focus on the consul installation and configuration parts.
apk add consul@testing
Configuration
Consul v0.5.0
Consul Protocol: 2 (Understands back to: 1)
By default, there are 4 files in /etc/consul
acl.json.sample encrypt.json.sample server.json tls.json.sample
Consul Server
the default consul is for a stand alone server...
It is important to bootstrap the cluster properly before starting agents otherwise agents will never find the consul leader!
DNSmasq with consul
NIC="eth0" # PXEserver NIC="lan" # generic machine apk add dnsmasq rc-update add dnsmasq mkdir -p /etc/dnsmasq.d echo "server=/consul/127.0.0.1#8600" > /etc/dnsmasq.d/10-consul echo <<EOF > /etc/conf.d/dnsmasq MASQ_OPTS="--user=dnsmasq --group=dnsmasq --interface=${NIC} --conf-dir=/etc/dnsmasq.d" EOF rc-service dnsmasq start DNS1=resolver.service.consul # need an IP here, not a fqdn... DNS1=resolver.service.consul # should be different due to round-robin echo "resolv-file=/etc/resolv.dnsmasq" > /etc/dnsmasq.d/20-resolv echo "nameserver ${DNS1}" > /etc/resolv.dnsmasq echo "nameserver ${DNS2}" >> /etc/resolv.dnsmasq rc-service dnsmasq restart
Consul Agent
We need to lauch the consul service after being able to read the IP address of the PXEserver involved.
This particuliar address will be used to join the consul cluster as agent.
Whenever possible, a service will be referenced by its name (like collectd.service.consul for the collectd server).
Consul agent and dnsmasq are the 2 first services to be started on each machine.
This is now included in our generic default apkovl for PXE boot and in our LXC creation custom-made script..
Usage
Be sure to have proxt http disabled if you want to use curl against localhost...
Machines discovery
List machines =
consul members
or
curl localhost:8500/v1/catalog/nodes
list PXEservers = servers in "consul members"
get consul leader = ???
Services discovery
Register service =
echo '{"service": {"name": "pxe"}}' > /etc/consul/pxe.json ; consul reload
List services :
curl http://localhost:8500/v1/agent/services : Returns the services the local agent is managing curl http://localhost:8500/v1/catalog/services : Lists services in a given DC curl http://localhost:8500/v1/catalog/service/<service> : Lists the nodes in a given service curl http://localhost:8500/v1/catalog/node/<node> : Lists the services provided by a node
What if ?
What if I register a service service1 with tag tag1 on node node1, then I register a service service1 with tag tag2 on node2. then I register a service service1 with tag tag3 on node1?
will the tags just add?
I plan to advertize available NBD with {"service": "nbd", "tags": ["<name>"]} ans access it with nbd:name.nbd.service.consul:name.
Cheks
Key/Value storage
curl -X PUT -d 'value' http://localhost:8500/v1/kv/path/to/key
curl http://localhost:8500/v1/kv/path/to/key
curl -X DELETE http://localhost:8500/v1/kv/path/to/key?recurse
need a standard function to convert from json to ash and vice-versa...
Events
Define event
Watch event
Triggers
envconsul
I tried to build a package for it but without success till now...