You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+52-2
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,7 @@ Build the Docker image using the provided Dockerfile:
34
34
35
35
```shell
36
36
docker build -t k8s-pod-cpu-stressor .
37
-
```
37
+
```
38
38
39
39
Run the Docker container, specifying the desired CPU usage, stress duration, and optionally whether to run CPU stress indefinitely:
40
40
@@ -56,6 +56,24 @@ The `k8s-pod-cpu-stressor` allows you to specify the desired CPU usage and stres
56
56
57
57
Adjust these parameters according to your requirements to simulate different CPU load scenarios.
58
58
59
+
### Kubernetes Resource Requests and Limits
60
+
61
+
It is recommended to specify Kubernetes resource requests and limits to control the amount of CPU resources consumed by the pod, and to prevent overloading your cluster. For example:
62
+
63
+
-**Requests**: This defines the minimum amount of CPU that the pod is guaranteed to have.
64
+
-**Limits**: This defines the maximum amount of CPU that the pod can use.
65
+
66
+
Adding requests and limits helps Kubernetes manage resources efficiently and ensures that your cluster remains stable during stress testing.
67
+
68
+
Example:
69
+
70
+
```yaml
71
+
resources:
72
+
requests:
73
+
cpu: "100m"
74
+
limits:
75
+
cpu: "200m"
76
+
```
59
77
60
78
## Check the Public Docker Image
61
79
@@ -98,10 +116,42 @@ spec:
98
116
cpu: "100m"
99
117
```
100
118
119
+
## Sample Job Manifest
120
+
121
+
If you want to run the CPU stressor for a fixed duration as a one-time job, you can use the following Kubernetes Job manifest:
122
+
123
+
```yaml
124
+
apiVersion: batch/v1
125
+
kind: Job
126
+
metadata:
127
+
name: cpu-stressor-job
128
+
spec:
129
+
template:
130
+
metadata:
131
+
labels:
132
+
app: cpu-stressor
133
+
spec:
134
+
containers:
135
+
- name: cpu-stressor
136
+
image: narmidm/k8s-pod-cpu-stressor:latest
137
+
args:
138
+
- "-cpu=0.5"
139
+
- "-duration=5m"
140
+
resources:
141
+
limits:
142
+
cpu: "500m"
143
+
requests:
144
+
cpu: "250m"
145
+
restartPolicy: Never
146
+
backoffLimit: 3
147
+
```
148
+
149
+
This manifest runs the `k8s-pod-cpu-stressor` as a Kubernetes Job, which will execute the stress test once for 5 minutes and then stop. The `backoffLimit` specifies the number of retries if the job fails.
150
+
101
151
## Contributing
102
152
103
153
Contributions are welcome! If you find a bug or have a suggestion, please open an issue or submit a pull request. For major changes, please discuss them first in the issue tracker.
104
154
105
155
## License
106
156
107
-
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
157
+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
0 commit comments