Alex Giurgiu (alex@giurgiu.io)
using the k/v store and health checks to build a leader election system
Goals for today
SoftLayer API credentials: https://pastee.org/xjr9v
Code: github.com/nustiueudinastea/consul_workshop_devopsdays
Fill in credentials in bootstrap_machines/bootstrap_softlayer.py
Run bootstrap_softlater.py from your machine or Vagrant
Make sure that your private key is available for Ansible
pip install -r requirements.txt
A distributed and highly available K/V store
(source: consul.io)
About Consul
Why Consul?
Consul features
(source: consul.io)
You should now have:
Quick check:
ssh -L 8555:127.0.0.1:8555 root@<VM ip>
Clone github.com/nustiueudinastea/consul_workshop_devopsdays on all 3 VM's
git clone https://github.com/nustiueudinastea/consul_workshop_devopsdays.git
cd consul_workshop_devopsdays/code/cluster_manager/
pip install -r requirements.txt
Consul has 3 types of health checks:
- ttl
- script
- port check
python cluster_manager.py --id 2
Check Consul UI
python cluster_manager.py --id 2 --election true
Check Consul UI
Storing a key and acquiring a lock
Start the other cluster_manager scripts using the election parameter