In this code pattern, you will build a movie ticket reservation application using Crunchy Data PostgreSQL on Red Hat Marketplace.
After completing this code pattern, you will understand how to:
- Deploy Crunchy PostgreSQL for Kubernetes Operator on an OpenShift cluster.
- Create a CrunchyDB cluster and database.
- Access the cluster on your localhost.
- Connect and access CrunchyDB data from a python flask application.
- User enters his details and reserves his seat.
- Application updates the Crunchy Data PostgreSQL tables accordingly.
- Application fetches the updated data from the tables.
- Application displays the updated seats availability data and booking details data that was fetched from the respective tables.
- Red Hat Marketplace Account.
- IBM Managed Red Hat OpenShift Cluster.
- For all operators being installed from Red Hat Marketplace, a Red Hat OpenShift cluster version 4.3 or higher is mandatory. Please set up a classic cluster using the instructions from this URL. Setting up OpenShift Cluster
- OC & kubectl CLI.
- Clone the repo
- Deploy a Crunchy PostgreSQL for Kubernetes Operator to an OpenShift cluster
- Run the application
- Analyse the results
Clone the movie_ticket_booking_application_using_crunchydb repo locally. In a terminal, run:
$ git clone https://github.com/IBM/movie_ticket_booking_application_using_crunchydb
Steps to Deploy Crunchy PostgreSQL for Kubernetes Operator from Red Hat Marketplace on OpenShift Cluster can be found at Steps to Deploy Crunchy PostgreSQL for Kubernetes Operator
To run the application, follow these steps:
Go to the cloned repo from step 1. In your terminal, run the following commands to install the required python libraries and run the app
- Install the required Python libraries by running the following command:
$ pip install -r requirements.txt- Run the application as follows:
$ python app.pyOpen the following URL in the browser: http://localhost:5000/create
Click on the link. This will create screen and userdetails tables in the Crunchy Data PostgreSQL database and load it with required data.
Note: Please be patient, this step will take a while
Open the application by following the promptss or opening the http://localhost:5000/.
The booking application showing the seats in a theater should lead on your screen.

Now, let's play around with the app to see how it works.
-
Select the seats you want, type your name and phone number in the fields and click Reserve Seats.
-
Your booking will be showcased in the booking details tab . Click on
Reserve More Ticketsto reserve more seats.The seats you chose will be marked with an X, as shown below:
-
You can view the tables in the CruncyDB console by running the following commands on the terminal,
kubectl port-forward -n pgo svc/cpdemo-pgadmin 5050:5050 -
Open the browser with the URL,
http://localhost:5050/. This will open the console forCrunchy Data PostgreSQLdatabase.For more details on
Crunchy Data PostgreSQLconsole, refer to this tutorial
This code pattern is licensed under the Apache License, Version 2. Separate third-party code objects invoked within this code pattern are licensed by their respective providers pursuant to their own separate licenses. Contributions are subject to the Developer Certificate of Origin, Version 1.1 and the Apache License, Version 2.




