zkt25/Z2
2025-04-17 01:53:09 +00:00
..
app.py Загрузить файлы в «Z2» 2025-04-17 01:53:09 +00:00
backend-deployment.yaml Загрузить файлы в «Z2» 2025-04-17 01:53:09 +00:00
backend-service.yaml Загрузить файлы в «Z2» 2025-04-17 01:53:09 +00:00
deployment.yaml Загрузить файлы в «Z2» 2025-04-17 01:53:09 +00:00
Dockerfile Загрузить файлы в «Z2» 2025-04-17 01:53:09 +00:00
frontend-deployment.yaml Загрузить файлы в «Z2» 2025-04-17 01:53:09 +00:00
frontend-service.yaml Загрузить файлы в «Z2» 2025-04-17 01:53:09 +00:00
index.html Загрузить файлы в «Z2» 2025-04-17 01:53:09 +00:00
ingress.yaml Загрузить файлы в «Z2» 2025-04-17 01:53:09 +00:00
namespace.yaml Загрузить файлы в «Z2» 2025-04-17 01:53:09 +00:00
prepare-app.sh Загрузить файлы в «Z2» 2025-04-17 01:53:09 +00:00
README.md Загрузить файлы в «Z2» 2025-04-17 01:53:09 +00:00
requirements.txt Загрузить файлы в «Z2» 2025-04-17 01:53:09 +00:00
script.js Загрузить файлы в «Z2» 2025-04-17 01:53:09 +00:00
service.yaml Загрузить файлы в «Z2» 2025-04-17 01:53:09 +00:00
start-app.sh Загрузить файлы в «Z2» 2025-04-17 01:53:09 +00:00
statefulset.yaml Загрузить файлы в «Z2» 2025-04-17 01:53:09 +00:00
stop-app.sh Загрузить файлы в «Z2» 2025-04-17 01:53:09 +00:00
style.css Загрузить файлы в «Z2» 2025-04-17 01:53:09 +00:00
tasks.json Загрузить файлы в «Z2» 2025-04-17 01:53:09 +00:00
todo-app-deployment.yaml Загрузить файлы в «Z2» 2025-04-17 01:53:09 +00:00
todo-app-ns-v2.yaml Загрузить файлы в «Z2» 2025-04-17 01:53:09 +00:00
todo-app-pv.yaml Загрузить файлы в «Z2» 2025-04-17 01:53:09 +00:00
todo-app-pvc.yaml Загрузить файлы в «Z2» 2025-04-17 01:53:09 +00:00
todo-data-service.yaml Загрузить файлы в «Z2» 2025-04-17 01:53:09 +00:00
todo-data-statefulset.yaml Загрузить файлы в «Z2» 2025-04-17 01:53:09 +00:00

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

  1. 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
  2. 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

  1. Namespace (todo-app-ns):

    • Isolates all the application resources in a dedicated namespace
  2. Deployment (todo-web-app):

    • Manages the web application containers
    • Maintains 2 replicas for high availability
    • Defines resource limits and requests
  3. StatefulSet (todo-data-manager):

    • Manages Redis instances for data persistence
    • Uses persistent storage to maintain task data
    • Ensures data consistency during pod restarts
  4. 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
  5. PersistentVolumeClaim (todo-app-pvc):

    • Claims storage from the PersistentVolume
    • Used by the StatefulSet for data persistence
  6. Services:

    • todo-web-service: NodePort service exposing the web application
    • todo-data-service: Headless service for the StatefulSet

Network and Volume Configuration

Networks

  • The application components communicate within the Kubernetes cluster using services
  • todo-web-service exposes the web interface externally using NodePort
  • todo-data-service provides internal DNS-based service discovery for the StatefulSet

Volumes

  • The application uses a persistent volume mounted at /mnt/data/todo-app on the host
  • This volume is mounted into the Redis container at /data to persist task data
  • The volume uses the manual storage 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

  1. Clone this repository
  2. Run the preparation script:
    chmod +x prepare-app.sh
    ./prepare-app.sh
    

Start the Application

  1. Run the start script:
    chmod +x start-app.sh
    ./start-app.sh
    
  2. The script will display the URL to access the application

Stop the Application

  1. Run the stop script:
    chmod +x stop-app.sh
    ./stop-app.sh
    

Accessing the Web Interface

  1. After starting the application, note the NodePort displayed in the terminal
  2. Open your web browser and navigate to http://localhost:<NodePort>
  3. You should see the To-Do List application interface
  4. 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