DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Install Anypoint Flex Gateway on the Kubernetes as an Ingress Controller in Connected Mode - Part 1

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

Learn how to install Anypoint Flex gateway on Kubernetes as an Ingress controller in connected mode.

Jitendra Bafna user avatar by
Jitendra Bafna
CORE ·
Jul. 28, 22 · Analysis
Like (2)
Save
Tweet
Share
4.28K Views

Join the DZone community and get the full member experience.

Join For Free

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 on Minikube as an Ingress controller and how to publish APIs to Flex Gateway. 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.

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.

Now, let's walk through how to install Flex Gateway on Minikube as an Ingress Controller in Connected Mode...

For installing the Flex Gateway on Minikube, make sure we have to fulfill the below prerequisites

  • Docker Engine or Docker Desktop
  • Minikube Install Minikube - Kubernetes (k8s-docs.netlify.app)
  • Minimum Helm version of 3.0.0

Installing Flex Gateway on Minikube as an Ingress Controller

To install Flex Gateway on Minikube, first, we need to pull the Flex Gateway container image. We can use the below command.

Shell
 
docker pull mulesoft/flex-gateway

After downloading the Flex Gateway container image, we need to register the Flex Gateway either in Local or Connected Mode. But we will be using the Connected Mode for this particular tutorial.

For registering the Flex Gateway in the Connected Mode, we can use one of the three Authentication Mechanisms listed below.

  • Auth Token
  • Connected App
  • Anypoint Username and Password

Now, you can log in to your Anypoint Platform and Navigate to the Runtime Manager  → Flex Gateways. Click on the Add Gateway button on the console. This will provide us with three options where we want to set up Flex Gateway.

Add a flex gateway

In our case, we will be using the Kubernetes environment and it will tell the list of commands that you need to execute on the Kubernetes for setting up Flex Gateway in Connected Mode. We will be going to run the below command for registering the Flex Gateway on the Anypoint Platform. We need to replace <gateway-name> with an appropriate name.

In this case, we will be using the gateway name as “demo-mule-flex”.

Shell
 
docker run --entrypoint flexctl -w /registration \
 -v "$(pwd)":/registration mulesoft/flex-gateway:1.0.1 \
 register <gateway-name> \
 --token=61f90255-74bc-430c-abb6-e76ba4c3cf0f \
 --organization=er34e370-ee77-5e53-586f-9eb43fee01af \
 --connected=true

This is using Auth Token as an Authentication mechanism for registering the Flex Gateway.  Once the above command is executed, it will generate three files and provide the below output on the command prompt.

  • 383bfd2a-1eb0-493b-9261-b07199773045.conf
  • 383bfd2a-1eb0-493b-9261-b07199773045.pem
  • 383bfd2a-1eb0-493b-9261-b07199773045.key

command prompt

The UUID of the file is important and it will be unique for everyone this will require further installation of Flex Gateway. These files will be generated on the path where we have executed the command or if we have specified any other path in the command. In this case UUID is 383bfd2a-1eb0-493b-9261-b07199773045.

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.

mule-flex-gw

We will be creating a separate namespace “gateway” on the minikube for installing the Flex Gateway.

Shell
 
kubectl create namespace gateway
After executing the above command, you can see it will create a new namespace on Minikube with the name “gateway” and it will generate the below output.

command prompt

Also, we can execute the below command to open a web-based Minikube dashboard.

Shell
 
minikube dashboard

After executing the above command, it will open the Minikube console on the browser and you can see the list of namespaces that exists in the drop-down list as shown below screenshot.

kubernetes gateway

There is another way to get the list of namespaces that exist on Minikube. We can execute the command below and it will provide a list of namespaces that exist on Minikube.

Shell
 
kubectl get namespace

Once we have created the namespace, we need to create a Kubernetes secret for the three files that have been created during Flex Gateway registration.

Shell
 
kubectl -n gateway create secret generic 383bfd2a-1eb0-493b-9261-b07199773045 \
--from-file=platform.conf=383bfd2a-1eb0-493b-9261-b07199773045.conf \
--from-file=platform.key=383bfd2a-1eb0-493b-9261-b07199773045.key \
--from-file=platform.pem=383bfd2a-1eb0-493b-9261-b07199773045.pem

Replace the <UUID-of-your-file> with the actual UUID that has been generated during the registration of Flex Gateway. In our case, it is “383bfd2a-1eb0-493b-9261-b07199773045”

After executing the above command, we will see the below output on the command prompt.

command prompt

To fetch the list of secrets in the namespace gateway, we can execute the below command. This command will show the secret that we have created using the above command with the name “383bfd2a-1eb0-493b-9261-b07199773045”

Shell
 
kubectl get secret --namespace gateway

We need to add and update the Flex Gateway helm repository and to do so we have to execute the below command.

Shell
 
helm repo add flex-gateway https://flex-packages.anypoint.mulesoft.com/helm
helm repo up

Once executing the above command on the command prompt, it will generate the below output.

command prompt

Note - Make sure the helm is available on the machine from where you are installing the Flex Gateway. Helm helps you manage Kubernetes applications — Helm Charts helps you define, install, and upgrade even the most complex Kubernetes application.

Using Ingress, install the Flex Gateway Helm Chart into the gateway namespace. Specify the UUID from the file names that have been created during registration.

Shell
 
helm -n gateway upgrade -i --wait ingress flex-gateway/flex-gateway \
--set registerSecretName=383bfd2a-1eb0-493b-9261-b07199773045

After executing the above command, we will see a replica created under Flex Gateway on the Anypoint Platform, and Flex Gateway will be in a connected state.

mule-flex-gw

We will verify API Instances that were created during the installation using the below command.

Shell
 
kubectl -n gateway get apiinstances

This command will be generated below output.

command prompt

We can also execute the command below and it will open the Kubernetes console on the browser and provide more details under the namespace gateway.

Shell
 
minikube dashboard


kubernetes gateway


To see the service list that is running under the namespace gateway, we can execute the below command.

Shell
 
minikube service list --n gateway

This command will provide ingress service details with a private URL for accessing the ingress.

command prompt

Here is the video tutorial explaining how to set up Flex Gateway on the Minikube

In this tutorial, we have seen how to install Flex Gateway on the Minikube as an Ingress Controller in the Connected Mode and various Minikube and kubectl commands for fetching service details, accessing the Kubernetes dashboard, creating secrets, etc. 

Kubernetes Command (computing) FLEX (protocol)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Understanding gRPC Concepts, Use Cases, and Best Practices
  • Top 5 Node.js REST API Frameworks
  • Iptables Basic Commands for Novice
  • How to Use MQTT in Java

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: