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.
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:
- IBM Cloud account
- OpenShift 4 cluster on Red Hat OpenShift on IBM Cloud
- OpenShift Origin CLI (oc) tool
- In the example currency conversion microservice, the client API consumer calls the microservice over the internet (https 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 South African Rands (ZAR) is retrieved and stored. The value of
600.66ZAR 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 Red Hat OpenShift 4 cluster on IBM Cloud.