Skip to main content

Kubernetes probe

With the proliferation of custom resources & operators, especially in the case of stateful applications, the steady-state is manifested as status parameters/flags within Kubernetes resources. K8s Probe addresses verification of the desired resource state by allowing users to define the Kubernetes GVR (group-version-resource) with appropriate filters (field selectors/label selectors). The experiment makes use of the Kubernetes Dynamic Client to achieve this. The probe supports following CRUD operations:

  • create: It creates kubernetes resource based on the data provided inside probe.data field.
  • delete: It deletes matching kubernetes resource via GVR and filters (field selectors/label selectors).
  • present: It checks for the presence of kubernetes resource based on GVR and filters (field selectors/label selectors).
  • absent: It checks for the absence of kubernetes resource based on GVR and filters (field selectors/label selectors).

Defining the probe

You can define the probes at .spec.experiments[].spec.probe path inside the chaos engine.

kind: Workflow
apiVersion: argoproj.io/v1alpha1
spec:
templates:
- inputs:
artifacts:
- raw:
data: |
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
spec:
experiments:
- spec:
probe:
####################################
Probes are defined here
####################################

Schema

Listed below is the probe schema for the Kubernetes probe, with properties shared across all the probes and properties unique to the Kubernetes probe.

FieldDescriptionTypeRangeNotes
groupFlag to hold the group of the kubernetes resource for the k8sProbeMandatoryN/A type: stringThe group contains group of the kubernetes resource on which k8sProbe performs the specified operation.
versionFlag to hold the apiVersion of the kubernetes resource for the k8sProbeMandatoryN/A type: stringThe version contains apiVersion of the kubernetes resource on which k8sProbe performs the specified operation
resourceFlag to hold the kubernetes resource name for the k8sProbeMandatoryN/A type: stringThe resource contains the kubernetes resource name on which k8sProbe performs the specified operation.
namespaceFlag to hold the namespace of the kubernetes resource for the k8sProbeMandatoryN/A type: stringThe namespace contains namespace of the kubernetes resource on which k8sProbe performs the specified operation.
fieldSelectorFlag to hold the fieldSelectors of the kubernetes resource for the k8sProbeOptionalN/A type: stringThe fieldSelector contains fieldSelector to derived the kubernetes resource on which k8sProbe performs the specified operation.
labelSelectorFlag to hold the labelSelectors of the kubernetes resource for the k8sProbeOptionalN/A type: stringThe labelSelector contains labelSelector to derived the kubernetes resource on which k8sProbe performs the specified operation.
operationFlag to hold the operation type for the k8sProbeMandatoryN/A type: stringThe operation contains operation which should be applied on the kubernetes resource as part of k8sProbe. It supports four type of operation. It can be one of create, delete, present, absent.

Run properties

FieldDescriptionTypeRangeNotes
probeTimeoutFlag to hold the timeout of the probeMandatoryN/A type: integerThe probeTimeout represents the time limit for the probe to execute the specified check and return the expected data
retryFlag to hold the retry count of the probeMandatoryN/A type: integerThe retry contains the number of times a check is re-run upon failure in the first attempt before declaring the probe status as failed.
intervalFlag to hold the interval of the probeMandatoryN/A type: integerThe interval contains the interval for which probes waits between subsequent retries
probePollingIntervalFlag to hold the polling interval for the probes (applicable for all modes)OptionalN/A type: integerThe probePollingInterval contains the time interval for which continuous probe should be sleep after each iteration
initialDelaySecondsFlag to hold the initial delay interval for the probesOptionalN/A type: integerThe initialDelaySeconds represents the initial waiting time interval for the probes.
stopOnFailureFlags to hold the stop or continue the experiment on probe failureOptionalN/A type: booleanThe stopOnFailure can be set to true/false to stop or continue the experiment execution after probe fails

Definition

probe:
- name: "check-app-cluster-cr-status"
type: "k8sProbe"
k8sProbe/inputs:
group: "<appGroup>"
version: "<appVersion>"
resource: "<appResource>"
namespace: "default"
fieldSelector: "metadata.name=<appResourceName>,status.phase=Running"
labelSelector: "<app-labels>"
operation: "present" # it can be present, absent, create, delete
mode: "EOT"
runProperties:
probeTimeout: 5
interval: 5
retry: 1