zkt25/z2
2025-04-21 18:56:16 +00:00
..
persistent-storage.yaml Téléverser les fichiers vers "z2" 2025-04-16 10:09:40 +00:00
prepare-app.sh Téléverser les fichiers vers "z2" 2025-04-16 10:09:40 +00:00
README.md Téléverser les fichiers vers "z2" 2025-04-16 10:09:40 +00:00
requirements.txt Téléverser les fichiers vers "z2" 2025-04-16 10:09:40 +00:00
service.yaml Téléverser les fichiers vers "z2" 2025-04-16 10:09:40 +00:00
start-app.sh Téléverser les fichiers vers "z2" 2025-04-16 10:09:40 +00:00
statefulset.yaml Téléverser les fichiers vers "z2" 2025-04-16 10:09:40 +00:00
stop-app.sh Téléverser les fichiers vers "z2" 2025-04-16 10:09:40 +00:00

PI Visualization Web Application on Kubernetes

Overview

This project deploys a Python web application using Flask on a Kubernetes cluster. The application displays the first 300 digits of PI with an interactive visualization. The deployment includes a Namespace, Deployment, StatefulSet (with PersistentVolume and PersistentVolumeClaim), and Service.

Application Description

  • The web application visualizes PI digits at the root URL (/).
  • Each digit appears one at a time (every 0.5 seconds by default) with a unique color.
  • Users can control the animation (start, pause, reset) and adjust the speed.
  • The application uses one container image built from the Dockerfile provided.

Containers

  • simple-web-app: Runs the Python Flask application on port 5000.

Kubernetes Objects

  • Namespace: Isolates all the resources under my-app.
  • Deployment: Manages the stateless web application pods with 2 replicas for high availability.
  • StatefulSet: Manages stateful application pods that require persistent storage.
  • PersistentVolume (PV): Provides persistent storage from the host (1GB).
  • PersistentVolumeClaim (PVC): Claims the PV for storage.
  • Service: Exposes the web application externally via NodePort 30007.

Networking and Storage

  • The application uses Kubernetes networking to enable communication between pods.
  • The StatefulSet uses a volume claim template that binds to a PersistentVolume mounted at /data.

Container Configuration

  • The container is based on Python and includes Flask.
  • It exposes port 5000 to serve the web application.
  • Resource limits and readiness probes are configured for better stability.

How to Prepare, Run, Pause, and Delete the Application

  1. Prepare the application:

    ./prepare-app.sh
    

    This script builds the Docker image and creates the directory for persistent volume.

  2. Start the application:

    ./start-app.sh
    

    This script creates all necessary Kubernetes objects in the correct order.

  3. Pause or delete the application:

    ./stop-app.sh
    

    This script removes all Kubernetes objects created by start-app.sh.

Accessing the Application

To access the application:

  1. Find the IP address of your Kubernetes node:

    kubectl get nodes -o wide
    
  2. Access the application in your browser at:

    http://<NODE_IP>:30007
    

    Where <NODE_IP> is the IP address of any of your Kubernetes nodes.

Troubleshooting

If you encounter issues:

  1. Check pod status:

    kubectl get pods -n my-app
    
  2. View pod logs:

    kubectl logs <pod-name> -n my-app
    
  3. Check service status:

    kubectl get svc -n my-app