In this exercise, you will deploy a set of microservices for use in a regional library system. To expose these APIs, you will create one or more of the following resources:
Backends
Products
Applications
Application plans
Outcomes
You should be able to:
Deploy microservices on Red Hat OpenShift Container Platform (RHOCP) in a way that is consumable by 3scale API Management.
Create backends and products.
Connect those backends and products to an application and corresponding application plan.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
[student@workstation ~]$ lab start applications-products
Procedure 2.1. Instructions
Create a product called library_product.
Within that product, create an application and application plan.
Use the 3scale Toolbox to create a product named library_product:
[student@workstation ~]$3scale service create 3scale-tenant library_productService 'library_product' has been created with ID:1
In 3scale API Management, a product and a service are the same.
Create an application plan named east-branch-plan:
[student@workstation ~]$3scale application-plan \ create 3scale-tenant library_product east-branch-planCreated application plan id:16. Default: false; Disabled: false
Note that the product is referenced via its system ID library_product.
Find the ID of the example developer named John:
[student@workstation ~]$3scale account find 3scale-tenant johnorg_name => Developerid => 3
Create an application named east-branch-app that references the east-branch-plan application plan and the example developer:
[student@workstation ~]$3scale application \ create 3scale-tenant 3 library_product east_branch_plan east-branch-appCreated application id:9
Create a backend for each of the APIs.
Using a web browser, log in to the Admin Portal as the admin user.
The portal is located at https://3scale-admin.apps.ocp4.example.com.
If this is your first time accessing the admin portal, a setup wizard opens. Use the button to exit this wizard.
From the top pane drop-down menu, select to view the list of backends.
Create a backend for the book API by clicking , providing the following values, and submitting the form. Leave all other fields as their default values.
| Field | Value |
|---|---|
| Name |
book-backend
|
| Private Base URL |
http://books-api.book-library.svc.cluster.local:8080
|
Create another backend for the patron API with the following values:
| Field | Value |
|---|---|
| Name |
patron-backend
|
| Private Base URL |
http://patrons-api.book-library.svc.cluster.local:8080
|
Associate book-backend and patron-backend with the library_product.
From the top pane drop-down menu, select to view the list of products. Click the name of the product in the list.
Navigate to the list of backends associated with the product by selecting → .
Associate a backend with the product by clicking .
Select book-backend as the backend, provide the unique path /b-api, and submit the form.
Repeat the previous step for the patron backend, but select the patron-backend and enter /p-api as the path.
Promote and test the product configuration.
Navigate to the product configuration by selecting → .
Promote the product's configuration to the staging environment by clicking .
Promote the product's configuration to the production environment by clicking .
From the Production APIcast section, copy the hostname from the URL value.
In the command line, store this value in an environment variable called API, to use in a later step.
[student@workstation ~]$ API=https://library-product-3scale-apicast-production\
.apps.ocp4.example.com:443From the Staging APIcast section, copy the user_key value from the example curl command.
In the command line, store this value in a USER_KEY environment variable.
[student@workstation ~]$ USER_KEY=02e852852327972ebc6edfae27b9037aYour user_key will differ from the one listed here.
Retrieve the book list from the book application.
[student@workstation ~]$ curl -s $API/b-api/books?user_key=$USER_KEY | jq
[
{
"title": "Frankenstein",
"authorName": "Mary Shelley",
"year": 1818,
"copies": 10
},
{
"title": "A Christmas Carol",
"authorName": "Charles Dickens",
"year": 1843,
"copies": 5
},
{
"title": "Pride and Prejudice",
"authorName": "Jane Austen",
"year": 1813,
"copies": 3
}
]Retrieve the patron list from the patron application.
[student@workstation ~]$ curl -s $API/p-api/patrons?user_key=$USER_KEY | jq
[
{
"name": "John Smith",
"numBooks": 3,
"cardNumber": "00001"
},
{
"name": "Patty Jones",
"numBooks": 1,
"cardNumber": "00002"
},
{
"name": "Frank Doe",
"numBooks": 8,
"cardNumber": "00003"
}
]Run the previous command several times to generate request metrics.
Review the endpoint metrics within the Admin Portal.
In the admin portal, navigate to → .
Use the selection menu to adjust the scale of the graph by selecting . Make sure is selected so that the time scale is correct.
Note that your graph could look slightly different based on how many times you ran the curl command.
![]() |
This concludes the guided exercise.