I am working on a new scheduler's stress test in Kubernetes. I need to open a lot of CPU and memory pods to analyze performance.
I am using image: polinux/stress in my pods. I would like to ask if there is any instruction, or when I write the yaml file, I can set this successfully generated pod to delete itself within the time set by me.
The following yaml file is the pod I am writing for stress testing. I would like to ask if I can write it from here to let him delete it after a period of time.
apiVersion: v1
kind: Pod
metadata:
  name: alltest12
  namespace: test
spec:
  containers:
  - name: alltest
    image: polinux/stress
    resources:
      requests:
        memory: "1000Mi"
        cpu: "1"
      limits:
        memory: "1000Mi"
        cpu: "1"
    command: ["stress"]
    args: ["--vm", "1", "--vm-bytes", "500M", "--vm-hang", "1"]If polinux/stress contains a shell, I believe you can have the thing kill itself:
- containers:
  image: polinux/stress
  command:
  - sh
  - -c
  - |
    sh -c "sleep 300; kill -9 1" &
    stress --vm 1 --vm-bytes 500M --vm-hang 1Or even slightly opposite:
  - |
    stress --vm etc etc &
    child_pid=$!
    sleep 300
    kill -9 $child_pidAnd you can parameterize that setup using env::
env:
- name: LIVE_SECONDS
  value: "300"
command:
- sh
- -c
- |
  sleep ${LIVE_SECONDS}
  kill -9 $child_pid