loadbalancer: Implementing a proper failover based on the router state
Due to the fact that two HAProxy can not listen on the same vip at the same time, the management of the HAProxy service has been delegated to the keepalived process. With this patch, the keepalived process starts/stops the HAProxy daemon based on the state is is entering. If it enters MASTER mode then it starts the HAProxy daemon. If it enters BACKUP mode then it stops the HAProxy daemon. close #25
This commit is contained in:
parent
b4bafb06c0
commit
183b99c0d2
@ -56,7 +56,9 @@ class cloud::loadbalancer(
|
||||
$mysql_vip = $os_params::mysql_vip
|
||||
){
|
||||
|
||||
class { 'haproxy': }
|
||||
class { 'haproxy':
|
||||
manage_service => false,
|
||||
}
|
||||
|
||||
class { 'keepalived': }
|
||||
|
||||
@ -65,11 +67,13 @@ class cloud::loadbalancer(
|
||||
}
|
||||
|
||||
keepalived::instance { '1':
|
||||
interface => $keepalived_interface,
|
||||
virtual_ips => split(join(flatten([$keepalived_ipvs, ['']]), " dev ${keepalived_interface},"), ','),
|
||||
state => $keepalived_state,
|
||||
track_script => ['haproxy'],
|
||||
priority => 50,
|
||||
interface => $keepalived_interface,
|
||||
virtual_ips => split(join(flatten([$keepalived_ipvs, ['']]), " dev ${keepalived_interface},"), ','),
|
||||
state => $keepalived_state,
|
||||
track_script => ['haproxy'],
|
||||
priority => 50,
|
||||
notify_master => '"/etc/init.d/haproxy start"',
|
||||
notify_backup => '"/etc/init.d/haproxy stop"',
|
||||
}
|
||||
|
||||
$monitors_data = inline_template('
|
||||
|
@ -63,7 +63,9 @@ describe 'cloud::loadbalancer' do
|
||||
end
|
||||
|
||||
it 'configure haproxy server' do
|
||||
should contain_class('haproxy')
|
||||
should contain_class('haproxy').with({
|
||||
'manage_service' => 'false',
|
||||
})
|
||||
end
|
||||
|
||||
it 'configure keepalived server' do
|
||||
@ -72,7 +74,9 @@ describe 'cloud::loadbalancer' do
|
||||
|
||||
it 'configure vrrp_instance with MASTER state' do
|
||||
should contain_keepalived__instance('1').with({
|
||||
'state' => 'MASTER',
|
||||
'state' => 'MASTER',
|
||||
'notify_master' => '"/etc/init.d/haproxy start"',
|
||||
'notify_backup' => '"/etc/init.d/haproxy stop"',
|
||||
})
|
||||
end
|
||||
|
||||
@ -121,7 +125,9 @@ describe 'cloud::loadbalancer' do
|
||||
end
|
||||
|
||||
it 'configure haproxy server' do
|
||||
should contain_class('haproxy')
|
||||
should contain_class('haproxy').with({
|
||||
'manage_service' => 'false',
|
||||
})
|
||||
end
|
||||
|
||||
it 'configure keepalived server' do
|
||||
@ -129,7 +135,10 @@ describe 'cloud::loadbalancer' do
|
||||
end
|
||||
|
||||
it 'configure vrrp_instance with BACKUP state' do
|
||||
should contain_keepalived__instance('1')
|
||||
should contain_keepalived__instance('1').with({
|
||||
'notify_master' => '"/etc/init.d/haproxy start"',
|
||||
'notify_backup' => '"/etc/init.d/haproxy stop"',
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user