Create Load Balancer L7 Link using API

I’m trying to dynamically add subdomain routing entries to my loadbalancer as containers and services are created.
visiting should connect me to vpn container port 80
visting should connect me to vpc container port 8081

The static label syntax looks like:

What I’m trying to do should be solved by

But for now it looks like I’m going to have to create an agent that will update my load balancer dynamically as services are created.

To that effect, I’m trying to figure out how to create an Advanced Load Balancing link (L7 type) using the API.

From what i’ve figured out so far, I need to create a loadBalancerServiceLink type object and post it to the http://localhost:5000/v1/loadbalancerservices/1s2/?action=setservicelinks endpoint, however I’m not really sure of the structure of a loadBalancerServiceLink object.

“serviceId”: {
“type”: “reference[service]”,
“create”: true,
“update”: false,
“required”: true,
“readOnCreateOnly”: false,
“ports”: {
“type”: “array[string]”,
“create”: true,
“update”: false,
“nullable”: true,
“readOnCreateOnly”: false,

What is the structure for serviceId and ports? or am I completely down the rabbit hole and missing some other obvious API endpoint?


  • Service id should be the id of the service you are linking to the LB
  • ports is the list of hostname routing rules represented as strings. You can find the syntax here:, “Load Balancer Example (L7)”

One of the examples:


I wrote this in the github thread, but I might as well leave this here for anyone who finds this thread via Google:

I created a simple agent that updates my load balancer whenever a new service starts/stops. Its pretty basic code but feel free to use/modify it as you need.

i’ve started a dynamic backend haproxy load balancer image which uses the rancher-metadata to dynamically route http host headers to a stack name, eg. $stack_name.$domain -> $stack_name/app
Its obviously still in development but is working:
This basically pulls updates to add backends for containers in stacks… this means you dont need to upgrade the LB stack at all to get updates to the config.