Setup Anypoint Flex Gateway in Connected Mode as an Docker Container — Part I

Jitendra Bafna
5 min readAug 3, 2022

--

MuleSoft launched Universal API Management in 2022 and released or improved various components.

  • Flex Gateway
  • API Governance
  • API Community Manager
  • API Experience Hub (coming soon)
  • Anypoint DataGraph
  • API Designer
  • API cataloging with the updated Anypoint Platform CLI (coming soon)
  • API Manager

In this particular tutorial, we will be focusing on setting up Flex Gateway as an Docker Container in connected Mode. Before we start with the tutorial, let’s understand what Flex Gateway is and what are the benefits that can be extracted out of Flex gateway.

Universal API Management allows you to manage, govern or secure the APIs within single control plane, it doesn’t matter whether they are MuleSoft or Non-MuleSoft APIs or it located anywhere (on-premise, cloud or anywhere).

It will allow the organizations or enterprises to control, manage, secure the APIs under single umbrella.

Adapt any architecture with lightweight and flexible API Gateway to manage and secure the APIs.

Govern the all APIs under single platform.

Flex Gateway is a lightweight, super-fast, and envoy-based API Gateway. Envoy is the CNCF project and it is one of the fastest and most high-performance services now. Flex Gateway can be deployed anywhere (Cloud, Customer Hosted, Kubernetes, Docker, etc.), doesn’t matter where your APIs exist and its technology agnostic.

Benefits of the Flex Gateway

Below is the list of benefits that you can get out of the Flex Gateway.

  • Flex gateway is an ultra-fast gateway that can be used for any APIs (MuleSoft or Non-MuleSoft APIs), deployed anywhere (Cloud, Docker, Kubernetes, Customer Hosted, etc.).
  • Easily manage all the APIs within your organization from a single platform and under a single umbrella.
  • Extend the Anypoint Platform Capabilities to Mule and non-Mule APIs.
  • Secure, discover, govern, or engage the APIs (Mule and non-Mule APIs).
  • Set up the Flex Gateway easily in 2 modes (Local and Connected).
  • Adapt any architecture with a lightweight and flexible API Gateway to manage and secure the APIs.

In Connected Mode, Flex Gateway configuration and API Metrics are managed by the Anypoint Platform and you don’t require any third-party tools whereas in Local Mode, Flex Gateway is managed locally using YAML descriptors and you may require the third-party monitoring tools like Grafana, Prometheus, Splunk, etc., for pushing the metrics.

Connected Mode V/S Local Mode

Prerequisites

  1. Anypoint Platform Account
  2. Docker Engine or Docker Desktop

Setup Flex Gateway as an Docker Container in Runtime Manager

Step 1 — Login into Anypoint Platform and Navigate to the Runtime Manager. Click on Flex Gateways tab and select Add Gateway

Step 2 — You will see different options for selecting OS or environment. We will be selecting the Docker and it will provide list of commands need to execute to install Flex Gateway.

Step 3 — Download or Pull the Flex Gateway docker image using below command.

docker pull mulesoft/flex-gateway:1.1.0

Verify the Flex Gateway docker is correctly installed using below command or even you can use Docker desktop to verify the image.

docker images

Step 4 — Register the Flex Gateway by executing the below command and make sure to replace the <gateway-name>.

docker run --entrypoint flexctl \
-v “$(pwd)”:/registration mulesoft/flex-gateway:1.1.0 \
register --organization=cc54e370-ee88–4e83–986d-9eb43fee01af \
--token=9908016e-8755–4dbb-9b4e-d7100d631a56 \
--output-directory=/registration \
--connected=true \
<gateway-name>

Once the above command is executed, it will generate the file registration.yaml and generate below output in the command prompt.

This registration.yaml will generated at current path where you have execute the command or if you provide the path explicitly in the command.

At the same time, we can see the Flex Gateway registered on the Anypoint Platform as we have passed — connected=true in the command. This means we are setting up Flex Gateway in the connected mode.

You will see Flex Gateway registered in the Anypoint Platform and Status will be Disconnected.

Step 5 — Start the Gateway

To start the Gateway, we need to execute the below command and this will add replicas to your Flex Gateway.

docker run --rm \
-v “$(pwd)”:/usr/local/share/mulesoft/flex-gateway/conf.d \
-p 8081:8081 \
mulesoft/flex-gateway:1.1.0

After executing above command, you will see Flex Gateway in the Connected status on Anypoint Platform and below output will be generated.

To add more replicas to the Flex gateway, you can execute the same command as above by changing the port number.

docker run --rm \
-v “$(pwd)”:/usr/local/share/mulesoft/flex-gateway/conf.d \
-p 8082:8081 \
mulesoft/flex-gateway:1.1.0

In this tutorial, we have seen how to install Flex Gateway as an Docker Container in the Connected Mode and we will going to see how to publish API to Flex gateway and setting up Flex Gateway as an Docker Container in Local Mode in next tutorial.

--

--

Jitendra Bafna

I am Jitendra Bafna, working as a Senior Solution Architect at EPAM Systems and currently leading APIN Competency Center.