API Gateway Container Cluster Configuration
You can combine API Gateway Docker containers to form a cluster.
To configure an API Gateway Docker container cluster:
1. Configure loadbalancer on the Docker host.
2. Configure Terracotta Server Array.
API Gateway requires a Terracotta Server Array installation. For details, see
webMethods Integration Server Clustering Guide and Terracotta documentation (
https://www.terracotta.org/). The Terracotta Server Array on its own can be deployed as a Docker container.
3. Create the basic API Gateway Docker image.
4. Create cluster API Gateway Docker image and enhance it with the cluster configuration in one of the following ways:
Clustered all-in-one containers that consist of
API Gateway, Elasticsearch, and Kibana.
Clustered
API Gateway containers with externalized Elasticsearch and Kibana containers.
Clustered all-in-one Containers that consist of API Gateway, Kibana and Elasticsearch
Although API Gateway clusters with externalized Elasticsearch is the preferred approach API Gateway all-in-one containers can also be clustered.
Note: Having external Kibana is an optional variation.
The following diagram depicts clustering based on all-in-one containers.
The all-in-one containers hold API Gateway, Kibana and Elasticsearch. The clustering is done through a Terracotta Server Array and the cluster capabilities of the embedded Elasticsearch instances.
The required settings for the cluster configuration can be injected during Docker run through an environment file. A sample environment file looks as follows.
apigw_cluster_tsaUrls=tc:9510
apigw_terracotta_license_filename=terracotta-license.key
apigw_discovery_zen_ping_unicast_hosts=apigw1:9340,apigw2:9340,apigw3:9340
Clustered API Gateway Containers with externalized Elasticsearch and Kibana containers
The API Gateway containers are clustered. They are talking to a clustered Terracotta Server Array container and to a cluster of Elasticsearch container through a loadbalancer. The Elasticsearch loadbalancer is also providing the Elasticsearch endpoint for the Kibana containers.
Note: The externalized Kibana is optional. You can still run Kibana within the API Gateway container.
To cluster the API Gateway with external containers for Elasticsearch, Kibana, and Terracotta Server Array, the settings can be injected into an API Gateway Docker image when starting by proving an environment file. The environment file needs to define the following environment variables.
apigw_cluster_tsaUrls=host:port
apigw_terracotta_license_filename=license-key-filename
apigw_elasticsearch_hosts=host:port
apigw_elasticsearch_http_username=user
apigw_elasticsearch_http_password=password
apigw_kibana_dashboardInstance=instance
A sample assignment of the environment variables looks as follows.
apigw_cluster_tsaUrls=tc:9510
apigw_terracotta_license_filename=terracotta-license.key
apigw_elasticsearch_hosts=testhost1:9200
apigw_elasticsearch_http_username=
apigw_elasticsearch_http_password=
apigw_kibana_dashboardInstance=testhost1:9405
Running an API Gateway Cluster using Docker Compose
You can run API Gateway cluster with Elasticsearch and Kibana using Docker Compose. You can have an embedded Elasticsearch where the Elasticsearch resides inside the Docker container or you might have a shared external Elasticsearch that resides outside the clustered API Gateway containers.
A sample docker-compose.yml file where Elasticsearch is inside the Docker container is as follows:
version: '2'
services:
terracotta:
image: is:tc
container_name: tc01
ports:
- 9510:9510
networks:
- apigw
apigateway1:
image: is:apigw
container_name: apigw01
environment:
- apigw_cluster_tsaUrls=tc01:9510
- apigw_terracotta_license_filename=terracotta-license.key
- apigw_discovery_zen_ping_unicast_hosts=apigw01:9340,
apigw02:9340,apigw03:9340
ports:
- 5555:5555
- 9072:9072
- 9240:9240
networks:
- apigw
apigateway2:
image: is:apigw
container_name: apigw02
environment:
- apigw_cluster_tsaUrls=tc01:9510
- apigw_terracotta_license_filename=terracotta-license.key
- apigw_discovery_zen_ping_unicast_hosts=apigw01:9340,
apigw02:9340,apigw03:9340
ports:
- 5556:5555
- 9073:9072
- 9241:9240
networks:
- apigw
apigateway3:
image: is:apigw
container_name: apigw03
environment:
- apigw_cluster_tsaUrls=tc01:9510
- apigw_terracotta_license_filename=terracotta-license.key
- apigw_discovery_zen.ping_unicast_hosts=apigw01:9340,
apigw02:9340,apigw03:9340
ports:
- 5557:5555
- 9074:9072
- 9242:9240
networks:
- apigw
networks:
apigw:
The docker-compose.yml defines the Terrracotta container tc01, and the API Gateway containers apigateway1, apigateway2, and apigateway3.
A sample docker-compose.yml file where you have an external Elasticsearch outside the clustered API Gateway containers is as follows:
version: '2.2'
services:
terracotta:
image: is:tc
container_name: tc01
ports:
- 9510:9510
networks:
- apigw
apigateway1:
image: is:apigw
container_name: apigw01
environment:
- apigw_cluster_tsaUrls=tc01:9510
- apigw_terracotta_license_filename=terracotta-license.key
- apigw_elasticsearch_hosts=elasticsearch:9240
ports:
- 5555:5555
- 9072:9072
networks:
- apigw
apigateway2:
image: is:apigw
container_name: apigw02
environment:
- apigw_cluster_tsaUrls=tc01:9510
- apigw_terracotta_license_filename=terracotta-license.key
- apigw_elasticsearch_hosts=elasticsearch:9240
ports:
- 5556:5555
- 9073:9072
networks:
- apigw
apigateway3:
image: is:apigw
container_name: apigw03
environment:
- apigw_cluster_tsaUrls=tc01:9510
- apigw_terracotta_license_filename=terracotta-license.key
- apigw_elasticsearch_hosts=elasticsearch:9240
ports:
- 5557:5555
- 9074:9072
networks:
- apigw
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:5.6.4
container_name: elasticsearch
environment:
- cluster.name=SAG_EventDataStore
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- xpack.security.enabled=false
ulimits:
memlock:
soft: -1
hard: -1
ports:
- 9240:9200
- 9340:9300
networks:
- apigw
elasticsearch2:
image: docker.elastic.co/elasticsearch/elasticsearch:5.6.4
container_name: elasticsearch2
environment:
- cluster.name=SAG_EventDataStore
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- "discovery.zen.ping.unicast.hosts=elasticsearch:9240"
- xpack.security.enabled=false
ulimits:
memlock:
soft: -1
hard: -1
networks:
- apigw
elasticsearch3:
image: docker.elastic.co/elasticsearch/elasticsearch:5.6.4
container_name: elasticsearch3
environment:
- cluster.name=SAG_EventDataStore
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- "discovery.zen.ping.unicast.hosts=elasticsearch:9240"
- xpack.security.enabled=false
ulimits:
memlock:
soft: -1
hard: -1
networks:
- apigw
networks:
apigw:
The sample file defines the Terracotta container tc01 and the API Gateway containers apigateway1, appigateway2, and apigateway3. In addition, it defines the clustered Elasticsearch containers elasticsearch1, elasticsearch2, and elasticsearch3.