API Cluster
The api-cluster
kit defines the following services:
ui
api1
api2
apilb
mongodb
elasticsearch
This kit differs from the quickstart in how it handles API requests. Requests are sent to the apilb
container which runs a load balancer, distributing work between api1
and api2
.
It is worth reviewing the cluster settings for both of your api servers in order for them to correctly communicate.
Running
Use the following commands:
docker-compose build --force-rm
docker-compose up
And then open a browser to:
http://localhost
To access the load balancer:
https://localhost:8080
To acess either api server directly:
https://localhost:6301
https://localhost:6302
docker-compose.yml
version: "2"
services:
ui:
build: ./ui
networks:
- cloudcms
depends_on:
- apilb
env_file:
- ./ui/ui.env
ports:
- "80:80"
apilb:
build: ./apilb
networks:
- cloudcms
depends_on:
- api1
- api2
ports:
- "8080:8080"
- "8085:8085"
expose:
- "8080"
api1:
build: ./api1
networks:
- cloudcms
depends_on:
- mongodb
- elasticsearch
env_file:
- ./api1/api1.env
ports:
- "8091:8080"
expose:
- "8080"
- "6301"
api2:
build: ./api2
networks:
- cloudcms
depends_on:
- mongodb
- elasticsearch
env_file:
- ./api2/api2.env
ports:
- "8092:8080"
expose:
- "8080"
- "6302"
mongodb:
build: ./mongodb
networks:
- cloudcms
ports:
- "27017:27017"
expose:
- "27017"
command: mongod --config /etc/mongod.conf
elasticsearch:
build: ./elasticsearch
networks:
- cloudcms
env_file:
- ./elasticsearch/elasticsearch.env
ulimits:
memlock:
soft: -1
hard: -1
ports:
- "9300:9300"
- "9200:9200"
networks:
cloudcms:
driver: bridge