| .. | ||
| images | ||
| app.js | ||
| app.py | ||
| deployment.yaml | ||
| Dockerfile | ||
| Dockerfile.mysql | ||
| index.html | ||
| prepare-app.sh | ||
| README.md | ||
| sensors_db.sql | ||
| service.yaml | ||
| start-app.sh | ||
| statefulset.yaml | ||
| stop-app.sh | ||
| styles.css | ||
Interactive Floor Plan Application with Kubernetes
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.
Container List
-
floorplan-webapp
- Web application container based on Python and Flask
- Serves the frontend HTML, CSS, and JavaScript files
- Provides an API endpoint for sensor data
-
mysql-db
- MySQL database container
- Stores sensor information including position, floor, location, and values
Kubernetes Objects
-
Namespace
sensor-app: Isolated environment for all application resources
-
Deployment
floorplan-webapp: Manages the web application with 2 replicas for high availability
-
StatefulSet
mysql: Manages the MySQL database instance with persistent storage
-
Services
floorplan-service: NodePort service exposing the web application on port 30080mysql-service: Headless service for MySQL database access
-
PersistentVolume
mysql-pv: 1GB volume for MySQL data storage
-
PersistentVolumeClaim
mysql-pvc: Claims storage from the persistent volume for MySQL
Network and Storage Configuration
Networks
- The application uses Kubernetes' built-in networking
- Web application connects to MySQL using the
mysql-serviceDNS name - External access is provided through a NodePort service on port 30080
Storage
- The MySQL database uses a persistent volume mounted at
/var/lib/mysql - The persistent volume is backed by a hostPath at
/mnt/dataon the host machine
Container Configuration
Web Application Container
- Based on Python 3.9 slim image
- Installed packages: Flask, mysql-connector-python
- Configured to connect to MySQL database using environment variables
- Exposes port 5000
MySQL Container
- Based on MySQL 8.0 image
- Configured with empty root password for development purposes
- Initializes with the sensors_db database and sample data
- Exposes port 3306
Application Management
Preparation
- Make all scripts executable:
chmod +x prepare-app.sh start-app.sh stop-app.sh - Run the preparation script:
This will:./prepare-app.sh- Create the required namespace
- Prepare the persistent volume directory
- Build the Docker images
Starting the Application
- Run the start script:
This will:./start-app.sh- Apply all Kubernetes configurations
- Wait for all components to be ready
- Display the URL to access the application
Stopping the Application
- Run the stop script:
This will:./stop-app.sh- Remove all Kubernetes objects created for the application
- The persistent volume data will remain intact
Viewing the Application
- Open your web browser
- Navigate to the URL displayed after running the start script http://localhost:8080
- You should see the interactive floor plan with sensors
- Use the buttons at the bottom to switch between floors
- Click on sensors to view their data in the right panel