You can configure the port used as the endpoint for viewing Edge-LB load balancing statistics. By default, you view load balancing statistics by connecting to the public agent IP address using the haproxy?stats
endpoint and port 9090. However, you can choose to specify the statistics port you want to use manually, or have Edge-LB automatically assign a port by setting a configuration option.
Before you begin
You must have:
- Edge-LB installed as described in the Edge-LB installation instructions.
- The core DC/OS command-line interface (CLI) installed and configured to communicate with the DC/OS™ cluster.
- The
edgelb
command-line interface (CLI) installed. - An active and properly-configured DC/OS Enterprise cluster, with at least one DC/OS private agent node to run the load-balanced service and at least one DC/OS public agent node for exposing the load-balanced service.
Configuring dynamic selection of the stats port
With Edge-LB, you can dynamically assign the port used to access load balancing statistics by modifying the Edge-LB pool configuration file. Through the settings in the pool configuration file, you can control whether Edge-LB should use a predefined port or automatically assign a port for accessing load balancing statistics.
Because you control this setting in the pool configuration file, for a given set of Edge-LB pool instances, you can choose to deploy separate pool configuration files for services that should use the default port, a predefined port, or a dynamically-assigned port.
Create the sample pool configuration file
-
Open a text editor, then copy and paste the following sample
nginx-lb.json
pool configuration file that automatically sets the statistics (stats
) port assignment:{ "apiVersion": "V2", "name": "nginx-lb", "count": 1, "haproxy": { "stats": { "bindPort": 0 }, "frontends": [{ "bindPort": 15000, "protocol": "HTTP", "linkBackend": { "defaultBackend": "nginx-backend" } }], "backends": [{ "name": "nginx-backend", "protocol": "HTTP", "services": [{ "marathon": { "serviceID": "/nginx" }, "endpoint": { "portName": "nginx-80" } }] }] } }
In this sample, the
haproxy.stats.bindPort
setting is0
, indicating that you want Edge-LB to select the port to use for thestats
endpoint automatically. -
Deploy the Edge-LB pool configuration:
dcos edgelb create nginx-lb.json
-
Verify the stats port that has been dynamically assigned to the Edge-LB pool:
dcos edgelb endpoints nginx-lb
This command displays a confirmation message similar to the following, if deployment is successful:
NAME PORT INTERNAL IP frontend_port0 15000 10.0.5.119, 10.0.6.5 stats_port 1026 10.0.5.119, 10.0.6.5
-
Navigate to the URL to see the statistics of the Edge-LB pools using the public IP address of the public agent.
http://<public_agent_public_IP>:1026/haproxy?stats
Changing a previously-configured port
If you have manually configured an Edge-LB pool to use a specific port for accessing HAProxy statistics, updating the pool configuration file to use auto-assignment for the stats port does not update the port used. For example, if you previously configured port 9090 as the statistics port and update the Edge-LB pool configuration haproxy.stats.bindPort
setting to 0
for dynamic allocation, Edge-LB will continue to use port 9090 for HAProxy statistics.
To use dynamic port selection, delete the previous pool configuration and create and deploy a new pool configuration file with the haproxy.stats.bindPort: 0
setting.
Enabling dynamic port allocation for multiple pools
Assigning the port used for the stats endpoint dynamically enables you to deploy more than one pool on an agent node without manually setting different values for each pool.
By leveraging dynamic port allocation, you can:
- Deploy multiple pools on the same agent without worrying about port conflicts.
- Avoid the limitations imposed by using the default stats port 9090 which restricted you to deploying only one Edge-LB pool per agent.
- Eliminate the need to identify and specify manual port assignments for Edge-LB pools running on the same agent.