-
Notifications
You must be signed in to change notification settings - Fork 18
Home
By Grant Steinfeld grant.steinfeld@ibm.com
This code pattern is part of the Bee Travels project that focuses on deploying a Python currency exchange application to Openshift 4 using Redhat's universal base image
- Python
- Flask
- RedHat Universal Base Image (UBI)
- OpenShift 4
- Microservices
Red Hat Universal Base Images (UBI) are OCI-compliant container base operating system images with complementary runtime languages and packages that are freely redistributable. Like previous RHEL base images, they are built from portions of Red Hat Enterprise Linux
This code pattern will show you how to create a world class currency conversion microservice using Test Driven Development (TDD) in Python. This code pattern is a microservice that is a part of the Bee Travels project
- 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.
- Use and run this simple microservice.
- Build a docker image of this microservice using the RedHat Universal Base Image(UBI)
- Deploy and run this microservice on OpenShift version 4
This is the flow of the currency conversion microservice.
figure 1: Architecture flow
- Client API Consumer calls the microservice over the internet (http/s request).
- Flask process acts as a
web server
and accepts the REST request (e.g. GET /convertCurrency/ZAR/USD/600.66). - Code routing in Flask passes the request to a service module which in turn calls the External European Currency Exchange API (http://api.exchangeratesapi.io).
- An exchange rate for ZAR is retrieved and stored. The value of 600.66 South 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 ).
Follow these steps to set up and run this code pattern locally and on the cloud. The steps are described in detail below.
- Clone the GitHub repository locally
- Build a docker image, then run it locally
- Deploy to IBM RedHat OpenShift 4 Cluster
- Python3 / Flask
Introducing the Red Hat Universal Base Image - RedHat blog by Scott McCarty