Deploy a sample currency exchange app to OpenShift using Red Hat Universal Base Image

Summary

This code pattern is part of the Bee Travels example project that focuses on deploying a Python currency exchange application to Red Hat® OpenShift® on IBM Cloud™, with OpenShift 4.3, using the Red Hat Universal Base Image (UBI).

UBI is a base operating system image that has Red Hat Enterprise Linux (RHEL) at its core, which means you can construct an image with all the qualities you have come to use and love about RHEL. It is responsive, highly secure, and resilient. Plus, as its name suggests, you can universally use it for anything you want. You can build your images on any platform and then distribute it freely to run anywhere you want.

With UBI, you can use familiar yum commands to install standard RPM repositories and packages. For example, you can easily set up Apache Web Server or stand up a versioned, language-specific environment such as Python version 3.7.5. Also, you can build and run your images anywhere, on any platform. For example, you can build and run on different operating systems like Mac, Linux, and Windows, all for free, without needing a paid Red Hat subscription. Learn more about UBI in the Red Hat FAQ article.

Description

You can try out the Universal Base Image with this code pattern and examples with Red Hat OpenShift on IBM Cloud.

By using this code pattern, you can learn the following skills:

  • Design and create a Python microservice with a REST interface that has a swagger test harness where you can manually inspect, discover, and run the various API endpoints.
  • Build a Docker image of the microservice using the Red Hat Universal Base Image.
  • Deploy and run the microservice on Red Hat OpenShift on IBM Cloud.

You need to have the following code and tools to complete the steps in this code pattern:

Flow

Currency conversion microservice architecture flow diagram

  1. In the example currency conversion microservice, the client API consumer calls the microservice over the internet (https request).
  2. Python Flask process acts as a web server and accepts the REST request (for example, GET /convertCurrency/ZAR/USD/600.66).
  3. Code routing in Flask passes the request to a service module, which in turn calls the External European Currency Exchange API.
  4. An exchange rate for South African Rands (ZAR) is retrieved and stored. The value of 600.66 ZAR is converted to US Dollars (USD).
  5. Flask then sends a response to the calling consumer with the dollar amount (in this case, $40.59).

Instructions

To try out this code pattern, see the detailed technical steps in the README.md file in the GitHub repository.

  1. Clone the GitHub repository locally.
  2. Build a Docker image and run it locally.
  3. Deploy to the Red Hat OpenShift 4 cluster on IBM Cloud.