https://github.com/akaspatranobis/flask-api-microservices-k8
Flask, Mongo App
https://github.com/akaspatranobis/flask-api-microservices-k8
flask kubernetes python
Last synced: 3 months ago
JSON representation
Flask, Mongo App
- Host: GitHub
- URL: https://github.com/akaspatranobis/flask-api-microservices-k8
- Owner: akaspatranobis
- License: apache-2.0
- Created: 2025-01-07T18:33:07.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-07T18:44:54.000Z (over 1 year ago)
- Last Synced: 2025-10-10T12:38:15.365Z (9 months ago)
- Topics: flask, kubernetes, python
- Language: Python
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Kubernetes Microservice Flask Application
This is a microservice application built using Flask and deployed on Kubernetes. It is designed to demonstrate how to build and deploy microservices on a Kubernetes cluster.
## Table of Contents
- [Installation](#installation)
- [Usage](#usage)
- [Contributing](#contributing)
- [License](#license)
## Installation
To install and run the application on your Kubernetes cluster, follow these steps:
1. Clone this repository to your local machine.
2. Navigate to the project root directory.
3. Create a Kubernetes deployment and service by running the following command:
`kubectl apply -f kubernetes.yaml`
4. Verify that the deployment and service have been created successfully by running the following command:
`kubectl get deployments,services`
5. If everything is working properly, you should see the name of your deployment and service listed in the output.
6. Load some Data in Mongo.
`mongosh
use dev;
db.task.insertMany([
{ task: "Complete Kubernetes setup" },
{ task: "Build Flask app" },
{ task: "Deploy app to Kubernetes" }
]); `
7. Using the POST Method to Add Data.
The POST /task endpoint accepts a JSON payload to create a new task.
`curl -X POST http:///task \
-H "Content-Type: application/json" \
-d '{"task": "Write documentation for the app"}' `
8. Using the PUT Method to Update Data
The PUT /task/ endpoint allows you to update a task by its ID. To use it, you need the id of the task you want to update, which you can fetch using the GET /tasks endpoint.
`curl -X PUT http:///task/63d7b9c8... \
-H "Content-Type: application/json" \
-d '{"task": "Write and review documentation for the app"}' `
## Usage
To use the microservice, you can send HTTP requests to the service's endpoint. Here's an example request:
`curl http:///tasks`
This should return a JSON response with a greeting message.
## Contributing
If you'd like to contribute to this project, please fork the repository and create a new branch. Pull requests are welcome!
## License
This project is licensed under the Apache License 2.0 - see the [LICENSE.md]