Skip to main contentIBM Garage for Cloud

IBM Cloud Pak for Applications - Microservices

Use IBM Cloud Pak for Applications to integrate microservices

For this homework, you will use two existing applications and deploy them as a set of microservices using the CP4Apps workflow.

Frontend Backend Demo

This guide assumes the following:

  1. You are using a Developer Environment that has already been installed.
  2. Cloud Pak for Applications has already been installed in the environment.
  3. You already completed CP4Apps homeworks.

This guide consists of the following sections:

Deploy existing backend as Appsody app

Create a backend app from an Appsody template, set it up for Appsody, and connect the repo to a pipeline.

First, create a backend app from an existing template.

Second, set up the cloned template with Appsody.

  • Initialize the backend as an Appsody Express.js app

    appsody init kabanero-0.2.1/nodejs-express none
  • Use Appsody to run the backend

    appsody run -p 3001:3000 -p 9230:9229 -p 8081:8080
  • Test the running backend, accessible at http://localhost:3001 (port 3000 will be use later for frontend)

  • Add deployment manifest

    appsody deploy --generate-only
  • Edit the generated file, app-deploy.yaml

    • Specify the namespace to deploy the application into
      metadata:
      namespace: dev-{initials}
  • Commit and push the new Appsody-related files

    git add .
    git commit -m "Add appsody files"
    git push

Third, connect the repo to the Tekton pipeline.

Deploy existing frontend as Appsody app

Create a frontend app from an Appsody template, set it up for Appsody and connect it to the backend, and connect the repo to a pipeline.

First, create a frontend app from an existing template.

  • Repeat the steps above to create a repo from a template:

  • Clone the new Github repo locally

Second, set up the cloned template with Appsody and connect it to the backend.

  • Initialize the frontend as an Appsody Express.js app

    appsody init kabanero-0.2.1/nodejs-express none
  • Use Appsody to run the frontend

    appsody run
  • Test the running frontend, accessible at http://localhost:3000 (port 3001 is used by the backend)

    • Make sure the backend is running with Appsody and exposed on port 3001

    • Test the app by adding a new user

  • Repeat the steps above from the backend using the command appsody deploy --generate-only to add the Appsody deployment manifest file app-deploy.yaml and set the target namespace to dev-{initials}

  • Also in app-deploy.yaml, add an environment variable to link the frontend service to the backend service

    spec:
    env:
    - name: APPSODY_BACKEND_DEFAULT_URL
    value: http://appsody-backend-{initials}:3000/

    (On the server, the frontend and backend will both listen on port 3000 (in different pods).)

  • Commit and push your changes to Git

Third, connect the repo to the Tekton pipeline.

Verify deployed microservice solution

The webhooks should have triggered the pipelines to deploy the frontend and backend to your OpenShift project. Let’s verify the apps are in OpenShift and running correctly.

  • In the OpenShift web console, navigate to your project and its deployments

  • Verify there are two applications corresponding to the frontend (appsody-frontend-{initials}) and backend (appsody-backend-{initials}) services

    Frontend Backend Console

  • Access the route for the frontend service and register a new user

    Frontend Route