From 04a3ebf8e5ccc9359c6f0ebd206f7790003ffa0a Mon Sep 17 00:00:00 2001 From: Shubham Chaudhary Date: Fri, 20 Dec 2024 15:33:47 +0530 Subject: [PATCH] chore: [CHAOS-7252]: Add transaction percentage support in dns Signed-off-by: Shubham Chaudhary --- .../kubernetes/pod/pod-dns-error.md | 39 +++++++++++++++++++ .../kubernetes/pod/pod-dns-spoof.md | 39 +++++++++++++++++++ .../pod-dns-error/transaction-percentage.yaml | 24 ++++++++++++ .../pod-dns-spoof/transaction-percentage.yaml | 24 ++++++++++++ 4 files changed, 126 insertions(+) create mode 100644 docs/chaos-engineering/use-harness-ce/chaos-faults/kubernetes/pod/static/manifests/pod-dns-error/transaction-percentage.yaml create mode 100644 docs/chaos-engineering/use-harness-ce/chaos-faults/kubernetes/pod/static/manifests/pod-dns-spoof/transaction-percentage.yaml diff --git a/docs/chaos-engineering/use-harness-ce/chaos-faults/kubernetes/pod/pod-dns-error.md b/docs/chaos-engineering/use-harness-ce/chaos-faults/kubernetes/pod/pod-dns-error.md index 23c545c096f..d98c10c8cda 100644 --- a/docs/chaos-engineering/use-harness-ce/chaos-faults/kubernetes/pod/pod-dns-error.md +++ b/docs/chaos-engineering/use-harness-ce/chaos-faults/kubernetes/pod/pod-dns-error.md @@ -99,6 +99,11 @@ permissions: Determines whether the DNS query exactly matches one of the targets or uses any of the targets as a substring. It can be exact or substring. If this is not provided, it is set to exact. For more information, go to match scheme + + TRANSACTION_PERCENTAGE + Percentage of the dns queries to be affected. + It supports values in range (0,100]. It targets all requests if not provided. For more information, go to transaction percentage . + PODS_AFFECTED_PERC Percentage of total pods to target. Provide numeric values. @@ -226,6 +231,40 @@ spec: value: '60' ``` +### Transaction Percentage + +The percentage of dns queries to be affected, with supported values in the range (0, 100]. If not specified, it targets all queries. Tune it by using the `TRANSACTION_PERCENTAGE` environment variable. + +The following YAML snippet illustrates the use of this environment variable: + +[embedmd]:# (./static/manifests/pod-dns-error/transaction-percentage.yaml yaml) +```yaml +# contains transaction percentage for the dns error +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-dns-error + spec: + components: + env: + # provide the transaction percentage within (0,100] range + # for example, it will affect 50% of the total dns queries + - name: TRANSACTION_PERCENTAGE + value: '50' + - name: TOTAL_CHAOS_DURATION + value: '60' +``` + ### Container runtime and socket path The `CONTAINER_RUNTIME` and `SOCKET_PATH` environment variables to set the container runtime and socket file path, respectively. diff --git a/docs/chaos-engineering/use-harness-ce/chaos-faults/kubernetes/pod/pod-dns-spoof.md b/docs/chaos-engineering/use-harness-ce/chaos-faults/kubernetes/pod/pod-dns-spoof.md index 92d46be509a..30cd4fc6298 100644 --- a/docs/chaos-engineering/use-harness-ce/chaos-faults/kubernetes/pod/pod-dns-spoof.md +++ b/docs/chaos-engineering/use-harness-ce/chaos-faults/kubernetes/pod/pod-dns-spoof.md @@ -88,6 +88,11 @@ permissions: Map of the target host names. For example, '{"abc.com":"spoofabc.com"}' where key is the host name to be spoofed and value is the host name to which the key is spoofed or redirected to. If not provided, no host names or domains are spoofed. + + TRANSACTION_PERCENTAGE + Percentage of the dns queries to be affected. + It supports values in range (0,100]. It targets all requests if not provided. For more information, go to transaction percentage . + PODS_AFFECTED_PERC Percentage of total pods to target. Provide numeric values. @@ -154,6 +159,40 @@ spec: value: "60" ``` +### Transaction Percentage + +The percentage of dns queries to be affected, with supported values in the range (0, 100]. If not specified, it targets all queries. Tune it by using the `TRANSACTION_PERCENTAGE` environment variable. + +The following YAML snippet illustrates the use of this environment variable: + +[embedmd]:# (./static/manifests/pod-dns-spoof/transaction-percentage.yaml yaml) +```yaml +# contains transaction percentage for the dns spoofing +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-dns-spoof + spec: + components: + env: + # provide the transaction percentage within (0,100] range + # for example, it will affect 50% of the total dns queries + - name: TRANSACTION_PERCENTAGE + value: '50' + - name: TOTAL_CHAOS_DURATION + value: '60' +``` + ### Container runtime and socket path The `CONTAINER_RUNTIME` and `SOCKET_PATH` environment variables to set the container runtime and socket file path, respectively. diff --git a/docs/chaos-engineering/use-harness-ce/chaos-faults/kubernetes/pod/static/manifests/pod-dns-error/transaction-percentage.yaml b/docs/chaos-engineering/use-harness-ce/chaos-faults/kubernetes/pod/static/manifests/pod-dns-error/transaction-percentage.yaml new file mode 100644 index 00000000000..6cd2040fe02 --- /dev/null +++ b/docs/chaos-engineering/use-harness-ce/chaos-faults/kubernetes/pod/static/manifests/pod-dns-error/transaction-percentage.yaml @@ -0,0 +1,24 @@ +# contains transaction percentage for the dns error +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-dns-error + spec: + components: + env: + # provide the transaction percentage within (0,100] range + # for example, it will affect 50% of the total dns queries + - name: TRANSACTION_PERCENTAGE + value: '50' + - name: TOTAL_CHAOS_DURATION + value: '60' \ No newline at end of file diff --git a/docs/chaos-engineering/use-harness-ce/chaos-faults/kubernetes/pod/static/manifests/pod-dns-spoof/transaction-percentage.yaml b/docs/chaos-engineering/use-harness-ce/chaos-faults/kubernetes/pod/static/manifests/pod-dns-spoof/transaction-percentage.yaml new file mode 100644 index 00000000000..d717f984795 --- /dev/null +++ b/docs/chaos-engineering/use-harness-ce/chaos-faults/kubernetes/pod/static/manifests/pod-dns-spoof/transaction-percentage.yaml @@ -0,0 +1,24 @@ +# contains transaction percentage for the dns spoofing +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-dns-spoof + spec: + components: + env: + # provide the transaction percentage within (0,100] range + # for example, it will affect 50% of the total dns queries + - name: TRANSACTION_PERCENTAGE + value: '50' + - name: TOTAL_CHAOS_DURATION + value: '60' \ No newline at end of file