Skip to content

Instantly share code, notes, and snippets.

@haproxytechblog
Last active May 10, 2021 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haproxytechblog/a51724ed8ca407f2b92295be308bbd9e to your computer and use it in GitHub Desktop.
Save haproxytechblog/a51724ed8ca407f2b92295be308bbd9e to your computer and use it in GitHub Desktop.
Announcing HAProxy Data Plane API 2.3
$ sudo dataplaneapi \
--host 127.0.0.1 \
--port 5555 \
--haproxy-bin /usr/sbin/haproxy \
--config-file /etc/haproxy/haproxy.cfg \
--reload-delay 5 \
--reload-cmd "service haproxy reload" \
--restart-cmd "service haproxy restart" \
--userlist haproxy-dataplaneapi \
--transaction-dir /tmp/haproxy
dataplaneapi:
host: "127.0.0.1"
port: 5555
user:
- name: "admin"
insecure: false
password: "$5$hY1nZJpAFNDjEN$LhRDisCDdKPzQw.Z7IyIy0mwWrnM0lK6OqFy5IIVEy2"
transaction:
transaction_dir: "/tmp/haproxy"
haproxy:
config_file: "/etc/haproxy/haproxy.cfg"
haproxy_bin: "/usr/sbin/haproxy"
reload:
reload_cmd: "service haproxy reload"
restart_cmd: "service haproxy restart"
reload_delay: 5
dataplaneapi {
host = "127.0.0.1"
port = 5555
user "admin" {
insecure = true
password = "adminpwd"
}
transaction {
transaction_dir = "/tmp/haproxy"
}
}
haproxy {
config_file = "/etc/haproxy/haproxy.cfg"
haproxy_bin = "/usr/sbin/haproxy"
reload {
reload_cmd = "service haproxy reload"
restart_cmd = "service haproxy restart"
reload_delay = "5"
}
}
$ sudo dataplaneapi -f dataplaneapi.yaml
$ go run configuration/converter/converter.go <original_fmt> <new_fmt>
$ curl -H 'Content-Type: application/json' \
-u dataplaneapi:mypassword \
-d \
'{
"access_key_id":"XXXXXXXXXXXXXXX",
"secret_access_key":"XXXXXXXXXXXXXXX",
"description":"AWS EC2 Production Environment",
"enabled":true,
"ipv4_address":"private",
"name":"www",
"region":"us-east-1",
"retry_timeout":10}' \
http://10.2.0.3:5555/v2/service_discovery/aws
service_discovery:
aws_regions:
- accesskeyid: <Insert AWS Access Key>
description: production
enabled: true
ipv4address: private
name: production
region: us-east-1
retrytimeout: 10
secretaccesskey: <Insert AWS Secret Access Key>
serverslotsbase: 10
serverslotsgrowthincrement: 10
serverslotsgrowthtype: exponential
backend aws-us-east-1-production-www-80
server SRV_0tWxu 172.31.31.174:80 check weight 128
server SRV_3pQJ7 172.31.31.151:80 check weight 128
server SRV_Bd56t 127.0.0.1:80 disabled weight 128
server SRV_i2SMt 127.0.0.1:80 disabled weight 128
server SRV_YvSgD 127.0.0.1:80 disabled weight 128
server SRV_5xAV0 127.0.0.1:80 disabled weight 128
server SRV_YU99z 127.0.0.1:80 disabled weight 128
server SRV_ampta 127.0.0.1:80 disabled weight 128
server SRV_7Z7S5 127.0.0.1:80 disabled weight 128
server SRV_75KLk 127.0.0.1:80 disabled weight 128
allowlist:
- key: tag:Environment
value: Production
reload:
reload_delay: 5
reload_cmd: service haproxy reload
restart_cmd: service haproxy restart
validate_cmd: /usr/local/bin/validate-haproxy.sh
#!/bin/bash
haproxy -f /etc/haproxy/resolvers.cfg -f $DATAPLANEAPI_TRANSACTION_FILE -c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment