User talk:Jch/consul
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/
Will prepare 5 KVM: 3 consul server (in run-from-ram mode) and 2 consul agent (a SAN (NBD) and a LXC host in data mode) on an isolated network.
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.
wget http://repos.mauras.ch/alpinelinux/x86_64/consul-0.5.0-r0.apk apk add consul-0.5.0-r0.apk --allow-untrusted --force
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
As in our setup we want as many PXE server (in stand-by mode) than consul server, installing a consul server is done by a script doing
- whoami on the LAN ?
- find IP of boot server (is consul leader)
- preconfigure OS
- install package from stable
- install package from edge
- rsync data
- install experimental consul package
- start consul as server
- untie from boot server
- get ENV from consul
- configure networking
- start networking
- start sshd
- (restart consul?)
- configure dnsmasq
- start dnsmasq
- configure ntpd
- start ntpd
- register time.service.consul
- configure collectd
- start collectd
- configure dhcpd
- configure pxelinux
- start in.tftp
- configure NFS
- start NFS
- configure darkhttpd
- start darkhttpd
- register repo.service.consul
- register pxe.service.consul
dhcpd will be started manually for now but later by the consul leader election.
DNSmasq with consul
apk add dnsmasq mkdir -p /etc/dnsmasq.d echo "server=/consul/127.0.0.1#8600" > /etc/dnsmasq.d/10-consul echo "resolv-file=/etc/resolv.dnsmasq" > /etc/dnsmasq.d/20-resolv echo "nameserver ${DNS1}" > /etc/resolv.dnsmasq echo "nameserver ${DNS2}" >> /etc/resolv.dnsmasq echo <<EOF > /etc/conf.d/dnsmasq MASQ_OPTS="--user=dnsmasq --group=dnsmasq --interface=eth0 --conf-dir=/etc/dnsmasq.d" EOF rc-service dnsmasq start
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.
- whoami on the LAN ?
- find IP of boot server (is consul leader)
- preconfigure OS
- install package from stable
- install package from edge
- install experimental consul package
- get standard agent config
- start consul as agent
- join consul cluster
- untie from boot server
- get ENV from consul
- configure dnsmasq
- restart dnsmasq
- configure collectd
- start collectd
Bootstrap the consul cluster
Is to launch the 3 first servers lying to them about the first consul server because we do not want to switch PXE production at the same time we are introducing consul...
Usage
Machines discovery
List machines = "consul members"
list PXEservers = servers in "consul members"
whois active.PXEservers = leader in "consul members"
Services discoevry
Register service
List services
Cheks
Key/Value storage
k/v