3scale API Manager using Load Balancer for API Gateways

Srikanth Valluru
4 min readJul 7, 2021

In 3scale architecture, you have a 3scale API Manager installed and then you can use built-in or self managed API Gateway configured for each Product for Staging API Gateway and Production API Gateway that will manage your API.

There are multiple ways to configure the API Gateways on where you can deploy and how you can deploy.

  • You can deploy API Gateways inside your corporate network closer to your API and then have a Load Balancer in your DMZ (which is registered with API Manager) handling all the load and hiding your API Gateway to the outside world for high performance and to avoid single point of failure.
  • Another case is where API Gateway is installed via Docker containers and you want to have a Load Balancer handle the requests and forward to Docker containers.
  • You can as well use OpenShift (K8s) scaling feature to run the desired number of API Gateway PODs and have the OpenShift’s Route feature take care of Load Balancing functionality.

There are other combinations of deployment topology which are outside the scope of the current article.

In this article we will look at one of the use cases, where you will have two API Gateways installed on OpenShift, use the Route feature of OpenShift which will provide Load Balancing functionality and use 3scale SaaS API Manager.

Let’s look in detail now…

Pre-requisites :

  1. Setup 3Scale API Manager either on SaaS or OCP.
  2. Create a Backend and Product for default Staging / Production API Gateway and check if you are able to call API or not.
  3. Setup Project (Namespace) on OCP for installing 3scale API Gateway Operator.

Below are Steps:

  1. Install “Red Hat Integration — 3scale APIcast gateway” Operator
  2. Deploy FIRST instance of self managed API Gateway
  3. Deploy SECOND instance of self managed API Gateway
  4. Configure OCP Route for Load Balancing URL
  5. Configure 3scale Product using the Route LB URL
  6. Promote your Product API to use LB URL at Staging API Gateway.
  7. Test the API using CURL.

Step 1 : From OCP Operator Hub, install the following operator “Red Hat Integration — 3scale APIcast gateway”

Step 2 : Deploy FIRST instance of self managed API Gateway using the following link :

https://access.redhat.com/documentation/en-us/red_hat_3scale_api_management/2.10/html/installing_3scale/installing-apicast#deploying-apicast-gateway-self-managed-operator

Step 3 : While installing the SECOND instance of self managed API Gateway in the same Project (namespace), there is a slight change in the way Secret is created.

While creating an OpenShift secret that contains 3scale System Admin Portal endpoint information, please use ${SOME_SECRET_NAME} different from the one used in Step (2) for FIRST API Gateway.

For example :

First API Gateway config :

Spec:

adminPortalCredentialsRef:

name: firstinstancesecret

Second API Gateway config :

Spec:

adminPortalCredentialsRef:

name: secondinstancesecret

After Step(2) and Step(3), you should below :

Two API Gateways listed under APIcast section

Two PODS running one for each API Gateway

Step 4 : Now we will need to configure LB. LB can be configured in many ways using many kinds of technologies. Here we are going to demonstrate one of the ways using OCP Route splitting traffic between Services.

Following are two of my services for API Gateways we created above :

While creating Route, you will configure Service as listed below :

Step 5 : Configure 3scale Product using the Route LB URL.

Go to your 3scale API Manager-> Products -> <Product Name> -> Integration -> Settings :

Copy the Route URL from Step (4) and set it in “Staging Public Base URL” and “Production Public Base URL” like below :

Step 6 : Promote your API to use LB URL at Staging API Gateway.

Go to your 3scale API Manager-> Products -> <Product Name> -> Integration -> Configuration :

Step 7 : Test the API. Use the CURL command from Step(6), fire up a few requests and you should see requests sent to both API Gateways in round robin fashion.

Below you will see the same CURL request is being responded by two different API Gateways (IP of Gateway’s marked in blue).

In my configuration, I used the SaaS version for 3scale API Manager with ECHO API.

--

--