A full-featured Flask notes application for testing docker-compose to Kubernetes deployment via K3s AI Manager.
- ✅ Full CRUD operations (Create, Read, Update, Delete)
- ✅ SQLite database with persistent storage
- ✅ RESTful API endpoints
- ✅ Beautiful, responsive UI
- ✅ Health check endpoint
- ✅ Ready for docker-compose deployment
- ✅ Kubernetes-ready with persistent volumes
- ✅ Load balanced with 2 replicas
docker-compose up --buildVisit: http://localhost:8080
pip install -r requirements.txt
python app.pyVisit: http://localhost:8080
- Open K3s AI Manager
- Navigate to Deployments
- Click Configure on your Ubuntu deployment
- Access the terminal
cd ~
git clone https://github.com/mozeal/SimpleWebAppPython.git
cd SimpleWebAppPython- In the Ubuntu Configure modal, click "Deploy docker-compose"
- Fill in the form:
- Compose File Path:
/home/ubuntu/SimpleWebAppPython/docker-compose.yml - Deployment Name:
notes-app(or your choice) - Custom Subdomain (optional):
my-notes
- Compose File Path:
- Click Preview to see what will be deployed
- Click Deploy and watch the build progress
- Once complete, click the generated URL to see your app!
Your app will be available at:
https://web-notes-app.artech.cloud
Or with custom subdomain:
https://web-my-notes.artech.cloud
| Endpoint | Method | Description |
|---|---|---|
/ |
GET | Home page with notes interface |
/health |
GET | Health check endpoint (JSON) |
/api/info |
GET | System information (JSON) |
/api/notes |
GET | Get all notes (JSON) |
/api/notes |
POST | Create new note (JSON) |
/api/notes/<id> |
GET | Get specific note (JSON) |
/api/notes/<id> |
PUT | Update note (JSON) |
/api/notes/<id> |
DELETE | Delete note |
curl -X POST https://web-notes-app.artech.cloud/api/notes \
-H "Content-Type: application/json" \
-d '{"title":"My First Note","content":"Hello from the API!"}'curl https://web-notes-app.artech.cloud/api/notescurl -X PUT https://web-notes-app.artech.cloud/api/notes/1 \
-H "Content-Type: application/json" \
-d '{"title":"Updated Title","content":"Updated content"}'curl -X DELETE https://web-notes-app.artech.cloud/api/notes/1SimpleWebAppPython/
├── app.py # Flask application with SQLite
├── templates/
│ └── index.html # Interactive notes UI
├── requirements.txt # Python dependencies
├── Dockerfile # Container image definition
├── docker-compose.yml # Deployment configuration
└── README.md # This file
When you deploy this app using docker-compose:
- 2 replicas of the web service (load balanced)
- 512MB RAM limit per pod
- 0.5 CPU limit per pod
- Persistent volume for SQLite database
- Automatic health checks every 30 seconds
- HTTPS URL with automatic routing via Traefik
- Zero-downtime rolling updates
Notes are stored in a SQLite database located at /data/notes.db inside the container. This directory is mounted as a Kubernetes PersistentVolume, ensuring your notes persist across:
- Pod restarts
- Deployments updates
- Container crashes
- Backend: Flask (Python)
- Database: SQLite
- Frontend: Vanilla JavaScript with modern CSS
- Container: Python 3.11 slim
- Orchestration: Kubernetes (via K3s)
- Ingress: Traefik
Edit docker-compose.yml:
ports:
- "3000:3000" # External:Internal
environment:
PORT: 3000Edit docker-compose.yml:
deploy:
replicas: 3 # Increase for higher availabilityEdit docker-compose.yml:
deploy:
resources:
limits:
cpus: '1.0'
memory: 1024MProblem: Image build fails with "file not found" Solution: Ensure all files exist in the repository:
ls -la ~/SimpleWebAppPython/
# Should show: app.py, Dockerfile, docker-compose.yml, requirements.txt, templates/Problem: Pods crash or won't start Solution: Check logs in K3s AI Manager:
- Click deployment status
- View logs
- Look for errors in application startup
Problem: Notes disappear after restart Solution: Ensure persistent volume is correctly mounted:
kubectl get pvc -n <namespace>
# Should show a PVC bound to the volumeProblem: URL returns 404 or connection error Solution:
- Wait 30 seconds after deployment completes (DNS propagation)
- Check pod status - should show "2/2 Running"
- Verify HTTPS (not HTTP) in URL
This app demonstrates a production-ready deployment pattern:
┌─────────────────────────────────────────┐
│ User Browser │
└──────────────┬──────────────────────────┘
│ HTTPS
▼
┌─────────────────────────────────────────┐
│ Traefik Ingress Controller │
│ (Automatic HTTPS, Load Balancing) │
└──────────────┬──────────────────────────┘
│
┌──────┴──────┐
│ │
▼ ▼
┌──────────┐ ┌──────────┐
│ Pod 1 │ │ Pod 2 │
│ Flask │ │ Flask │
│ SQLite │ │ SQLite │
└────┬─────┘ └────┬─────┘
│ │
└───────┬───────┘
▼
┌─────────────────────────────────────────┐
│ Persistent Volume (notes-data) │
│ SQLite Database │
└─────────────────────────────────────────┘
Run locally with auto-reload:
export FLASK_ENV=development
python app.pyRun tests:
# Install test dependencies
pip install pytest requests
# Run tests (example)
pytest tests/MIT License - Feel free to use this for learning and testing!
For issues with the app, open an issue on GitHub.
For issues with K3s AI Manager deployment, check the main documentation.
Happy Deploying! 🚀