Hi, after digging into the Data Plane API v3 documentation and doing some testing, I found the following two APIs:
- PUT
/services/haproxy/runtime/backends/{parent_name}/servers/{name}(doc) - POST
/services/haproxy/runtime/backends/{parent_name}/servers(doc)
These are sufficient to avoid restarting the proxy. I was missing the “runtime” part of the API path.
The only minor issue is that the Data Plane API does not seem to expose the current weights, even though they are applied and used by HAProxy for load balancing. However, this is not really a problem for my use case.
cURL logs
$ curl -s -u admin:admin "http://localhost:30555/v3/services/haproxy/runtime/backends/function_figlet_forwarded/servers" | jq
[
{
"address": "IP_X",
"admin_state": "ready",
"id": "1",
"name": "openfaas-local",
"operational_state": "up",
"port": 31112
},
{
"address": "IP_Y",
"admin_state": "ready",
"id": "2",
"name": "test",
"operational_state": "up",
"port": 31112
}
]
$ curl -s -u admin:admin -X PUT "http://localhost:30555/v3/services/haproxy/runtime/backends/function_figlet_forwarded/servers/openfaas-local" -H "Content-Type: application/json" -d '{"weight": 80}' | jq
{
"address": "IP_X",
"admin_state": "ready",
"id": "1",
"name": "openfaas-local",
"operational_state": "up",
"port": 31112
}
$ curl -s -u admin:admin "http://localhost:30555/v3/services/haproxy/runtime/backends/function_figlet_forwarded/servers" | jq
[
{
"address": "IP_X",
"admin_state": "ready",
"id": "1",
"name": "openfaas-local",
"operational_state": "up",
"port": 31112
},
{
"address": "IP_Y",
"admin_state": "ready",
"id": "2",
"name": "test",
"operational_state": "up",
"port": 31112
}
]