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. k8sProbe 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. It supports CRUD operations which can be defined at probe.k8sProbe/inputs.operation.
It can be executed by setting type as k8sProbe inside .spec.experiments[].spec.probe.
View the k8s 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
.k8sProbe/inputs.group
Description
Flag to hold the group of the kubernetes resource for the k8sProbe
Type
Mandatory
Range
n/a {type: string}
Notes
The .k8sProbe/inputs.group contains group of the kubernetes resource on which k8sProbe performs the specified operation
Field
.k8sProbe/inputs.version
Description
Flag to hold the apiVersion of the kubernetes resource for the k8sProbe
Type
Mandatory
Range
n/a {type: string}
Notes
The .k8sProbe/inputs.version contains apiVersion of the kubernetes resource on which k8sProbe performs the specified operation
Field
.k8sProbe/inputs.resource
Description
Flag to hold the kubernetes resource name for the k8sProbe
Type
Mandatory
Range
n/a {type: string}
Notes
The .k8sProbe/inputs.resource contains the kubernetes resource name on which k8sProbe performs the specified operation
Field
.k8sProbe/inputs.namespace
Description
Flag to hold the namespace of the kubernetes resource for the k8sProbe
Type
Mandatory
Range
n/a {type: string}
Notes
The .k8sProbe/inputs.namespace contains namespace of the kubernetes resource on which k8sProbe performs the specified operation
Field
.k8sProbe/inputs.fieldSelector
Description
Flag to hold the fieldSelectors of the kubernetes resource for the k8sProbe
Type
Optional
Range
n/a {type: string}
Notes
The .k8sProbe/inputs.fieldSelector contains fieldSelector to derived the kubernetes resource on which k8sProbe performs the specified operation
Field
.k8sProbe/inputs.labelSelector
Description
Flag to hold the labelSelectors of the kubernetes resource for the k8sProbe
Type
Optional
Range
n/a {type: string}
Notes
The .k8sProbe/inputs.labelSelector contains labelSelector to derived the kubernetes resource on which k8sProbe performs the specified operation
Field
.k8sProbe/inputs.operation
Description
Flag to hold the operation type for the k8sProbe
Type
Mandatory
Range
create, delete, present, absent
Notes
The .k8sProbe/inputs.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.
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
It creates kubernetes resource based on the data provided inside probe.data field. It can be defined by setting operation to create operation.
Use the following example to tune this:
# create the given resource provided inside data fieldapiVersion: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:"create-percona-pvc"type:"k8sProbe"k8sProbe/inputs:# group of the resourcegroup:""# version of the resourceversion:"v1"# name of the resourceresource:"persistentvolumeclaims"# namespace where the instance of resource should be creatednamespace:"default"# type of operation# supports: create, delete, present, absentoperation:"create"mode:"SOT"runProperties:probeTimeout:5interval:2retry:1# contains manifest, which can be used to create the resourcedata:|kind: PersistentVolumeClaimapiVersion: v1metadata:name: percona-mysql-claimlabels:openebs.io/target-affinity: perconaspec:storageClassName: standardaccessModes:- ReadWriteOnceresources:requests:storage: 100Mi
It deletes matching kubernetes resources via GVR and filters (field selectors/label selectors) provided at probe.k8sProbe/inputs. It can be defined by setting operation to delete operation.
Use the following example to tune this:
# delete the resource matched with the given inputsapiVersion: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:"delete-percona-pvc"type:"k8sProbe"k8sProbe/inputs:# group of the resourcegroup:""# version of the resourceversion:"v1"# name of the resourceresource:"persistentvolumeclaims"# namespace of the instance, which needs to be deletednamespace:"default"# labels selectors for the k8s resource, which needs to be deletedlabelSelector:"openebs.io/target-affinity=percona"# fieldselector for the k8s resource, which needs to be deletedfieldSelector:""# type of operation# supports: create, delete, present, absentoperation:"delete"mode:"EOT"runProperties:probeTimeout:5interval:2retry:1
It checks for the presence of kubernetes resource based on GVR and filters (field selectors/labelselectors) provided at probe.k8sProbe/inputs. It can be defined by setting operation to present operation.
Use the following example to tune this:
# verify the existance of the resource matched with the given inputs inside clusterapiVersion: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-percona-pvc-presence"type:"k8sProbe"k8sProbe/inputs:# group of the resourcegroup:""# version of the resourceversion:"v1"# name of the resourceresource:"persistentvolumeclaims"# namespace where the instance of resourcenamespace:"default"# labels selectors for the k8s resourcelabelSelector:"openebs.io/target-affinity=percona"# fieldselector for the k8s resourcefieldSelector:""# type of operation# supports: create, delete, present, absentoperation:"present"mode:"SOT"runProperties:probeTimeout:5interval:2retry:1
It checks for the absence of kubernetes resource based on GVR and filters (field selectors/labelselectors) provided at probe.k8sProbe/inputs. It can be defined by setting operation to absent operation.
Use the following example to tune this:
# verify that the no resource should be present in cluster with the given inputsapiVersion: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-percona-pvc-absence"type:"k8sProbe"k8sProbe/inputs:# group of the resourcegroup:""# version of the resourceversion:"v1"# name of the resourceresource:"persistentvolumeclaims"# namespace where the instance of resourcenamespace:"default"# labels selectors for the k8s resourcelabelSelector:"openebs.io/target-affinity=percona"# fieldselector for the k8s resourcefieldSelector:""# type of operation# supports: create, delete, present, absentoperation:"absent"mode:"EOT"runProperties:probeTimeout:5interval:2retry:1