Skip to content

Commit

Permalink
chore: [CHAOS-7808]: Add pod api modify response custom fault (#9643)
Browse files Browse the repository at this point in the history
* chore: [CHAOS-7808]: Add pod api modify response custom fault

Signed-off-by: Shubham Chaudhary <[email protected]>

* chore: [CHAOS-7808]: update the hyperlink

Signed-off-by: Shubham Chaudhary <[email protected]>

* review

Add image and review docs

---------

Signed-off-by: Shubham Chaudhary <[email protected]>
Co-authored-by: SmritiSatya <[email protected]>
  • Loading branch information
ispeakc0de and SmritiSatya authored Mar 10, 2025
1 parent ee3a198 commit 1b40688
Show file tree
Hide file tree
Showing 12 changed files with 849 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ export const experiments: ExperimentDetails[] = [
tags: ["pod"],
category: "kubernetes",
},
{
name: "Pod API modify response custom",
description:"Pod API modify response custom modifies the headers, body, and status code of both request and response for the APIs of the service through path filtering",
tags: ["pod"],
category: "kubernetes",
},
{
name: "Pod autoscaler",
description:"Pod autoscaler determines whether nodes can accommodate multiple replicas of a given application pod.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,22 @@ This fault evaluates the application's resilience to lossy (or flaky) API reques

<FaultDetailsCard category="kubernetes" subCategory="pod">

### Pod API modify response custom

Pod API modify response custom is a Kubernetes pod-level chaos fault that consolidates the **pod-api-modify-body**, **pod-api-modify-header**, and **pod-api-status-code** faults.

- It modifies the headers, body, and status code of both request and response for the APIs of the service specified by the `TARGET_SERVICE_PORT` environment variable.
- It assesses the application's resilience to modified or corrupted API requests and responses.

<Accordion color="green">
<summary>Use cases</summary>
This fault assesses the application's resilience to modified or corrupted API requests and responses.
</Accordion>

</FaultDetailsCard>

<FaultDetailsCard category="kubernetes" subCategory="pod">

### Pod API Status Code

Pod API status code is a Kubernetes pod-level chaos fault that change the API response status code and optionally api response body through path filtering.
Expand Down

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# it injects the api modify header fault
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: engine-nginx
spec:
engineState: "active"
annotationCheck: "false"
appinfo:
appns: "default"
applabel: "app=nginx"
appkind: "deployment"
chaosServiceAccount: litmus-admin
experiments:
- name: pod-api-modify-response-custom
spec:
components:
env:
# provide the proxy port
- name: PROXY_PORT
value: '20000'
# provide the connection type
- name: SERVICE_DIRECTION
value: 'ingress'
# provide the payload type
- name: DATA_DIRECTION
value: 'both'
# provide the network interface
- name: NETWORK_INTERFACE
value: 'eth0'
# provide the api path filter
- name: PATH_FILTER
value: '/status'
# provide the port of the targeted service
- name: TARGET_SERVICE_PORT
value: "80"
- name: HEADERS_MAP
value: '{"X-Litmus-Test-Header": "X-Litmus-Test-Value"}'
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# it injects the api modify header fault
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: engine-nginx
spec:
engineState: "active"
annotationCheck: "false"
appinfo:
appns: "default"
applabel: "app=nginx"
appkind: "deployment"
chaosServiceAccount: litmus-admin
experiments:
- name: pod-api-modify-response-custom
spec:
components:
env:
# provide the headers filters
- name: HEADERS_FILTERS
value: 'key1:value1,key2:value2'
# provide the methods filters
- name: METHODS
value: 'GET,POST'
# provide the query params filters
- name: QUERY_PARAMS
value: 'param1:value1,param2:value2'
# provide the source hosts filters
- name: SOURCE_HOSTS
value: 'host1,host2'
# provide the source ips filters
- name: SOURCE_IPS
value: 'ip1,ip2'
# provide the connection type
- name: SERVICE_DIRECTION
value: 'ingress'
# provide the port of the targeted service
- name: TARGET_SERVICE_PORT
value: "80"
- name: HEADERS_MAP
value: '{"X-Litmus-Test-Header": "X-Litmus-Test-Value"}'
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
## provide the container runtime and socket file path
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: engine-nginx
spec:
engineState: "active"
annotationCheck: "false"
appinfo:
appns: "default"
applabel: "app=nginx"
appkind: "deployment"
chaosServiceAccount: litmus-admin
experiments:
- name: pod-api-modify-response-custom
spec:
components:
env:
# runtime for the container
# supports docker, containerd, crio
- name: CONTAINER_RUNTIME
value: "containerd"
# path of the socket file
- name: SOCKET_PATH
value: "/run/containerd/containerd.sock"
# provide the port of the targeted service
- name: TARGET_SERVICE_PORT
value: "80"
# provide the api path filter
- name: PATH_FILTER
value: '/status'
- name: HEADERS_MAP
value: '{"X-Litmus-Test-Header": "X-Litmus-Test-Value"}'
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
## provide destination ports
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: engine-nginx
spec:
engineState: "active"
annotationCheck: "false"
appinfo:
appns: "default"
applabel: "app=nginx"
appkind: "deployment"
chaosServiceAccount: litmus-admin
experiments:
- name: pod-api-modify-response-custom
spec:
components:
env:
# provide destination ports
- name: DESTINATION_PORTS
value: '80,443'
# provide the api path filter
- name: PATH_FILTER
value: '/status'
- name: HEADERS_MAP
value: '{"X-Litmus-Test-Header": "X-Litmus-Test-Value"}'
# provide the port of the targeted service
- name: TARGET_SERVICE_PORT
value: "80"
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
## enable https support
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: engine-nginx
spec:
engineState: "active"
annotationCheck: "false"
appinfo:
appns: "default"
applabel: "app=nginx"
appkind: "deployment"
chaosServiceAccount: litmus-admin
experiments:
- name: pod-api-modify-response-custom
spec:
components:
env:
# enable https support
- name: HTTPS_ENABLED
value: 'true'
- name: SERVER_CERTIFICATES
value: 'Y3VzdG9tIGNlcnRpZmljYXRlcwo='
# provide the api path filter
- name: PATH_FILTER
value: '/status'
- name: HEADERS_MAP
value: '{"X-Litmus-Test-Header": "X-Litmus-Test-Value"}'
# provide the port of the targeted service
- name: TARGET_SERVICE_PORT
value: "80"
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
## provide the headers as a map
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: engine-nginx
spec:
engineState: "active"
annotationCheck: "false"
appinfo:
appns: "default"
applabel: "app=nginx"
appkind: "deployment"
chaosServiceAccount: litmus-admin
experiments:
- name: pod-api-modify-header
spec:
components:
env:
# map of headers to modify/add; Eg: {"X-Litmus-Test-Header": "X-Litmus-Test-Value"}
# to remove a header, just set the value to ""; Eg: {"X-Litmus-Test-Header": ""}
- name: HEADERS_MAP
value: '{"X-Litmus-Test-Header": "X-Litmus-Test-Value"}'
# provide the http status code
- name: STATUS_CODE
value: "500"
# provide the response body
- name: RESPONSE_BODY
value: "/.+/internal_server_error"
# provide the port of the targeted service
- name: TARGET_SERVICE_PORT
value: "80"
- name: PATH_FILTER
value: '/status'
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## provide api path filter
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: engine-nginx
spec:
engineState: "active"
annotationCheck: "false"
appinfo:
appns: "default"
applabel: "app=nginx"
appkind: "deployment"
chaosServiceAccount: litmus-admin
experiments:
- name: pod-api-modify-response-custom
spec:
components:
env:
# provide the api path filter
- name: PATH_FILTER
value: '/status'
- name: HEADERS_MAP
value: '{"X-Litmus-Test-Header": "X-Litmus-Test-Value"}'
# provide the port of the targeted service
- name: TARGET_SERVICE_PORT
value: "80"
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## provide the port of the targeted service
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: engine-nginx
spec:
engineState: "active"
annotationCheck: "false"
appinfo:
appns: "default"
applabel: "app=nginx"
appkind: "deployment"
chaosServiceAccount: litmus-admin
experiments:
- name: pod-api-modify-response-custom
spec:
components:
env:
# provide the port of the targeted service
- name: TARGET_SERVICE_PORT
value: "80"
- name: HEADERS_MAP
value: '{"X-Litmus-Test-Header": "X-Litmus-Test-Value"}'
- name: PATH_FILTER
value: '/status'

0 comments on commit 1b40688

Please sign in to comment.