Library to manage the load balancer using the Serf
gem 'naminori'
Or install it yourself as:
$ gem install naminori
- check the event classification
- add or delete rip if these member-join or member-leave(faile)
- health_check with fetch member
#! /usr/bin/env ruby
require 'rubygems'
require 'naminori'
Naminori.configure do |config|
config.notifier :slack do
webhook_url "https://hooks.slack.com/services/XXXXXX"
channel "#pyama"
end
config.service :dns_server do
service :dns
protocol "udp"
vip "192.68.77.9"
end
config.service :dns_server do
service :dns
protocol "tcp"
vip "192.68.77.9"
end
end
Naminori.run
{
"event_handlers": [
"/opt/serf/event_handlers/envent_example.rb"
],
"interface": "enp0s9",
"discover": "cache-dns",
"tags": {
"role": "lb_server"
},
"log_level": "debug"
}
{
"event_handlers": [
],
"interface": "enp0s8",
"discover": "cache-dns",
"tags": {
"role": "dns_server"
}
}
# crontab -l
# Chef Name: health_check
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
* * * * * for i in `seq 0 10 59`;do (sleep ${i}; /opt/serf/event_handlers/event_example.rb)& done;
{
lb: "lvs" # lb type
port: "53", # service port
protocol: "udp" # protocol
vip: "192.168.77.9", # service vip
method: "nat", # lvs_method gateway/ip/nat
query: "pepabo.com", # health_check_query
retry_c: 3, # health_check_retry_c_count
timeout: 3, # health_check_time_out
}
{
lb: "lvs",
port: "80",
protocol: "tcp",
vip: "192.168.77.9",
method: "nat",
query: "index.html",
retry_c: 3,
timeout: 3
}
- pyama