| .. | ||
| app.py | ||
| backend-deployment.yaml | ||
| backend-service.yaml | ||
| deployment.yaml | ||
| Dockerfile | ||
| frontend-deployment.yaml | ||
| frontend-service.yaml | ||
| index.html | ||
| ingress.yaml | ||
| namespace.yaml | ||
| prepare-app.sh | ||
| README.md | ||
| requirements.txt | ||
| script.js | ||
| service.yaml | ||
| start-app.sh | ||
| statefulset.yaml | ||
| stop-app.sh | ||
| style.css | ||
| tasks.json | ||
| todo-app-deployment.yaml | ||
| todo-app-ns-v2.yaml | ||
| todo-app-pv.yaml | ||
| todo-app-pvc.yaml | ||
| todo-data-service.yaml | ||
| todo-data-statefulset.yaml | ||
To-Do List Application on Kubernetes
Application Description
This is a simple To-Do List web application that allows users to:
- Add new tasks
- Mark tasks as completed
- Delete tasks
- Filter tasks by their status (All, Active, Completed)
- Reorder tasks using drag-and-drop functionality
The application uses local storage to persist tasks and allows users to manage their daily tasks efficiently.
Container Images Used
-
todo-web-app:latest:
- Custom image based on nginx:alpine
- Contains the static web files (HTML, CSS, JavaScript) for the To-Do List application
- Serves the web interface on port 80
-
redis:alpine:
- Official Redis image based on Alpine Linux
- Used in the StatefulSet for data persistence
- Stores task data on a persistent volume
- Runs on port 6379
Kubernetes Objects
-
Namespace (
todo-app-ns):- Isolates all the application resources in a dedicated namespace
-
Deployment (
todo-web-app):- Manages the web application containers
- Maintains 2 replicas for high availability
- Defines resource limits and requests
-
StatefulSet (
todo-data-manager):- Manages Redis instances for data persistence
- Uses persistent storage to maintain task data
- Ensures data consistency during pod restarts
-
PersistentVolume (
todo-app-pv):- Provides storage resources for the application
- Uses local storage on the host at
/mnt/data/todo-app - 1GB capacity for storing task data
-
PersistentVolumeClaim (
todo-app-pvc):- Claims storage from the PersistentVolume
- Used by the StatefulSet for data persistence
-
Services:
todo-web-service: NodePort service exposing the web applicationtodo-data-service: Headless service for the StatefulSet
Network and Volume Configuration
Networks
- The application components communicate within the Kubernetes cluster using services
todo-web-serviceexposes the web interface externally using NodePorttodo-data-serviceprovides internal DNS-based service discovery for the StatefulSet
Volumes
- The application uses a persistent volume mounted at
/mnt/data/todo-appon the host - This volume is mounted into the Redis container at
/datato persist task data - The volume uses the
manualstorage class with ReadWriteOnce access mode
Container Configuration
Web Application Container
- Based on nginx:alpine
- Configured to serve static content from
/usr/share/nginx/html - Resource limits: 500m CPU, 256Mi memory
- Resource requests: 100m CPU, 128Mi memory
Redis Container
- Based on redis:alpine
- Data directory mounted to persistent storage
- Resource limits: 300m CPU, 256Mi memory
- Resource requests: 100m CPU, 128Mi memory
How to Use the Application
Prerequisites
- Kubernetes cluster (Minikube or similar)
- kubectl configured to communicate with your cluster
- Docker for building the application image
Prepare the Application
- Clone this repository
- Run the preparation script:
chmod +x prepare-app.sh ./prepare-app.sh
Start the Application
- Run the start script:
chmod +x start-app.sh ./start-app.sh - The script will display the URL to access the application
Stop the Application
- Run the stop script:
chmod +x stop-app.sh ./stop-app.sh
Accessing the Web Interface
- After starting the application, note the NodePort displayed in the terminal
- Open your web browser and navigate to
http://localhost:<NodePort> - You should see the To-Do List application interface
- Start adding tasks, marking them as completed, or deleting them as needed
Troubleshooting
- If pods aren't starting, check the pod status:
kubectl get pods -n todo-app-ns - For detailed pod issues:
kubectl describe pod <pod-name> -n todo-app-ns - To view logs:
kubectl logs <pod-name> -n todo-app-ns