Cloud-Native Learning Journey - Integration Topics
Learning tasks for developers to understand the IBM middleware integration use cases on Red Hat OpenShift.
Learning Tasks
This set of learning tasks focuses on using IBM middleware on Red Hat OpenShift.
Self-paced agenda to build and deploy an App Connect REST API workflow
This activity provides a working example of a Tekton based CICD pipeline to build and deploy an App Connect application invoking the REST API of the Inventory Management Service. The Pipeline and Task resources available in the Cloud Native Toolkit can be used as a starting point to build BAR files for other ACE workflows.
The activity consists of the following tasks:
- Prerequisites
- Deploy the Inventory Management Service
- Configure the App Connect workflow with the Inventory REST API URL
- Execute the the App Connect pipeline to build and deploy the configured workflow
Prerequisites
Task | Instructions |
---|---|
Active OpenShift 4.x Cluster | |
Set up accounts and tools | Instructions |
Install the Cloud Native Toolkit | Install the Cloud Native Toolkit |
Install IBM Cloud Pak for Integration | Install Cloud Pak for Integration v2020.4 |
Deploy the backend Inventory Management Service
The image below depicts the Tekton pipeline executed.
Open a terminal and log into your OpenShift cluster. For IBM Cloud, navigate to your cluster in the IBM Cloud console, click on the Access tab, and follow the instructions to log in to the cluster from the command line.
Create a development namespace.
oc sync ${DEV_NAMESPACE} --devOpen the Developer Dashboard.
oc dashboardFrom the Developer Dashboard, click on Starter Kits tab. Click on the Inventory Service tile to create your app github repository from the template repository selected. You can also click on the Git Icon to browse the source template repository and click on the Template to create the template.
Complete the GitHub create repository from template process.
Owner: Select a validate GitHub organization that you are authorized to create repositories within or the one you were given for the shared cluster (See warning above)
Repository name: Enter a valid name for you repo, GitHub will help with showing a green tick if it is valid (See warning above)
Description: Describe your app
Press Create repository from template and the new repository will be created in your selected organization.
With the browser open to the newly created repository, click on Clone or download and copy the clone SSH link, and use the
git clone
command to clone it to your developer desktop machine.git clone git@github.com:{gitid}/inventory-management-svc-solution.gitChange into the cloned directory.
cd inventory-management-svc-solutionSet a basepath for the REST API for the Inventory Management Service.
Edit src/main/resources/application.yml and update the server section to include the
/api
base path to server.servlet.context-path.server:port: ${PORT:9080}servlet:context-path: "/api"
Edit the file chart/base/values.yaml and set the route.path from
/
to/api
.route:enabled: falserewriteTarget: "/"path: "/api"
Edit the file chart/base/values.yaml and set the route.path from
/
to/api
.route:enabled: falserewriteTarget: "/"path: "/api"
Set the namespace context.
oc project {DEV_NAMESPACE}Register the App in a DevOps Pipeline
oc pipelineSelect the Tekton pipeline type.
The first time a pipeline is registered in the namespace, the CLI will ask for your username and Personal Access Token for the Git repository. The credentials will be stored in a secret named
git-credentials
. It will use the current branch.Username: Enter your GitHub user id
Personal Access Token: Paste your GitHub personal access token
When registering a
Tekton
pipeline, you will also be prompted to select which pipeline you want to use for your application. Selectibm-java-gradle
.Select
Y
/n
to enable the pipeline to scan the image for vulnerabilities.Provide
/api/health
as the health endpoint. This is needed by the pipeline when running the health Task.After the pipeline has been created, the command will set up a webhook from the Git host to the pipeline event listener.
Note: If the webhook registration step fails it is likely because the Git credentials are incorrect or do not have enough permission in the repository.
The pipeline will be registered in your development cluster and a pipelinerun will be started.
View your application pipeline.
oc consoleFrom menu on the left switch to the Developer mode and select the dev project that was used for the application pipeline registration.
In the left menu, select Pipelines and click on the link to the
inventory-management-svc-solution-xxxxxx
PipelineRun (PLR).Validate the REST API of the Inventory Management service is working correctly in the terminal.
curl https://$(oc get route inventory-management-svc-solution -o jsonpath='{ .spec.host }')/api/stock-itemsThe response should be similar to the following output.
[{"name":"Item 1","id":"1","stock":100,"price":10.5,"manufacturer":"Sony"},{"name":"Item 2","id":"2","stock":150,"price":100.0,"manufacturer":"Insignia"},{"name":"Item 3","id":"3","stock":10,"price":1000.0,"manufacturer":"Panasonic"},{"name":"Item 4","id":"4","stock":9,"price":990.0,"manufacturer":"JVC"}]
Here is a view of a completed and successful pipelinerun.
Configure the App Connect workflow
- Download and install the ACE Toolkit and follow steps 1 and 2.
- Fork the inventory-mgmt-ace-solution repository. The new repository will be created in your selected organization.
- With the browser open to the newly created repository, click on Clone or download and copy the clone SSH link, and use the
git clone
command to clone it to your developer desktop machine.git clone git@github.com:{gitid}/inventory-mgmt-ace-solution.git - Change into the cloned directorycd inventory-mgmt-ace-solution/workspace/InventoryManagementSvc
- Obtain the URL of the Inventory Management SVC route.echo $(oc get route inventory-management-svc-solution -o jsonpath='{ .spec.host }')
- Search and replace the placeholder
INVENTORY_MANAGEMENT_SVC_BASE_URL
with the Route URL in the listStockItemsUsingGET.subflow and ace-inventory-management-svc.json files. - Commit and push the changes into your forked repository.
Execute the App Connect pipeline
The image below depicts the Tekton pipeline executed.
Create a Secret containing the IBM Entitled Registry credentials to pull the ACE image for the CI process in the pipeline.
oc create secret generic ibm-entitled-registry --type="kubernetes.io/basic-auth" --from-literal=username=cp --from-literal=password=<IBM Entitlement Key>Register the App in a DevOps Pipeline
oc pipelineSelect the
Tekton
pipeline type. You should not be prompted for Git credentials as a Secret already exists with your username and token.When registering a
Tekton
pipeline, you will also be prompted to select which pipeline you want to use for your application. Selectibm-ace-bar
.Select
Y
/n
to enable the pipeline to scan the image for vulnerabilities.Provide
/api/stock-items
as the health endpoint. This is needed by the pipeline when running the health Task.After the pipeline has been created, the command will set up a webhook from the Git host to the pipeline event listener
Note: If the webhook registration step fails it is likely because the Git credentials are incorrect or do not have enough permission in the repository.
The pipeline will be registered in your development cluster.
View your application pipeline
oc consoleFrom menu on the left switch to the Developer mode and select dev project that was used for the application pipeline registration.
In the left menu, select Pipelines and click on the link to the
inventory-mgmt-ace-solution-xxxxxx
PipelineRun (PLR).Validate the App Connect server is working correctly in the terminal.
curl http://$(oc get route inventory-mgmt-ace-solution-http -o jsonpath='{ .spec.host }')/api/stock-itemsThe response should be similar to the following output.
[{"name":"Item 1","id":"1","stock":100,"price":10.5,"manufacturer":"Sony"},{"name":"Item 2","id":"2","stock":150,"price":100.0,"manufacturer":"Insignia"},{"name":"Item 3","id":"3","stock":10,"price":1000.0,"manufacturer":"Panasonic"},{"name":"Item 4","id":"4","stock":9,"price":990.0,"manufacturer":"JVC"}]
Here is a view of a completed and successful pipelinerun.