123 lines
3.3 KiB
Markdown
123 lines
3.3 KiB
Markdown
# 🧠 Typing Speed & RSI Awareness Game - Kubernetes Deployment
|
|
|
|
This project showcases a web-based **Typing Speed & RSI Awareness Game** deployed on a Kubernetes cluster. Although the game is a simple frontend app (HTML, CSS, JavaScript), the Kubernetes setup is fully compliant with deployment best practices and assignment requirements.
|
|
|
|
---
|
|
|
|
## 🎮 Game Overview
|
|
|
|
The application is designed to:
|
|
- Improve typing speed and accuracy.
|
|
- Educate users on RSI (Repetitive Strain Injury) prevention.
|
|
- Include real-time feedback and typing stats.
|
|
- Encourage healthy typing habits with periodic stretch reminders.
|
|
|
|
---
|
|
|
|
## 📁 Project Structure
|
|
|
|
File/Folder Description |
|
|
|
|
| index.html`, `style.css`, `script.js` | Frontend game files |
|
|
| Dockerfile` | Builds Nginx image to serve the game |
|
|
| prepare-app.sh` | Prepares the environment and Docker image |
|
|
| start-app.sh` | Applies all Kubernetes resources |
|
|
| stop-app.sh` | Cleans up all Kubernetes resources |
|
|
| namespace.yaml` | Creates the `typing-game` namespace |
|
|
| deployment.yaml` | Deploys the frontend via Nginx |
|
|
| service.yaml` | Exposes frontend using NodePort |
|
|
| pv-pvc.yaml` | Defines persistent volume and claim |
|
|
| statefulset.yaml` | Dummy backend with StatefulSet + PVC |
|
|
|
|
|
|
|
---
|
|
|
|
## How to Run
|
|
|
|
### Step 1: Prepare the Application
|
|
|
|
```bash
|
|
./prepare-app.sh
|
|
```
|
|
|
|
- Builds the Docker image: `typing-game`
|
|
- Saves it as a `.tar` for loading on cluster nodes
|
|
- Prepares persistent storage
|
|
|
|
---
|
|
|
|
### Step 2: Deploy the Application
|
|
|
|
```bash
|
|
./start-app.sh
|
|
```
|
|
|
|
This applies:
|
|
- Namespace
|
|
- Deployment
|
|
- Service
|
|
- StatefulSet
|
|
- PersistentVolume + PersistentVolumeClaim
|
|
|
|
---
|
|
|
|
### Step 3: Access the App
|
|
|
|
Open in your browser:
|
|
|
|
```
|
|
http://<your-node-ip>:30007
|
|
```
|
|
|
|
> Replace `<your-node-ip>` with the external IP of your Kubernetes node.
|
|
|
|
---
|
|
|
|
### Step 4: Clean Up
|
|
|
|
```bash
|
|
./stop-app.sh
|
|
```
|
|
|
|
This deletes all Kubernetes resources created by this project.
|
|
|
|
---
|
|
|
|
## ✅ Assignment Requirements Fulfilled
|
|
|
|
### 1. Namespace
|
|
**Requirement:** All objects must belong to a custom namespace.
|
|
**You Did:** Defined `typing-game` in `namespace.yaml`, and referenced it in all other files.
|
|
|
|
### 2. Deployment
|
|
**Requirement:** Deploy your web application.
|
|
**You Did:** Used `deployment.yaml` to deploy your frontend game using Nginx.
|
|
|
|
### 3. StatefulSet + PersistentVolume + PersistentVolumeClaim
|
|
**Requirement:** Demonstrate persistent storage via a StatefulSet.
|
|
**You Did:**
|
|
- Used `statefulset.yaml` with Alpine Linux writing logs to `/data/log.txt`.
|
|
- Mounted `/data` using a PVC created from `pv-pvc.yaml`.
|
|
|
|
### 4. Service
|
|
**Requirement:** Expose your app.
|
|
**You Did:** Used a `NodePort` service in `service.yaml` on port `30007`.
|
|
|
|
### 5. start-app.sh
|
|
**Requirement:** Script to create all objects.
|
|
**You Did:** Automated creation of namespace, Deployment, Service, StatefulSet, PV/PVC.
|
|
|
|
### 6. stop-app.sh
|
|
**Requirement:** Script to delete all objects.
|
|
**You Did:** Cleanly removes all created Kubernetes objects.
|
|
|
|
### 7. prepare-app.sh
|
|
**Requirement:** Prepares the environment.
|
|
**You Did:** Builds and saves Docker image, prepares persistent volume.
|
|
|
|
### 8. Dockerfile
|
|
**Requirement:** Provide necessary container files.
|
|
**You Did:** Dockerfile builds a custom Nginx image that serves your HTML/JS/CSS game files.
|
|
|
|
|