- Python 3.11+
- FastAPI
- Uvicorn
- Docker
- Jenkins
- Kubernetes
Automate the build, Docker image creation, Docker image push, and Kubernetes deployment of a FastAPI Inventory REST API.
Method| Endpoint| Description GET| "/health"| Health check GET| "/products"| Retrieve all products POST| "/products"| Add a product
Use an in-memory list. No database is required.
Install dependencies
pip install -r requirements.txt
Run
uvicorn main:app --host 0.0.0.0 --port 8000
Application URL
Swagger
Verify
GET /health GET /products
Create a "Dockerfile".
Verify:
- Docker image builds successfully.
- Container starts successfully.
- Health endpoint is reachable.
Create a Declarative "Jenkinsfile" containing:
- Checkout
- Install Dependencies
- Docker Build
- Docker Push
Docker image format:
/python-inventory-api:${BUILD_NUMBER}
Create:
- "deployment.yaml"
- "service.yaml"
Requirements:
- Replicas = 2
- NodePort Service
Deploy
kubectl apply -f deployment.yaml kubectl apply -f service.yaml
Verify
kubectl get pods kubectl get svc
- FastAPI Source Code
- Dockerfile
- Jenkinsfile
- deployment.yaml
- service.yaml
- Jenkins Pipeline Screenshot
- Docker Hub Screenshot
- Kubernetes Pods Screenshot
- Browser/Postman Output Screenshot
RaviKumar K
This project is provided for learning, training, and demonstration purposes.