Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Space Explorer Logbook

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.


🧰 Technologies

  • 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.

🏗️ Architecture

Browser
   │
   ▼
Flask web (Service: web)
   ├── PostgreSQL (Service: postgres, StatefulSet + PVC)
   └── Redis (Service: redis, Deployment)

🐳 Running Locally

The project includes a docker-compose.yml file. It starts the Flask application, PostgreSQL, and Redis locally:

docker compose up --build

Once started, navigate to http://localhost:5001 in your web browser.

To stop the containers:

docker compose down

🧪 Running Tests

The 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 -v

☸️ Kubernetes Deployment

Enable Kubernetes in Docker Desktop, then verify that the cluster is available:

kubectl get nodes

Create a local secret from the template:

cd k8s
Copy-Item secret.example.yaml secret.yaml
notepad secret.yaml

Note: secret.yaml contains 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.yaml

Check the Pod status:

kubectl get pods -n space-explorer

To access the application locally:

kubectl port-forward -n space-explorer service/web 8080:80

Then open http://localhost:8080 in your web browser.


🔄 CI/CD Pipeline

The workflow is located in .github/workflows/ci-cd.yml.

After every git push to the main branch, GitHub Actions automatically:

  1. Runs the tests.
  2. Builds the Docker image.
  3. Pushes the image to Docker Hub.
  4. Updates the Flask application in the local Kubernetes cluster.

Required GitHub Secrets

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.


📁 Kubernetes Manifests

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

🔐 Security

  • Do not add k8s/secret.yaml to Git.
  • Do not publish the Docker Hub Access Token.
  • In production projects, store sensitive values in a dedicated secrets manager.

About

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.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages