Researching how to best apply stress to Kubenetes pods/nodes using stress-ng
Yes, I’m aware there are existing projects that were created to apply stress to Kubernetes clusters, but I’m working on some internal Microsoft projects that are needed for custom infrastructure. As such, the research presented by this repository will be largely based around raw
stress-ng
with no non-Kubernetes wrappers.
The way I’m looking at it currently, there’s three options for applying stress using a wrapper around stress-ng
:
stress-ng
that tries to vampire suck all the resources of the nodestress-ng
inside the application pods and apply stress directlystress-ng
on the actual VM (potentially via a daemonset) and stress the whole boxstress-ng
load test at 80% CPU for a minute:
docker run -it --rm alexeiled/stress-ng:latest-ubuntu --cpu 0 --cpu-load 80 --timeout 60s --metrics-brief
Saw host CPU usage hold at 80% across all cores as expected.
stress-ng
:
kubectl apply -f pod.yaml
stress-ng
pod to load test at 80% CPU for a minute:
kubectl exec -it <stress-ng-pod> -- stress-ng --cpu 0 --cpu-load 80 --timeout 60s
Saw host CPU usage hold at 80% across all cores as expected.
stress-ng
:
kubectl apply -f pod.yaml
kubectl apply -f pod2.yaml
stress-ng
pods to load test at 80% CPU for a minute:
kubectl exec -it <stress-ng-pod1> -- stress-ng --cpu 0 --cpu-load 80 --timeout 60s
kubectl exec -it <stress-ng-pod2> -- stress-ng --cpu 0 --cpu-load 80 --timeout 60s
Saw host CPU usage hold at 100% across all cores. The competing pods were not able to take CPU above 100% usage.
kubectl create namespace limitrange-cpu-50-percent
kubectl apply -f limitrange-cpu-50-percent.yaml --namespace=constraints-cpu-example