1- docker build -t stressed-pod . && docker run -p 5000:5000 stressed-pod
1+ # Stressed Pod
2+
3+ ## Overview
4+ Stressed Pod is a tool designed to simulate various types of loads on a Kubernetes pod. It enables testing application resilience by generating CPU, memory loads, and producing custom logs. This tool is particularly useful for performance testing, resource sizing, and scaling policy validation.
5+
6+ ## Features
7+ - **CPU Load Management**: Precise control of CPU usage (0 to N cores)
8+ - **Memory Load Management**: Memory consumption simulation (in MB)
9+ - **Dynamic Load**: Progressive variation of CPU/memory load
10+ - **Log Generation**: Custom log production with different levels and formats
11+ - **Kubernetes Probes**: Control of readiness/liveness probes
12+ - **REST API**: HTTP interface for load control
13+ - **Environment Variable Configuration**: Flexible behavior parameterization
14+
15+ ## Installation
16+
17+ ### Requirements
18+ - Python 3.13+
19+ - Poetry for dependency management
20+
21+ ### Configuration
22+
23+ #### Environment Variables
24+ ```yaml
25+ # CPU Load
26+ ENABLE_DYNAMIC_CPU_LOAD: "false"
27+ INITIAL_CPU_LOAD: "0"
28+ FINAL_CPU_LOAD: "0.5"
29+ CPU_LOAD_DURATION: "60"
30+ STOP_CPU_LOAD_AT_END: "true"
31+
32+ # Memory Load
33+ ENABLE_DYNAMIC_MEMORY_LOAD: "false"
34+ INITIAL_MEMORY_LOAD: "0"
35+ FINAL_MEMORY_LOAD: "256"
36+ MEMORY_LOAD_DURATION: "60"
37+ STOP_MEMORY_LOAD_AT_END: "true"
38+
39+ # Log Configuration
40+ ENABLE_AUTOMATIC_LOGS: "false"
41+ LOG_MESSAGE: "Automatic log message"
42+ LOG_LEVEL: "info"
43+ LOG_SERVICE: "auto-logger"
44+ LOG_FORMAT: "json"
45+ LOG_INTERVAL: "5"
46+ LOG_DURATION: "60"
47+
48+ # Initial Probe States
49+ READINESS_STATUS: "SUCCESS"
50+ LIVENESS_STATUS: "SUCCESS"
51+
52+ # System Configuration
53+ ENABLE_AUTO_TERMINATION: "false"
54+ AUTO_TERMINATION_DELAY: "300"
55+ ```
56+
57+ ## API Endpoints
58+
59+ ### Load Management
60+ - `GET /load`: Current load status
61+ - `POST /load/cpu/start`: Start CPU load
62+ - `POST /load/cpu/stop`: Stop CPU load
63+ - `POST /load/cpu/dynamic`: Configure dynamic CPU load
64+ - `POST /load/memory/start`: Start memory load
65+ - `POST /load/memory/stop`: Stop memory load
66+ - `POST /load/memory/dynamic`: Configure dynamic memory load
67+
68+ ### Log Management
69+ - `POST /log`: Create custom logs
70+
71+ ### Probe Management
72+ - `GET /probes`: Probe status
73+ - `GET /probes/readiness`: Readiness probe status
74+ - `GET /probes/liveness`: Liveness probe status
75+ - `POST /probes/status`: Modify probe status
76+
77+ ### System Management
78+ - `GET /system`: System information
79+ - `POST /system/terminate`: Schedule pod termination
80+
81+ ## Usage Examples
82+
83+ ### Dynamic CPU Load
84+ ```bash
85+ curl -X POST http://localhost:8000/load/cpu/dynamic \
86+ -H "Content-Type: application/json" \
87+ -d '{
88+ "start_value": 0.1,
89+ "end_value": 0.8,
90+ "duration": 60,
91+ "stop_at_end": true
92+ }'
93+ ```
94+
95+ ### Memory Load
96+ ```bash
97+ curl -X POST http://localhost:8000/load/memory/start \
98+ -H "Content-Type: application/json" \
99+ -d '{
100+ "value": 256
101+ }'
102+ ```
103+
104+ ### Log Generation
105+ ```bash
106+ curl -X POST http://localhost:8000/log \
107+ -H "Content-Type: application/json" \
108+ -d '{
109+ "message": "Test message",
110+ "level": "info",
111+ "service": "test-service",
112+ "format": "json",
113+ "interval": 5,
114+ "duration": 60
115+ }'
116+ ```
117+
118+ ### Probe Control
119+ ```bash
120+ curl -X POST http://localhost:8000/probes/status \
121+ -H "Content-Type: application/json" \
122+ -d '{
123+ "probe": "readiness",
124+ "status": "error"
125+ }'
126+ ```
127+
128+ ## Development
129+
130+ ### Launch app
131+ docker-compose up --build
132+
133+ ### Running Tests
134+ ```bash
135+ # Install dependencies
136+ poetry install
137+
138+ # Run tests
139+ poetry run pytest
140+
141+ # Run tests with coverage
142+ poetry run pytest --cov=app
143+ ```
144+
145+ ### Code Quality
146+ The project uses:
147+ - pytest for testing
148+ - black for code formatting
149+ - flake8 for linting
150+ - mypy for type checking
151+
152+ ## Contributing
153+ Contributions are welcome! Please feel free to submit a Pull Request.
154+
155+ ## License
156+ This project is licensed under the MIT License.
157+
158+ ## Important Notes
159+ - The CPU load is distributed across all available cores
160+ - Memory load is specified in MB
161+ - Log formats supported: JSON and plaintext
162+ - Probe status changes are immediate
163+ - All durations are in seconds
164+
165+ This tool is designed for testing purposes and should be used with caution in production environments.
0 commit comments