The command probe allows developers to run shell commands and match the resulting output as part of the entry/exit criteria. The intent behind this probe was to allow users to implement a non-standard & imperative way of expressing their hypothesis. For example, the cmdProbe enables you to check for specific data within a database, parse the value out of a JSON blob being dumped into a certain path, or check for the existence of a particular string in the service logs.
It can be executed by setting type as cmdProbe inside .spec.experiments[].spec.probe.
View the command probe schema
Field
.name
Description
Flag to hold the name of the probe
Type
Mandatory
Range
n/a (type: string)
Notes
The .name holds the name of the probe. It can be set based on the usecase
Field
.type
Description
Flag to hold the type of the probe
Type
Mandatory
Range
httpProbe, k8sProbe, cmdProbe, promProbe
Notes
The .type supports four type of probes. It can one of the httpProbe, k8sProbe, cmdProbe, promProbe
Field
.mode
Description
Flag to hold the mode of the probe
Type
Mandatory
Range
SOT, EOT, Edge, Continuous, OnChaos
Notes
The .mode supports five modes of probes. It can one of the SOT, EOT, Edge, Continuous, OnChaos
Field
.cmdProbe/inputs.command
Description
Flag to hold the command for the cmdProbe
Type
Mandatory
Range
n/a {type: string}
Notes
The .cmdProbe/inputs.command contains the shell command, which should be run as part of cmdProbe
Field
.cmdProbe/inputs.source
Description
Flag to hold the source for the cmdProbe
Type
Mandatory
Range
It contains the source attributes i.e, image, imagePullPolicy
Notes
The .cmdProbe/inputs.source It supports inline mode where command should be run within the experiment pod, and it can be tuned by omiting source field. Otherwise provide the source details(i.e, image) which can be used to launch a external pod where the command execution is carried out.
Field
.cmdProbe/inputs.comparator.type
Description
Flag to hold type of the data used for comparision
Type
Mandatory
Range
string, int, float
Notes
The .cmdProbe/inputs.comparator.type contains type of data, which should be compare as part of comparision operation
Field
.cmdProbe/inputs.comparator.criteria
Description
Flag to hold criteria for the comparision
Type
Mandatory
Range
it supports {>=, <=, ==, >, <, !=, oneOf, between} for int & float type. And {equal, notEqual, contains, matches, notMatches, oneOf} for string type.
Notes
The .cmdProbe/inputs.comparator.criteria contains criteria of the comparision, which should be fulfill as part of comparision operation.
Field
.cmdProbe/inputs.comparator.value
Description
Flag to hold value for the comparision
Type
Mandatory
Range
n/a {type: string}
Notes
The .cmdProbe/inputs.comparator.value contains value of the comparision, which should follow the given criteria as part of comparision operation.
Field
.runProperties.probeTimeout
Description
Flag to hold the timeout for the probes
Type
Mandatory
Range
n/a {type: integer}
Notes
The .runProperties.probeTimeout represents the time limit for the probe to execute the specified check and return the expected data
Field
.runProperties.retry
Description
Flag to hold the retry count for the probes
Type
Mandatory
Range
n/a {type: integer}
Notes
The .runProperties.retry contains the number of times a check is re-run upon failure in the first attempt before declaring the probe status as failed.
Field
.runProperties.interval
Description
Flag to hold the interval for the probes
Type
Mandatory
Range
n/a {type: integer}
Notes
The .runProperties.interval contains the interval for which probes waits between subsequent retries
Field
.runProperties.probePollingInterval
Description
Flag to hold the polling interval for the probes(applicable for Continuous mode only)
Type
Optional
Range
n/a {type: integer}
Notes
The .runProperties.probePollingInterval contains the time interval for which continuous probe should be sleep after each iteration
Field
.runProperties.initialDelaySeconds
Description
Flag to hold the initial delay interval for the probes
Type
Optional
Range
n/a {type: integer}
Notes
The .runProperties.initialDelaySeconds represents the initial waiting time interval for the probes.
Field
.runProperties.stopOnFailure
Description
Flags to hold the stop or continue the experiment on probe failure
Type
Optional
Range
false {type: boolean}
Notes
The .runProperties.stopOnFailure can be set to true/false to stop or continue the experiment execution after probe fails
In inline mode, the command probe is executed from within the experiment pod. It is preferred for simple shell commands.
It is default mode, and it can be tuned by omitting source field.
Use the following example to tune this:
# execute the command inside the experiment pod itself# cases where command doesn't need any extra binaries which is not available in litmsuchaos/go-runner imageapiVersion:litmuschaos.io/v1alpha1kind:ChaosEnginemetadata:name:engine-nginxspec:engineState:"active"appinfo:appns:"default"applabel:"app=nginx"appkind:"deployment"chaosServiceAccount:pod-delete-saexperiments:-name:pod-deletespec:probe:-name:"check-database-integrity"type:"cmdProbe"cmdProbe/inputs:# command which needs to run in cmdProbecommand:"<command>"comparator:# output type for the above command# supports: string, int, floattype:"string"# criteria which should be followed by the actual output and the expected output#supports [>=, <=, >, <, ==, !=] for int and float# supports [contains, equal, notEqual, matches, notMatches] for string valuescriteria:"contains"# expected value, which should follow the specified criteriavalue:"<value-for-criteria-match>"mode:"Edge"runProperties:probeTimeout:5interval:5retry:1initialDelaySeconds:5
In source mode, the command execution is carried out from within a new pod whose image can be specified. It can be used when application-specific binaries are required.
View the source probe schema
Field
.image
Description
Flag to hold the image of the source pod
Type
Mandatory
Range
n/a (type: string)
Notes
The .image holds the image of the source pod/td>
Field
.hostNetwork
Description
Flag to enable the hostNetwork for the source pod
Type
Optional
Range
(type: boolean)
Notes
The .hostNetwork flag to enable the hostnetwork. It supports boolean values and default value is false/td>
Field
.args
Description
Flag to hold the args for the source pod
Type
Optional
Range
(type: []string])
Notes
The .args flag to hold the args for source pod/td>
Field
.env
Description
Flag to hold the envs for the source pod
Type
Optional
Range
(type: []corev1.EnvVar])
Notes
The .env flag to hold the envs for source pod/td>
Field
.labels
Description
Flag to hold the labels for the source pod
Type
Optional
Range
(type: map[string]string)
Notes
The .labels flag to hold the labels for source pod/td>
Field
.annotations
Description
Flag to hold the annotations for the source pod
Type
Optional
Range
(type: map[string]string)
Notes
The .annotations flag to hold the annotations for source pod/td>
Field
.command
Description
Flag to hold the command for the source pod
Type
Optional
Range
(type: []string
Notes
The .command flag to hold the command for source pod/td>
Field
.imagePullPolicy
Description
Flag to set the imagePullPolicy for the source pod
Type
Optional
Range
(type: corev1.PullPolicy
Notes
The .imagePullPolicy Flag to set the imagePullPolicy for the source pod/td>
Field
.privileged
Description
Flag to set the privileged for the source pod
Type
Optional
Range
(type: boolean
Notes
The .privileged Flag to set the privileged for the source pod. Default value is false/td>
Field
.nodeSelector
Description
Flag to hold the node selectors for the probe pod
Type
Optional
Range
(type: map[string]string
Notes
The .nodeSelector Flag to hold the node selectors for the probe pod/td>
Field
.volumes
Description
Flag to hold the volumes for the source pod
Type
Optional
Range
(type: []corev1.Volume
Notes
The .volumes Flag to hold the volumes for source pod/td>
Field
.volumeMount
Description
Flag to hold the volume mounts for the source pod
Type
Optional
Range
(type: []corev1.VolumeMount
Notes
The .volumes Flag to hold the volume Mounts for source pod/td>
Field
.imagePullSecrets
Description
Flag to set the imagePullSecrets for the source pod
Type
Optional
Range
(type: []corev1.LocalObjectReference
Notes
The .imagePullSecrets Flag to set the imagePullSecrets for the source pod/td>
Use the following example to tune this:
# it launches the external pod with the source image and run the command inside the same pod# cases where command needs an extra binaries which is not available in litmsuchaos/go-runner imageapiVersion:litmuschaos.io/v1alpha1kind:ChaosEnginemetadata:name:engine-nginxspec:engineState:"active"appinfo:appns:"default"applabel:"app=nginx"appkind:"deployment"chaosServiceAccount:pod-delete-saexperiments:-name:pod-deletespec:probe:-name:"check-database-integrity"type:"cmdProbe"cmdProbe/inputs:# command which needs to run in cmdProbecommand:"<command>"comparator:# output type for the above command# supports: string, int, floattype:"string"# criteria which should be followed by the actual output and the expected output#supports [>=, <=, >, <, ==, !=, oneOf, between] for int and float# supports [contains, equal, notEqual, matches, notMatches, oneOf] for string valuescriteria:"contains"# expected value, which should follow the specified criteriavalue:"<value-for-criteria-match>"# source for the cmdProbesource:image:"<source-image>"imagePullPolicy:Alwaysprivileged:truehostNetwork:falsemode:"Edge"runProperties:probeTimeout:5interval:5retry:1initialDelaySeconds:5