actionCPU

stress_cpu

Stress the CPU of a Pod's container

Activity as code

Below are the details and signature of the activity Python module.

Typeaction
Modulechaosk8s.chaosmesh.stress.actions
Namestress_cpu
Returnmapping

Usage

JSON

{
  "name": "stress-cpu",
  "type": "action",
  "provider": {
    "type": "python",
    "module": "chaosk8s.chaosmesh.stress.actions",
    "func": "stress_cpu",
    "arguments": {
      "name": "",
      "workers": 0,
      "load": 0
    }
  }
}

YAML

name: stress-cpu
provider:
  arguments:
    load: 0
    name: ''
    workers: 0
  func: stress_cpu
  module: chaosk8s.chaosmesh.stress.actions
  type: python
type: action

Arguments

NameTypeDefaultRequiredTitleDescription
namestringYesNameA unique name to identify this particular fault
container_namesstringNoContainer NamesComma-seperated list of container names to target
workersintegerYesWorkersNumber of worker threads that stress the CPU
loadintegerNoLoadBusiness of CPU between O and 100
durationstring30sNoDurationDuration of the stress, such as 30s
nsstringdefaultNoNamespaceNamespace where to apply the fault
namespaces_selectorsstringNoNamespaces SelectorsComma-separated list of namespaces to scope the fault to
label_selectorsstringNoLabel SelectorsComma-separated list of key=value pairs to scope the fault to
annotations_selectorsstringNoAnnotation SelectorsComma-separated list of key=value pairs to scope the fault to
modestringoneNoModeMode of fault injection: one, all, fixed, fixed-percent, random-max-percent
mode_valuestringNoMode ValueValue depending on the mode above
stressng_stressorsstringNoAdditional ParametersAdditional Stress-ng command line parameters

This action relies on Chaos Mesh to perform the fault. Make sure to install it before hand.

Signature

def stress_cpu(name: str,
               workers: int,
               load: int,
               ns: str = 'default',
               namespaces_selectors: Optional[str] = None,
               label_selectors: Optional[str] = None,
               annotations_selectors: Optional[str] = None,
               mode: str = 'one',
               mode_value: Optional[str] = None,
               direction: str = 'to',
               duration: str = '30s',
               container_names: Union[str, List[str], NoneType] = None,
               stressng_stressors: Optional[str] = None,
               secrets: Dict[str, Dict[str, str]] = None) -> Dict[str, Any]:
    pass