Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HAProxy mode fix and add stats option #392

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 44 additions & 4 deletions common/catalog/common/haproxy.bom
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,24 @@ brooklyn.catalog:
description: |
Extra bind configuration such as TLS certificate paths
type: string
- name: haproxy.stats.enable
label: "Enable HAProxy Statistics"
description: |
Whether HAProxy should serve statistics information page
type: boolean
default: false
- name: haproxy.stats.port
label: "HAProxy Statistics Port"
description: |
Port that HAProxy should serve statistics on
type: integer
default: 7000
- name: haproxy.stats.password
label: "HAProxy Statistics Password"
description: |
Password for 'admin' user on HAProxy statistics service
type: string
default: "p4ssw0rd"

brooklyn.config:
haproxy.bind.options:
Expand All @@ -63,6 +81,9 @@ brooklyn.catalog:
HAPROXY_PORT: $brooklyn:config("haproxy.port")
HAPROXY_PROTOCOL: $brooklyn:config("haproxy.protocol")
HAPROXY_BIND_OPTIONS: $brooklyn:config("haproxy.bind.options")
HAPROXY_STATS_ENABLE: $brooklyn:config("haproxy.stats.enable")
HAPROXY_STATS_PORT: $brooklyn:config("haproxy.stats.port")
HAPROXY_STATS_PASSWORD: $brooklyn:config("haproxy.stats.password")

install.command: |
sudo yum install -y gcc make openssl-devel wget util-linux
Expand All @@ -74,10 +95,16 @@ brooklyn.catalog:
sudo cp haproxy /usr/bin

customize.command: |
if [ "${HAPROXY_PROTOCOL}" == "http" ]; then
mode="http"
else
mode="tcp"
fi
cat > haproxy.conf <<-EOF
global
daemon
maxconn 256
quiet
maxconn 1024
pidfile ${PID_FILE}
defaults
option http-server-close
Expand All @@ -88,10 +115,23 @@ brooklyn.catalog:
bind *:${HAPROXY_PORT} ${HAPROXY_BIND_OPTIONS}
reqadd X-Forwarded-Proto:\ ${HAPROXY_PROTOCOL}
default_backend servers
mode tcp
option tcplog
log 127.0.0.1 syslog
mode ${mode}
EOF
if [ "${HAPROXY_STATS_ENABLE}" == "true" ]; then
cat >> haproxy.conf <<-EOF
listen statistics
mode http
bind *:${HAPROXY_STATS_PORT}
log global
maxconn 16
stats enable
stats uri /
stats refresh 30s
stats show-node
stats realm HAProxy
stats auth admin:${HAPROXY_STATS_PASSWORD}
EOF
fi
echo "backend servers" > servers.conf

launch.command: |
Expand Down