.. | ||
persistent-storage.yaml | ||
prepare-app.sh | ||
README.md | ||
requirements.txt | ||
service.yaml | ||
start-app.sh | ||
statefulset.yaml | ||
stop-app.sh |
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
-
Prepare the application:
./prepare-app.sh
This script builds the Docker image and creates the directory for persistent volume.
-
Start the application:
./start-app.sh
This script creates all necessary Kubernetes objects in the correct order.
-
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:
-
Find the IP address of your Kubernetes node:
kubectl get nodes -o wide
-
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:
-
Check pod status:
kubectl get pods -n my-app
-
View pod logs:
kubectl logs <pod-name> -n my-app
-
Check service status:
kubectl get svc -n my-app