API Management with Fuse on Openshift and 3scale on Amazon Web Services (Part 1)
Join the DZone community and get the full member experience.Join For Free
In the following blog series, we're going to show how solutions based on 3scale and Red Hat JBoss Fuse enable organizations to create right interfaces to their internal systems thus enabling them to thrive in the networked, integrated economy.
Among the API Management scenarios that can be addresses by 3cale and Red Hat with JBoss Fuse on OpenShift, we have selected to showcase the following:
• Scenario 1 – Fuse on Openshift with 3scale on Amazon Web Services (AWS)
• Scenario 2 – Fuse on Openshift with APICast (3scale’s cloud hosted API gateway)
• Scenario 3 – Fuse on Openshift and 3scale on Openshift
- Part 1: Fuse on Openshift setup to design and implement the API
- Part 2: 3scale setup for API Management using the nginx open-source API gateway
- Part 3: AWS setup for API gateway hosting
- Part 4: Testing the API and API Management
We will create a Fuse Application that contains the API to be managed. We will use the REST Quickstart that is included with Fuse 6.1. This requires a Medium or Large gear to be used as using the small gear will result in out of memory errors and/or horrible performance.
Step 1: Sign onto your Openshift Online Account. You can sign up for a Openshift Online account if you don’t have one.
Step 2: Click the Add Application button after singing on.
Step 3: Under xPaaS select the Fuse type for the application
Step 4: Now we will configure the application. Enter a Public URL, such as restapitest which gives the full url as appname-domain.rhcloud.com. As in the example below restapitest-ossmentor.rhcloud.com. Change the gear size to medium or large which is required for the Fuse cartridge. Now click on Create Application.
Step 5: Click Create Application
Step 7: After signing on click on the Runtime tab and the container. We will add the REST API example.
Step 8: Click on Add a Profile button
Step 10: Click on the Runtime/APIs tab to verify the REST API profile.
Part 2: 3scale setup
Once we have our API set up on Openshift we can start setting it up on 3scale to provide the management layer for access control and usage monitoring.
Step 1: Log in to your 3scale account. You can sign up for a 3scale account for free at www.3scale.net if you don’t already have one. When you log in to your account for the first time you will see a to-do list to guide you through setting up your API with 3scale.
Step 4: Once you have all of the methods that you want to monitor and control set up under the application plan, you will need to map these to actual http methods on endpoints of your API. We do this by going back to the Integration page and expanding the “Mapping Rules” section.
And creating proxy rules for each of the methods we created under the Application Plan.
Step 5: Once you have clicked “Update and Test” to save and test your configuration, you are ready to download the set of configuration files that will allow you to configure your API gateway on AWS. As an API gateway we use an high-performance and open-source proxy called nginx. You will find the necessary configuration files for nginx in the same Integration page, by scrolling down to the “Production” section
The final section will now take you through installing these configuration files on your Nginx instance on Amazon Web Services (AWS) for hosting.
Part 3: Amazon Web Services (AWS) Setup
We assume that you have already completed these steps:
- You have your Amazon Cloud account.
- You have created your application and are ready to deploy it to Amazon Cloud.
- You have created your proxy on 3scale.
STEP 1. Open Your EC2 Management Console
Select plan that is most appropriate to your application and then you can either select “Review and Launch” if you want a simple launch with 3scale or “Next: Configure Instance Details” to add additional detail configuration; such as shutdown, storage and security.
And click “Launch”. The next screen will ask you to create or select an existing public private key.
If you do not already have a public-private key pair you should choose to create a new pair.
- head over to the your AWS Management Console and go into the running instances list on the EC2 section.
- check that your instance is ready to be accessed. That is indicated by a green check mark icon in the column named Status Checks.
- click on over the instance the list to find its public DNS and copy it
- log in through SSH using the ubuntu user and the private key you chose before. The command will look more or less like:
- ssh -i privateKey.pem firstname.lastname@example.org
- once you log in, read the instructions that will be printed to the screen: all the necessary commands to manage your proxy are described there. In case you want to read them later, these instructions are located in a file named 3SCALE_README in the home directory.
Part 4: Testing the API and API Management
Use your favorite REST client and run the following commands
1. Retrieve the customer instance with id 123
3. Update the customer instance with id 123
4. Delete the customer instance with id 123
5. Check the analytics of the API Management of your API
If you now log back in to your 3scale account and go to Monitoring > Usage you can see the various hits of the API endpoints represented as graphs.
- Access control
- Usage policies and rate limits
- API documentation and developer portals
- Monetization and billing
For more details about the specific Red Hat JBoss Fuse Product features and their benefits, please refer to the Fuse Product description.
For more details about running Red Hat JBoss Fuse on OpenShift, please refer to the xPaaS with Fuse on Openshift description.
Published at DZone with permission of Kenneth Peeples, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.