Skip to content

Instantly share code, notes, and snippets.

@adyanth
Created April 12, 2023 01:00
Show Gist options
  • Save adyanth/d589eecd0933fd65cb2da832a0265d39 to your computer and use it in GitHub Desktop.
Save adyanth/d589eecd0933fd65cb2da832a0265d39 to your computer and use it in GitHub Desktop.
Scheduled Stress all nodes in K8s
FROM alpine
RUN apk add stress-ng
ENTRYPOINT ["stress-ng"]
apiVersion: batch/v1
kind: CronJob
metadata:
name: stress
labels:
app: stress
spec:
concurrencyPolicy: Replace
successfulJobsHistoryLimit: 1
failedJobsHistoryLimit: 1
schedule: "* * * * *" # Run every minute
jobTemplate:
spec:
parallelism: 4 # Number of nodes
template:
metadata:
labels:
app: stress
spec:
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
topologyKey: kubernetes.io/hostname
labelSelector:
matchExpressions:
- key: app
operator: In
values:
- stress
weight: 100
containers:
- name: stress
image: adyanth/stress-ng
imagePullPolicy: IfNotPresent
args:
- --cpu
- "1" # 1 core stress
- --timeout
- 10s # 10 sec timeout
restartPolicy: Never
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment