Skip to content

Repository files navigation

python-flask-probe

Minimal Python Flask application used for deployment validation across any environment (local, Docker, Kubernetes, ECS, etc.).

This is the Python counterpart to the node-express-probe and validates deployment across different stacks.

Use Cases

  • Validate Docker builds and images
  • Test Kubernetes / ECS deployments
  • Verify CI/CD smoke tests
  • Experiment with runtime behavior across different platforms
  • Backstage integration testing

Endpoints

EndpointMethodPurpose
/GETRoot - basic service info
/healthGETHealth check (returns JSON)
/healthzGETKubernetes-style health check
/readyGETReadiness probe
/liveGETLiveness probe
/api/v1/infoGETDetailed app info (time, hostname, version)
/api/v1/versionGETVersion and commit info

Local Development

Quick Start

# Install dependencies
pip install -r requirements.txt
# Run the app
python src/app.py

The app will start on http://localhost:8080

With Environment Variables

# Set custom version and commit
APP_VERSION=2.0.0 APP_COMMIT_SHA=abc123 python src/app.py

Docker Local

# Build image
docker build -t python-probe:latest .# Run container
docker run -p 8080:8080 python-probe:latest
# With environment variables
docker run -p 8080:8080 \
-e APP_VERSION=2.0.0 \
-e APP_COMMIT_SHA=abc123 \
python-probe:latest

Kubernetes Deployment

The app includes proper probe endpoints for Kubernetes:

livenessProbe:
httpGet:
path: /liveport: 8080initialDelaySeconds: 5periodSeconds: 10readinessProbe:
httpGet:
path: /readyport: 8080initialDelaySeconds: 5periodSeconds: 5

See k8s/deploy.yaml for full deployment example.


ECS / EC2 Deployment

The app works on any environment. Set environment variables via:

  • EC2: User data script or SSM Parameter Store
  • ECS: Task definition environment variables
  • Docker: -e flag or .env file
# Example EC2 user data#!/bin/bashexport APP_VERSION=1.0.0
export APP_COMMIT_SHA=${GIT_COMMIT}
python /app/src/app.py

Configuration

VariableDefaultPurpose
PORT8080Port to listen on
APP_VERSION1.0.0Application version
APP_COMMIT_SHAunknownGit commit SHA (for tracking)

Production

For production, the Docker image uses Gunicorn (4 workers) instead of Flask's development server:

# Manual production run
gunicorn --bind 0.0.0.0:8080 --workers 4 --access-logfile - app:app

Development

Project Structure

src/
app.py # Flask application
requirements.txt # Python dependencies
Dockerfile # Docker image definition
k8s/ # Kubernetes manifests
chart/ # Helm chart (optional)

Testing Endpoints

# Health checks
curl http://localhost:8080/health
curl http://localhost:8080/live
curl http://localhost:8080/ready
# App info
curl http://localhost:8080/api/v1/info
curl http://localhost:8080/api/v1/version

License

MIT

About

Minimal Flask-based deployment probe for Docker, Kubernetes, ECS, and CI/CD validation.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages