Welcome to the Songs Microservice! This is a simple microservice that provides access to a collection of songs. It's built using Flask and connects to a MongoDB database to store song information. π
- π€ Add songs to the database.
- π§ Retrieve all songs from the database.
- πΆ Health Check endpoint to verify the service is up and running.
- Python π
- Flask π
- MongoDB ποΈ
- OpenShift βοΈ
- GitHub π»
After completing this lab, you will be able to:
- Start Code Engine service in the lab environment.
- Deploy a Flask service to Code Engine.
- Access the RedHat OpenShift platform in the lab environment.
- Deploy a Flask service to RedHat OpenShift.
Clone the repository to your local machine:
git clone https://github.com/Willie-Conway/Deploying-Microservices.git
Navigate to the project directory and set up a virtual environment:
cd Back-End-Development-Songs
python3 -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`
pip install -r requirements.txt
Ensure that the MongoDB service is up and running. Use the internal MongoDB URL for OpenShift or any other connection string.
Example MongoDB URL:
mongo.sn-labs-hirewillieco.svc.cluster.local
To run the microservice locally:
python app.py
Visit http://localhost:5000
to see the service in action! π
To deploy the microservice to OpenShift, use the following command:
oc new-app https://github.com/${GITHUB_ACCOUNT}/Back-End-Development-Songs --strategy=source --name=songs --env MONGODB_SERVICE=mongo.${OPENSHIFT_PROJECT}.svc.cluster.local --name songs
Once deployed, you can access the Songs microservice via the following URL:
http://songs-sn-labs-hirewillieco.labs-prod-openshift-san-a45631dc5778dc6371c67d206ba9ae5c-0000.us-east.containers.appdomain.cloud
Use the /health
endpoint to check if the service is running smoothly:
http://songs-sn-labs-hirewillieco.labs-prod-openshift-san-a45631dc5778dc6371c67d206ba9ae5c-0000.us-east.containers.appdomain.cloud/health
It will return a response like:
{
"status": "OK"
}
If you'd like to contribute, feel free to open an issue or pull request. π
- Fork the repo π΄
- Create your feature branch π§βπ»
- Commit your changes βοΈ
- Push to the branch π
- Open a pull request π₯
This project is licensed under the MIT License - see the LICENSE file for details. π
For any questions or suggestions, feel free to reach out to me via:
- Email: hire.willie.conway@gmail.com π§
- GitHub: Willie-Conway π¨βπ»
Happy coding! π