Update z2/README.md

This commit is contained in:
Danylo Kunak 2025-04-17 07:24:45 +00:00
parent 94332d8469
commit 77b0f385b6

View File

@ -1,104 +1,104 @@
# Interactive Floor Plan Application with Kubernetes # Interactive Floor Plan Application with Kubernetes
## Application Description ## Application Description
This application is an interactive floor plan visualization tool that displays sensor data on different floors of a building. Users can navigate between floors using the buttons at the bottom of the page and click on sensors to view their current data. This application is an interactive floor plan visualization tool that displays sensor data on different floors of a building. Users can navigate between floors using the buttons at the bottom of the page and click on sensors to view their current data.
## Container List ## Container List
1. **floorplan-webapp** 1. **floorplan-webapp**
- Web application container based on Python and Flask - Web application container based on Python and Flask
- Serves the frontend HTML, CSS, and JavaScript files - Serves the frontend HTML, CSS, and JavaScript files
- Provides an API endpoint for sensor data - Provides an API endpoint for sensor data
2. **mysql-db** 2. **mysql-db**
- MySQL database container - MySQL database container
- Stores sensor information including position, floor, location, and values - Stores sensor information including position, floor, location, and values
## Kubernetes Objects ## Kubernetes Objects
1. **Namespace** 1. **Namespace**
- `sensor-app`: Isolated environment for all application resources - `sensor-app`: Isolated environment for all application resources
2. **Deployment** 2. **Deployment**
- `floorplan-webapp`: Manages the web application with 2 replicas for high availability - `floorplan-webapp`: Manages the web application with 2 replicas for high availability
3. **StatefulSet** 3. **StatefulSet**
- `mysql`: Manages the MySQL database instance with persistent storage - `mysql`: Manages the MySQL database instance with persistent storage
4. **Services** 4. **Services**
- `floorplan-service`: NodePort service exposing the web application on port 30080 - `floorplan-service`: NodePort service exposing the web application on port 30080
- `mysql-service`: Headless service for MySQL database access - `mysql-service`: Headless service for MySQL database access
5. **PersistentVolume** 5. **PersistentVolume**
- `mysql-pv`: 1GB volume for MySQL data storage - `mysql-pv`: 1GB volume for MySQL data storage
6. **PersistentVolumeClaim** 6. **PersistentVolumeClaim**
- `mysql-pvc`: Claims storage from the persistent volume for MySQL - `mysql-pvc`: Claims storage from the persistent volume for MySQL
## Network and Storage Configuration ## Network and Storage Configuration
### Networks ### Networks
- The application uses Kubernetes' built-in networking - The application uses Kubernetes' built-in networking
- Web application connects to MySQL using the `mysql-service` DNS name - Web application connects to MySQL using the `mysql-service` DNS name
- External access is provided through a NodePort service on port 30080 - External access is provided through a NodePort service on port 8080
### Storage ### Storage
- The MySQL database uses a persistent volume mounted at `/var/lib/mysql` - The MySQL database uses a persistent volume mounted at `/var/lib/mysql`
- The persistent volume is backed by a hostPath at `/mnt/data` on the host machine - The persistent volume is backed by a hostPath at `/mnt/data` on the host machine
## Container Configuration ## Container Configuration
### Web Application Container ### Web Application Container
- Based on Python 3.9 slim image - Based on Python 3.9 slim image
- Installed packages: Flask, mysql-connector-python - Installed packages: Flask, mysql-connector-python
- Configured to connect to MySQL database using environment variables - Configured to connect to MySQL database using environment variables
- Exposes port 5000 - Exposes port 5000
### MySQL Container ### MySQL Container
- Based on MySQL 8.0 image - Based on MySQL 8.0 image
- Configured with empty root password for development purposes - Configured with empty root password for development purposes
- Initializes with the sensors_db database and sample data - Initializes with the sensors_db database and sample data
- Exposes port 3306 - Exposes port 3306
## Application Management ## Application Management
### Preparation ### Preparation
1. Make all scripts executable: 1. Make all scripts executable:
``` ```
chmod +x prepare-app.sh start-app.sh stop-app.sh chmod +x prepare-app.sh start-app.sh stop-app.sh
``` ```
2. Run the preparation script: 2. Run the preparation script:
``` ```
./prepare-app.sh ./prepare-app.sh
``` ```
This will: This will:
- Create the required namespace - Create the required namespace
- Prepare the persistent volume directory - Prepare the persistent volume directory
- Build the Docker images - Build the Docker images
### Starting the Application ### Starting the Application
1. Run the start script: 1. Run the start script:
``` ```
./start-app.sh ./start-app.sh
``` ```
This will: This will:
- Apply all Kubernetes configurations - Apply all Kubernetes configurations
- Wait for all components to be ready - Wait for all components to be ready
- Display the URL to access the application - Display the URL to access the application
### Stopping the Application ### Stopping the Application
1. Run the stop script: 1. Run the stop script:
``` ```
./stop-app.sh ./stop-app.sh
``` ```
This will: This will:
- Remove all Kubernetes objects created for the application - Remove all Kubernetes objects created for the application
- The persistent volume data will remain intact - The persistent volume data will remain intact
### Viewing the Application ### Viewing the Application
1. Open your web browser 1. Open your web browser
2. Navigate to the URL displayed after running the start script (typically http://[NODE-IP]:30080) 2. Navigate to the URL displayed after running the start script http://localhost:8080
3. You should see the interactive floor plan with sensors 3. You should see the interactive floor plan with sensors
4. Use the buttons at the bottom to switch between floors 4. Use the buttons at the bottom to switch between floors
5. Click on sensors to view their data in the right panel 5. Click on sensors to view their data in the right panel