Skip to content

victornaya-dev/flask-on-kubernetes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flask API Project

Overview

This repository contains a Flask API project deployed on Kubernetes with monitoring using Prometheus and Grafana.

Project Structure

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

Quick Start

Clone the project

git clone https://github.com/victornaya-dev/flask-on-kubernetes

Apply all Kubernetes manifests

kubectl apply -f flask-on-kubernetes/k8s -R

Note: This assumes Prometheus Operator is installed.

Check if Prometheus Operator is installed

kubectl get pods --all-namespaces | grep operator

If 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>:30008

Flask API Image

For local clusters (like Minikube), you can use:

http://localhost:30008

Import Grafana Dashboard Import the dashboard JSON located at:

k8s/prometheus/grafana-dashboard.json

Monitoring & Metrics

Prometheus 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)

Grafana Image

Docker Image (Optional)

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:tagname

Run the container locally:

docker run -p 80:80 myapp_flask_v003:latest

You can now access the Flask API at:

http://localhost:80

TEST

Once 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/data

Expected response:

{"message": "Hello from flask API!", "status": "success"}

Curl Image

About

Flask API project deployed on Kubernetes with monitoring using Prometheus and Grafana.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published