This repository contains a Flask API project deployed on Kubernetes with monitoring using Prometheus and Grafana.
flask-on-kubernetes/
- app/
- static/ (Static files)
- templates/ (HTML templates)
- docker/ (Dockerfile and related files)
- k8s/ (Kubernetes manifests: Deployment, Service, HPA, etc.)
- prometheus/ (Prometheus & Grafana dashboards and configs)
- README.md
git clone https://github.com/victornaya-dev/flask-on-kubernetesApply all Kubernetes manifests
kubectl apply -f flask-on-kubernetes/k8s -RNote: This assumes Prometheus Operator is installed.
Check if Prometheus Operator is installed
kubectl get pods --all-namespaces | grep operatorIf there is a pod with a name similar to kube-prometheus-stack-operator-xxxx, the operator is installed.
Access the Flask API Open the API in your browser or via curl at:
http://<node-ip>:30008For local clusters (like Minikube), you can use:
http://localhost:30008Import Grafana Dashboard Import the dashboard JSON located at:
k8s/prometheus/grafana-dashboard.jsonPrometheus scrapes metrics from the Flask app using the /metrics endpoint. The Grafana dashboard includes:
- CPU usage per container
- Memory usage per container
- Requests per second
- Average latency
- Pod status (Running / Pending)
The Docker image for this project is available on Docker Hub: victordock218/myapp_flask_v003:tagname
However, you can also build and run the image locally if you prefer to customize it.
docker build -t myapp_flask_v003:latest .(Optional) Tag it if you want to push later:
docker tag myapp_flask_v003:latest victordock218/myapp_flask_v003:tagnameRun the container locally:
docker run -p 80:80 myapp_flask_v003:latestYou can now access the Flask API at:
http://localhost:80Once your Flask app is running (for example, via Docker, Kubernetes, or directly with python app.py), you can test it with:
curl http://localhost:30008/api/dataExpected response:
{"message": "Hello from flask API!", "status": "success"}