This project is a simple web application based on Flask. Its purpose is to serve as a test environment for configuring CI/CD pipelines and deploying to Kubernetes. The application uses PostgreSQL to store records (discovered planets) and Redis for a visit/action counter.
- Flask — Python web application framework.
- PostgreSQL — persistent storage for log entries.
- Redis — visitor counter.
- Docker Compose — local environment startup.
- Kubernetes — container orchestration.
- GitHub Actions — automated testing, image building, and deployment.
Browser
│
▼
Flask web (Service: web)
├── PostgreSQL (Service: postgres, StatefulSet + PVC)
└── Redis (Service: redis, Deployment)
The project includes a docker-compose.yml file. It starts the Flask application, PostgreSQL, and Redis locally:
docker compose up --buildOnce started, navigate to http://localhost:5001 in your web browser.
To stop the containers:
docker compose downThe test suite verifies the availability of the main page and the logic for adding records.
cd app
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
pytest test_app.py -vEnable Kubernetes in Docker Desktop, then verify that the cluster is available:
kubectl get nodesCreate a local secret from the template:
cd k8s
Copy-Item secret.example.yaml secret.yaml
notepad secret.yamlNote:
secret.yamlcontains local passwords and is excluded from Git.
Deploy the application:
kubectl apply -f namespace.yaml
kubectl apply -f secret.yaml
kubectl apply -f configmap.yaml
kubectl apply -f postgres.yaml
kubectl apply -f redis.yaml
kubectl apply -f app.yamlCheck the Pod status:
kubectl get pods -n space-explorerTo access the application locally:
kubectl port-forward -n space-explorer service/web 8080:80Then open http://localhost:8080 in your web browser.
The workflow is located in .github/workflows/ci-cd.yml.
After every git push to the main branch, GitHub Actions automatically:
- Runs the tests.
- Builds the Docker image.
- Pushes the image to Docker Hub.
- Updates the Flask application in the local Kubernetes cluster.
| Secret | Purpose |
|---|---|
DOCKERHUB_USERNAME |
Docker Hub username |
DOCKERHUB_TOKEN |
Token used to push the image |
Deployment is performed by a self-hosted GitHub runner on the local PC because it has access to Kubernetes in Docker Desktop.
k8s/
├── namespace.yaml # Namespace
├── configmap.yaml # Redis configuration
├── secret.example.yaml # Secret template
├── postgres.yaml # PostgreSQL Service, StatefulSet, PVC
├── redis.yaml # Redis Service and Deployment
├── app.yaml # Flask Service and Deployment
└── README.md # Kubernetes documentation
- Do not add
k8s/secret.yamlto Git. - Do not publish the Docker Hub Access Token.
- In production projects, store sensitive values in a dedicated secrets manager.