Install Anypoint Flex Gateway on the Kubernetes as an Ingress Controller in Connected Mode - Part 2

In my last blog, we saw how to set up Flex Gateway on Minikube as an Ingress controller in the Connected Mode and here we will see how to publish the APIs to Flex Gateway.

As we have seen for installing the Flex Gateway, we have used the Runtime Manager and for publishing the APIs, we will be using the API Manager. To achieve this, we have to make sure that Flex Gateway is connected. With Flex Gateway, Anypoint API Manager capabilities can be extended to the MuleSoft APIs as well as to Non-MuleSoft APIs.

Publish the APIs to the Flex Gateway

To Publish the APIs to Flex Gateway, Navigate to the API Manager ⇒ Add API ⇒ Add new API. Select the Runtime as a Flex Gateway and it will list down all the Flex Gateway available in your environment and allow you to publish APIs on those Flex Gateway that is Connected.

Publish the APIs

In this case, we will be selecting “mule-flex-gw” and click “Next”. Now, we can Select API from Exchange or Create a new API. In this case, we will be selecting Create new API and provide a few details like Name and select Asset types as an HTTP API and clicking Next.

Create new API

After clicking the Next, it will open a new window, and there few important details that need to provide like Implementation URI (i.e. Url of our API implementation) and in the Advanced options, provide the port number 80 and will be using HTTP protocol.

Note - Make sure the Implementation URL must be accessible from Minikube where we have installed Flex Gateway. We need to take care of appropriate firewall rules and ensure that there is connectivity to implementation URLs from Minikube.

We need to take care of appropriate firewall rules and ensure that there is connectivity to implementation URLs from Minikube.

After clicking Next, it will navigate to the review console. We can review all the information and click on the Save & Deploy button.

click on the Save & Deploy button

After the API is successfully published to Flex Gateway, we can see API status to Active in the API Manager console.

API Manager console

This means API is successfully published to the Flex Gateway.

Accessing APIs published to Flex Gateway on Minikube

As we have already installed the ingress in the part 1 tutorial and will be using ingress for accessing the API. We can execute the below command for getting the ingress URL.

Shell
 
minikube service list --namespace gateway

This command will give the below output with HTTP and HTTPS URLs. In our case, we have published an API to port 80 and protocol HTTP. 

command prompt

So we will be using a URL that is mapped with HTTP - http://192.168.49.2:31687.

This is a private URL and cannot be accessed outside. In our case, the complete URL will be this.

To access the above private URL, we will open the Minikube container CLI. To do so, just go to docker desktop and open CLI for the Minikube container.

Docker Apps

We have curled the above URL and we have got some responses back from our API. This means we have sent a request on ingress and ingress has forwarded the request to the implementation.

command prompt

If we want to access the URL outside the Minikube, we need to execute the below command and that will provide the URL which can be used to access ingress.

Shell
 
minikube service ingress --url --namespace gateway

This command will generate the below output with multiple URLs for accessing the ingress.

command prompt

Now, we can use any one of the URLs for accessing the ingress.

This URL can be used in the browser for accessing the APIs. We can see responses from our APIs.

API JSON Response

Note - This URL and port number can be different for everyone and everyone's URL may look different.

Please don't confuse by an error response. Here is the intention to show how we can access APIs via Flex Gateway.

Applying Policies to the API

We can use API Manager in the same way that we are using MuleSoft API Gateway for applying the Policies to the API instance. We can apply any out-of-the-box as well as Custom Policies to the APIs.

Navigate to API Manager → Select API Instance → Policies and select whatever policies we need to apply to API instances.

Policies

Once policies have been applied, they will be enforced to our APIs deployed to Flex Gateway, and next time whenever we will try to access APIs, it will execute whatever policies applied like it will ask for Authentication in case Basic Authentication or any other security policies have been applied.

API Metrics and Telemetry

We will see out-of-box API Metrics as part of our API Manager instance. This includes Total Requests, Total Policy Violations, Total Errors, and Average Response Time graphs.

API Metrics

Anypoint Monitoring

When we are using Flex Gateway in Connected Mode, there will be a lot of metrics available that can help us in analyzing or troubleshooting if there are any issues. Anypoint Monitoring provides a lot of details like CPU and Memory Usage, Requests By Response Code, Requests By Method, Average Response Time, etc.

To view metrics on Anypoint Monitoring, navigate to Monitoring, select Environment, Resource name (i.e. API name), Version/Instance, and Click on the View. 

Anypoint Monitoring

Once clicked on the view, it will provide various metrics that can be used for analyzing or troubleshooting any issues.

Anypoint Monitoring

There are out-of-the-box capabilities that can be used with Flex Gateway in Connected Mode like applying API Alerts using API Manager and many other things like Advanced logging etc.

In this tutorial, we have seen how easily APIs can be published to Flex Gateway and easily manage, govern, engage or discover the APIs. Flex Gateway is enabled with various out-of-the-box features and it can easily extend Anypoint API Manager capabilities to any APIs deployed anywhere and written in any technology.

 

 

 

 

Top