A simple Flask microservice for learning Kubernetes, Docker, and modern Python development practices.
- RESTful API with multiple endpoints
- Health checks and monitoring endpoints
- CORS support for cross-origin requests
- Security headers (X-Frame-Options, CSP, etc.)
- Docker support with multi-stage builds
- Kubernetes ready with deployment configurations
- CI/CD pipelines (GitLab CI, GitHub Actions)
- Comprehensive testing with pytest
- Production-ready with Gunicorn
| Endpoint | Method | Description |
|---|---|---|
/ |
GET | Welcome page with API documentation |
/ping |
GET | Simple ping-pong health check |
/healthz |
GET | Detailed health check with system metrics |
/info |
GET | Application and system information |
/version |
GET | Application version information |
/echo |
POST | Echo back the request body |
- Python 3.12 or higher
- Docker (optional)
- make (optional, for using Makefile commands)
- Clone the repository
git clone https://github.com/dxas90/learn-python.git
cd learn-python- Install dependencies
make install
# or manually:
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
pip install -r requirements-dev.txt- Run the application
make dev
# or manually:
source .venv/bin/activate
FLASK_ENV=development flask run --host=0.0.0.0 --port=8000- Test the API
curl http://localhost:8000/
curl http://localhost:8000/ping
curl http://localhost:8000/healthzmake test
# or with coverage:
make test-coverage# Build the image
make docker-build
# Run the container
make docker-run
# Or manually:
docker build -t learn-python .
docker run -p 8000:8000 learn-pythonoc new-app https://github.com/dxas90/learn-python.gitmake k8s-deploy
# or manually:
kubectl apply -f k8s/ Git Actions: CI System Actions:
+-------------------------+ +-----------------+
+-►| Create a Feature Branch | +--►| Build Container |
| +------------+------------+ | +--------+--------+
| | | |
| | | |
| +--------▼--------+ | +-------▼--------+
| +--►+ Push the Branch +-------+ | Push Container |
| | +--------+--------+ +-------+--------+
| | | |
| | | |
| | +------▼------+ +---------▼-----------+
| +-----+ Test/Verify +◄-------+ | Deploy Container to |
| +------+------+ | | Ephemeral Namespace |
| | | +---------+-----------+
| | | |
| | +-------------+
| |
| | +-----------------+
| | +-----►| Build Container |
| +--------▼--------+ | +--------+--------+
| +--►+ Merge to Master +----+ |
| | +--------+--------+ |
| | | +-------▼--------+
| | | | Push Container |
| | +------▼------+ +-------+--------+
| +-----+ Test/Verify +◄------+ |
| +------+------+ | |
| | | +---------▼-----------+
| | | | Deploy Container to |
| | | | Staging Namespace |
| | | +---------+-----------+
| | | |
| | +--------------+
| |
| +------▼-----+ +---------------------+
+--------+ Tag Master +------------►| Deploy Container to |
+------------+ | Production |
+---------------------+