Pod Application Function Latency
The Pod Application Function Latency fault introduces artificial delay into a specified function of an application running within a Kubernetes pod. This helps evaluate the application's resilience to function-level latency and performance degradation.

Use cases
- Simulate slow function execution to test application behavior under degraded performance.
- Validate timeout, retry, and circuit breaker mechanisms when core functions are delayed.
- Induce latency that can lead to application-level failures, helping identify resilience gaps and failure thresholds.
Prerequisites
- Kubernetes >= 1.12.0
- The target application pod must be running and accessible.
- The function to inject latency into must be identifiable by name.
- The litmus-admin service account must be available in the target namespace.
Permissions required
Below is a sample Kubernetes role that defines the permissions required to execute the fault.
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  namespace: hce
  name: pod-application-function-latency
spec:
  definition:
    scope: Cluster # Supports "Namespaced" mode too
permissions:
  - apiGroups: [""]
    resources: ["pods"]
    verbs: ["create", "delete", "get", "list", "patch", "deletecollection", "update"]
  - apiGroups: [""]
    resources: ["events"]
    verbs: ["create", "get", "list", "patch", "update"]
  - apiGroups: [""]
    resources: ["pods/log"]
    verbs: ["get", "list", "watch"]
  - apiGroups: [""]
    resources: ["deployments, statefulsets"]
    verbs: ["get", "list"]
  - apiGroups: [""]
    resources: ["replicasets, daemonsets"]
    verbs: ["get", "list"]
  - apiGroups: [""]
    resources: ["chaosEngines", "chaosExperiments", "chaosResults"]
    verbs: ["create", "delete", "get", "list", "patch", "update"]
  - apiGroups: ["batch"]
    resources: ["jobs"]
    verbs: ["create", "delete", "get", "list", "deletecollection"]
Mandatory tunables
| Tunable | Description | Notes | 
|---|---|---|
| NAME | Name of the target application where the function is defined. | For example: my-app.  For more information, go to name. | 
| FUNCTION | Name of the specific function in the application where the error will be injected. | For example: myFunction.  For more information, go to function. | 
Optional tunables
| Tunable | Description | Notes | 
|---|---|---|
| TOTAL_CHAOS_DURATION | Total duration (in seconds) for which the error will be injected into the function. | Default: 60 s. For more information, go to duration of the chaos. | 
| LATENCY | Provide the exact latency that you want to cause in your application. | For example: Injected error for testing. For more information, go to message. | 
Name
The NAME env specifies the name of the target application that is under chaos.
---
# Injects error in a given function of the application pod
apiVersion: litmuschaos.io/v1alpha1
kind: K8sFault
metadata:
  name: pod-application-function-latency
spec:
  definition:
    targets:
      application:
        name: 'my-app'
        function: 'myFunction'
    chaos:
      experiment: pod-application-function-latency
      serviceAccountName: litmus-admin
      image: docker.io/harness/chaos-ddcr-faults:main-latest
      imagePullPolicy: Always
      env:
        - name: MESSAGE
          value: 'Injected error for testing'
Function
The FUNCTION env specifies the specific function in the application where the error will be injected.
---
# Injects error in a given function of the application pod
apiVersion: litmuschaos.io/v1alpha1
kind: K8sFault
metadata:
  name: pod-application-function-latency
spec:
  definition:
    targets:
      application:
        name: 'my-app'
        function: 'myFunction'
    chaos:
      experiment: pod-application-function-latency
      serviceAccountName: litmus-admin
      image: docker.io/harness/chaos-ddcr-faults:main-latest
      imagePullPolicy: Always
      env:
        - name: MESSAGE
          value: 'Injected error for testing'
Latency
The LATENCY environment variable specifies the exact latency that you want to cause in your application.
---
# Injects error in a given function of the application pod
apiVersion: litmuschaos.io/v1alpha1
kind: K8sFault
metadata:
  name: pod-application-function-latency
spec:
  definition:
    targets:
      application:
        name: 'my-app'
        function: 'myFunction'
    chaos:
      experiment: pod-application-function-latency
      serviceAccountName: litmus-admin
      image: docker.io/harness/chaos-ddcr-faults:main-latest
      imagePullPolicy: Always
      env:
        - name: LATENCY
          value: '2000'