This tutorial was updated in August 2022 and is based on Flex Gateway 1.1.0.
You can use Flex Gateway locally or in connected mode. If you use it locally, you will only be able to run it from your local machine, but you can’t manage the APIs from Anypoint Platform. In connected mode, you can view your gateways, your API instances, and policy configurations in API Manager. In this case, we’ll register and run Flex Gateway in connected mode as a Kubernetes Ingress Controller.
In this tutorial, you’ll learn how to:
minikube, or a cloud service provider such as Amazon Elastic Kubernetes Service (EKS).
1 - Log in to Anypoint Platform and navigate to Runtime Manager. Click on the Flex Gateways tab on the left and select Add Gateway.
If this is the first time you access Anypoint Platform, it may ask you to select an environment. Choose Sandbox.
2 - You will see different options to select where to set up your Flex Gateway. Let’s select Kubernetes.
1 - Download the Flex Gateway Docker image by running the following command. We will be using the latest version in this tutorial.
1 docker pull mulesoft/flex-gateway:latest
You can browse the repository in DockerHub (here) to find any version you want to use instead. To use a different version, run
docker pull mulesoft/flex-gateway:<version>. For example,
docker pull mulesoft/flex-gateway:1.0.0.
2 - Verify the image was correctly installed by running
docker images or checking your images from the Docker Desktop app. You should see the new
1 2 REPOSITORY TAG IMAGE ID CREATED SIZE mulesoft/flex-gateway latest 4ba042860c8f 7 days ago 273MB
Docker Desktop preview:
1 - Copy the command from Runtime Manager to register your gateway. It already contains the
organization ID you need to authenticate and connect the gateway with your Anypoint Platform account. You need to replace
<gateway-name> with your own name (i.e.
my-gateway) and remove the version from the
flex-gateway image to use the one you previously downloaded.
It’s better to run this command in a new folder or in a known location to quickly identify the files that will be created.
You should end up with something like the following (with your own
1 2 3 4 5 6 7 docker run --entrypoint flexctl \ -v "$(pwd)":/registration mulesoft/flex-gateway \ register --organization=e04b331c-a0d3-4b0b-b40c-55254205c981 \ --token=8ac19527-d3b0-419f-8921-b65c09ba42ed \ --output-directory=/registration \ --connected=true \ my-gateway
1 2 Starting registration, please be patient. Registration completed, the configuration files were written in directory "/registration". For security, modify the file permissions to restrict production scenario access to the user running flex.
2 - Verify there is a new
registration.yaml file in the same directory you executed the command.
3 - If you check the Flex Gateway list in Runtime Manager, your should now see your new gateway (
my-gateway) listed with a status of Disconnected.
Make sure you are already running Kubernetes before continuing. You can use a local instance such as
minikube, or a cloud service provider such as Amazon Elastic Kubernetes Service (EKS). If this is not set up correctly, the following steps might result in errors.
1 - Run the following commands to add and update the helm repository.
1 2 helm repo add flex-gateway https://flex-packages.anypoint.mulesoft.com/helm helm repo up
1 2 3 4 5 6 "flex-gateway" has been added to your repositories Hang tight while we grab the latest from your chart repositories... ...Successfully got an update from the "flex-gateway" chart repository ...Successfully got an update from the "peregrine" chart repository ...Successfully got an update from the "grafana" chart repository Update Complete. ⎈Happy Helming!⎈
2 - Run the following command to create the
gateway namespace and install the gateway to Anypoint Platform.
1 2 helm -n gateway upgrade -i --create-namespace --wait ingress flex-gateway/flex-gateway \ --set-file registration.content=registration.yaml
1 2 3 4 5 6 7 Release "ingress" does not exist. Installing it now. NAME: ingress LAST DEPLOYED: Wed Aug 10 13:35:44 2022 NAMESPACE: gateway STATUS: deployed REVISION: 1 TEST SUITE: None
3 - If you check the Flex Gateways list in Runtime Manager, you should now see your new gateway (
my-gateway) with a status of Connected.
4 - You can verify the gateway is up and running in Kubernetes with the following command.
1 kubectl get services --namespace gateway
1 2 NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE ingress LoadBalancer 172.21.104.120 550f1-279.us-west-1.amazonaws.com 80:30253/TCP,443:30270/TCP 4m23s
Take note of the
EXTERNAL-IP and the associated ports to use in the following tutorial. In this case, this would be the configuration we’d use:
|EXTERNAL-IP / Host||
To delete a gateway from Runtime Manager, click on the 3-dot button next to the gateway and select Delete gateway.
The gateway will now have a status of Deleted and will be removed from the UI in 30 days. For more information, see Anypoint Flex Gateway.
In this tutorial, you learned how to:
In the next tutorial, you’ll learn how to manage your APIs from API Manager using the Flex Gateway you created in this tutorial.
Click on the Next button below to continue to the next tutorial.