Configure HAProxy for Elasticsearch and Kibana

Change-Id: Ib6176f6ec851f3fcb647faf9d4649f83d7acaffe
This commit is contained in:
Swann Croiset 2015-12-16 16:32:09 +01:00
parent 9c3955a15f
commit 11f4138051
3 changed files with 76 additions and 2 deletions

View File

@ -0,0 +1,65 @@
# Copyright 2015 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
$plugin_name = 'elasticsearch_kibana'
$es_port = '9200'
$nginx_port = '80'
$vip_name = 'es_vip_mgmt'
$network_metadata = hiera_hash('network_metadata')
if ! $network_metadata['vips'][$vip_name] {
fail('Elasticsearch VIP is not defined')
}
$vip = $network_metadata['vips'][$vip_name]['ipaddr']
notice($vip)
$roles = [ $plugin_name ]
$es_nodes = get_nodes_hash_by_roles($network_metadata, $roles)
$es_address_map = get_node_to_ipaddr_map_by_network_role($es_nodes, 'elasticsearch')
$es_nodes_ips = values($es_address_map)
$es_nodes_names = keys($es_address_map)
notice($es_address_map)
notice($es_nodes_ips)
Openstack::Ha::Haproxy_service {
server_names => $es_nodes_names,
ipaddresses => $es_nodes_ips,
public => false,
public_ssl => false,
internal => true,
internal_virtual_ip => $vip,
}
openstack::ha::haproxy_service { 'elasticsearch-rest':
order => '920',
listen_port => $es_port,
balancermember_port => $es_port,
balancermember_options => 'check inter 10s fastinter 2s downinter 3s rise 3 fall 3',
haproxy_config_options => {
'option' => ['httplog', 'http-keep-alive', 'prefer-last-server'],
'balance' => 'roundrobin',
'mode' => 'http',
}
}
openstack::ha::haproxy_service { 'kibana':
order => '921',
listen_port => $nginx_port,
balancermember_port => $nginx_port,
balancermember_options => 'check inter 10s fastinter 2s downinter 3s rise 3 fall 3',
haproxy_config_options => {
'option' => ['httplog', 'http-keep-alive', 'prefer-last-server'],
'balance' => 'roundrobin',
'mode' => 'http',
}
}

View File

@ -40,3 +40,12 @@
puppet_modules: "puppet/modules"
timeout: 120
- id: es-kibana-haproxy
type: puppet
groups: [elasticsearch_kibana]
requires: [cluster-haproxy, es-virtual-ip]
required_for: [deploy_end]
parameters:
puppet_manifest: "puppet/manifests/haproxy.pp"
puppet_modules: "puppet/modules"
timeout: 120

View File

@ -43,7 +43,7 @@ mkdir -p "${KIBANA_FOLDER}"
wget -qO- "${KIBANA_TARBALL_URL}" | tar -C "${KIBANA_FOLDER}" --strip-components=1 -xz
# Extract dependent manifests from fuel-library
rm -rf "${MODULES_DIR:?}"/{l23network,osnailyfacter,cluster,pacemaker_wrappers,pacemaker,openstack}
rm -rf "${MODULES_DIR:?}"/{l23network,osnailyfacter,cluster,pacemaker_wrappers,pacemaker,openstack,haproxy}
wget -qO- "${FUEL_LIB_TARBALL_URL}" | \
tar -C "${MODULES_DIR}" --strip-components=3 -zxvf - \
fuel-library-${FUEL_LIB_COMMIT}/deployment/puppet/{l23network,osnailyfacter,cluster,pacemaker_wrappers,pacemaker,openstack}
fuel-library-${FUEL_LIB_COMMIT}/deployment/puppet/{l23network,osnailyfacter,cluster,pacemaker_wrappers,pacemaker,openstack,haproxy}