Last active
May 10, 2021 15:38
-
-
Save haproxytechblog/a51724ed8ca407f2b92295be308bbd9e to your computer and use it in GitHub Desktop.
Announcing HAProxy Data Plane API 2.3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo dataplaneapi -f dataplaneapi.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ go run configuration/converter/converter.go <original_fmt> <new_fmt> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
allowlist: | |
- key: tag:Environment | |
value: Production |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
reload: | |
reload_delay: 5 | |
reload_cmd: service haproxy reload | |
restart_cmd: service haproxy restart | |
validate_cmd: /usr/local/bin/validate-haproxy.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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