Digital Developer Conference: Hybrid Cloud
  • Introduction
  • Getting Started
    • Pre-work
  • Threat Modeling & Identity Management
    • Lecture
      • Threat Modeling
      • Identity Management
      • Prerequisites
    • Lab 1
      • Clone the repo
      • Creating App ID in IBM Cloud
      • Building the front end service
      • Deploying to OpenShift
      • Test the Simulator
  • Operator Workshop
    • Lecture
      • Introduction
    • Lab 2
      • Install the PostgreSQL Operator
      • Create an instance of a database
      • Load the schema
      • Expose and verify
  • Microservice Workshop
    • Lecture
      • Introduction
      • Prerequisites
    • Lab 3
      • Part 1
      • Part 2
  • Microservice Workshop (OSS)
    • Lecture
      • Introduction
      • Prerequisites
    • Lab
      • Database setup
      • Part 1
      • Part 2
  • Serverless Workshop
    • Introduction
      • Example Bank App Architecture
      • Serverless
      • Prerequisites
      • Quick Install - Identity Management, Operator, Microservices Workshops
    • Lab 4
      • Installing OpenShift Serverless
      • Installing Knative Serving
      • Clone the repo
      • Create an admin scoped user
      • Building the example serverless application
      • Configure Deployment file
      • Deploying to OpenShift Serverless
      • Test the Serverless App
      • Modify Serverless App
      • Conclusion
  • Service Mesh Workshop
    • ServiceMesh Lab
  • Pipelines (Tekton) Workshop
    • Lecture
      • What is tekton?
      • CI/CD
      • Explain tasks and pipelines
    • Lab 6
      • Cluster Setup
      • Install Pipeline
  • Resources
    • IBM Developer
Powered by GitBook
On this page
  • 1. Modify code
  • 2. Build and push container image
  • 3. Modify deployment file
  • 4. Deploy to OpenShift
  • 5. Test using the simulator again

Was this helpful?

  1. Serverless Workshop
  2. Lab 4

Modify Serverless App

1. Modify code

Modify the function computeReward() section in bank-knative-service/index.js file. Modify the code so that it returns different points rewarded based on a category.

### index.js
function computeReward(category, amount) {
    if (category == "RIDE") {
        return 2 * amount
    }
    return amount;
}

2. Build and push container image

You can now build and push the container image with the updated code.

$ docker build -t $DOCKER_USERNAME/serverless-workshop-example:2.0 bank-knative-service
$ docker push $DOCKER_USERNAME/serverless-workshop-example:2.0

3. Modify deployment file

Modify the deployment file in bank-knative-service/deployment.yaml.

Make sure the image name is the one you built in the previous step.

      containers:
        - image: anthonyamanse/serverless-workshop-example:2.0

4. Deploy to OpenShift

You can now deploy the serverless app to openshift using oc apply

$ oc apply -f bank-knative-service/deployment.yaml

Verify its status. READY should be True

$ oc get ksvc
NAME                  URL                                                         LATESTCREATED               LATESTREADY                 READY   REASON
process-transaction   http://process-transaction.example-bank.svc.cluster.local   process-transaction-dh7kf   process-transaction-dh7kf   True

5. Test using the simulator again

$ oc get routes
NAME                       HOST/PORT             PATH   SERVICES                           PORT    TERMINATION   WILDCARD
mobile-simulator-service   ***.appdomain.cloud          mobile-simulator-service           <all>   edge          None
PreviousTest the Serverless AppNextConclusion

Last updated 4 years ago

Was this helpful?