Deploy a sample currency exchange app to OpenShift using Red Hat Universal Base Image
Example code for deploying a Python app to Red Hat OpenShift on IBM Cloud, improving security, responsiveness, and resiliency
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.
The Universal Base Image 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 the Universal Base Image, you can use familiar yum commands to install standard rpm repositories and packages. For example, easily set up Apache Web Server or stand up a versioned, language-specific environment like Python version 3.7.5. Also, you can build and run your images anywhere on any platform. For example, build and run on different operating systems like Mac, Linux, and Windows, all for free, without needing a paid Red Hat subscription.
You can try out the Universal Base Image with this code pattern and examples with Red Hat OpenShift on IBM Cloud.
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, compatible with OpenShift 4.3.
You need to have the following code and tools to complete the steps in this code pattern:
- An IBM Cloud account
- A RedHat OpenShift 4 cluster on Red Hat OpenShift on IBM Cloud
- The OpenShift Origin CLI tool (oc)
- In the example currency conversion microservice, The client API consumer calls the microservice over the internet (http/s request).
- Python Flask process acts as a web server and accepts the REST request (for example,
- Code routing in Flask passes the request to a service module which in turn calls the External European Currency Exchange API.
- An exchange rate for ZAR is retrieved and stored. The value of
600.66South African Rands (ZAR) is converted to US Dollars (USD).
- Flask then sends a response to the calling consumer with the dollar amount (in this case, $40.59).
To try out this code pattern, see the detailed technical steps in the README.md file in the GitHub repository.
- Clone the GitHub repository locally.
- Build a Docker image and run it locally.
- Deploy to the IBM Red Hat OpenShift 4 cluster.