A Docker image that simplifies the deployment of HAProxy in front of a CockroachDB Docker cluster. This image is intended to be used for local development, testing and demos. The following docker-compose.yml
snippet highlights how it may be used, specifically the lb
service.
services:
crdb-0:
hostname: crdb-0
...
crdb-1:
hostname: crdb-1
...
crdb-2:
hostname: crdb-2
...
lb:
container_name: lb
hostname: lb
image: timveil/dynamic-haproxy:latest
ports:
- "26257:26257" # SQL Port
- "8080:8080" # HTTP Port
- "8081:8081" # Stats Port
environment:
- NODES=crdb-0 crdb-1 crdb-2
links:
- crdb-0
- crdb-1
- crdb-2
The following environment
variables are supported by the Docker image.
NODES
- Required. A space-delimited list of CockroachDB node hostnames (as defined above indocker-compose.yml
) that will be fronted by HAProxy. For example,crdb-0 crdb-1 crdb-2
.SQL_BIND_PORT
- The port that HAProxy willbind
and ultimately expose for CockroachDB SQL connections. The default is26257
.HTTP_BIND_PORT
- The port that HAProxy willbind
and ultimately expose for CockroachDB HTTP connections. The default is8080
.STATS_BIND_PORT
- The port that HAProxy willbind
and ultimately expose for the HAProxy Statistics Report UI. The default is8081
.SQL_LISTEN_PORT
- The port that the CockroachDB exposes for SQL connections. The default is26257
.HTTP_LISTEN_PORT
- The port that the CockroachDB exposes for HTTP connections. The default is8080
.HEALTH_CHECK_PORT
- The port that the CockroachDB uses for health checks. The default is8080
.
docker build --no-cache -t timveil/dynamic-haproxy:latest .
docker push timveil/dynamic-haproxy:latest
docker run -it timveil/dynamic-haproxy:latest
running the image with environment variables
docker run \
--env "NODES=crdb-0 crdb-1 crdb-2" \
--env SQL_BIND_PORT=5432 \
-it timveil/dynamic-haproxy:latest