diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..d8adb82 Binary files /dev/null and b/.DS_Store differ diff --git a/cron-workflows/.DS_Store b/cron-workflows/.DS_Store new file mode 100644 index 0000000..4e206e1 Binary files /dev/null and b/cron-workflows/.DS_Store differ diff --git a/cron-workflows/node-cpu-hog/workflow.yaml b/cron-workflows/node-cpu-hog/workflow.yaml new file mode 100644 index 0000000..6058a4d --- /dev/null +++ b/cron-workflows/node-cpu-hog/workflow.yaml @@ -0,0 +1,55 @@ +## Refer to https://github.com/litmuschaos/chaos-workflows.git to setup the argo infrastructure +## Uses admin mode of litmus execution + +apiVersion: argoproj.io/v1alpha1 +kind: CronWorkflow +metadata: + name: node-cpu-cron-wf + namespace: litmus +spec: + schedule: "5/10 * * * *" + concurrencyPolicy: "Forbid" + startingDeadlineSeconds: 0 + workflowSpec: + entrypoint: argowf-chaos + serviceAccountName: argo-chaos + templates: + - name: argowf-chaos + steps: + - name: run-node-cpu-hog + template: run-node-cpu-hog + - name: run-node-cpu-hog + inputs: + artifacts: + - name: run-node-cpu-hog + path: /tmp/chaosengine-1.yaml + raw: + data: | + apiVersion: litmuschaos.io/v1alpha1 + kind: ChaosEngine + metadata: + name: node-cpu-hog + namespace: litmus + spec: + appinfo: + appns: kube-system + applabel: "k8s-app=kube-proxy" + appkind: daemonset + jobCleanUpPolicy: retain + monitoring: true + annotationCheck: 'false' + engineState: 'active' + chaosServiceAccount: litmus-admin + experiments: + - name: node-cpu-hog + spec: + components: + env: + - name: TOTAL_CHAOS_DURATION + value: "60" + - name: NODE_CPU_CORE + value: "" + container: + image: lachlanevenson/k8s-kubectl + command: [sh, -c] + args: ['kubectl apply -f /tmp/chaosengine-1.yaml -n litmus'] diff --git a/cron-workflows/node-memory-hog/workflow.yaml b/cron-workflows/node-memory-hog/workflow.yaml new file mode 100644 index 0000000..8f165ab --- /dev/null +++ b/cron-workflows/node-memory-hog/workflow.yaml @@ -0,0 +1,56 @@ +## Refer to https://github.com/litmuschaos/chaos-workflows.git to setup the argo infrastructure +## Uses admin mode of litmus execution + + +apiVersion: argoproj.io/v1alpha1 +kind: CronWorkflow +metadata: + name: node-memory-cron-wf + namespace: litmus +spec: + schedule: "0/10 * * * *" + concurrencyPolicy: "Forbid" + startingDeadlineSeconds: 0 + workflowSpec: + entrypoint: argowf-chaos + serviceAccountName: argo-chaos + templates: + - name: argowf-chaos + steps: + - name: run-node-memory-hog + template: run-node-memory-hog + - name: run-node-memory-hog + inputs: + artifacts: + - name: run-node-memory-hog + path: /tmp/chaosengine-2.yaml + raw: + data: | + apiVersion: litmuschaos.io/v1alpha1 + kind: ChaosEngine + metadata: + name: node-memory-hog + namespace: litmus + spec: + appinfo: + appns: kube-system + applabel: "k8s-app=kube-proxy" + appkind: daemonset + jobCleanUpPolicy: retain + monitoring: true + annotationCheck: 'false' + engineState: 'active' + chaosServiceAccount: litmus-admin + experiments: + - name: node-memory-hog + spec: + components: + env: + - name: TOTAL_CHAOS_DURATION + value: "60" + - name: MEMORY_PERCENTAGE + value: "90" + container: + image: lachlanevenson/k8s-kubectl + command: [sh, -c] + args: ['kubectl apply -f /tmp/chaosengine-2.yaml -n litmus'] diff --git a/service-accounts/argo-access.yaml b/service-accounts/argo-access.yaml new file mode 100644 index 0000000..a417f5a --- /dev/null +++ b/service-accounts/argo-access.yaml @@ -0,0 +1,29 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: argo-chaos +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: chaos-cluster-role +rules: +- apiGroups: + - '*' + resources: + - '*' + verbs: + - '*' +--- +apiVersion: rbac.authorization.k8s.io/v1beta1 +kind: ClusterRoleBinding +metadata: + name: chaos-cluster-role-binding +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: chaos-cluster-role +subjects: +- kind: ServiceAccount + name: argo-chaos + namespace: litmus \ No newline at end of file diff --git a/service-accounts/argowf-chaos-admin.yaml b/service-accounts/argowf-chaos-admin.yaml new file mode 100644 index 0000000..668633c --- /dev/null +++ b/service-accounts/argowf-chaos-admin.yaml @@ -0,0 +1,115 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Workflow +metadata: + generateName: argowf-chaos- +spec: + entrypoint: argowf-chaos + serviceAccountName: argo-chaos + arguments: + parameters: + - name: appNamespace + value: "default" + - name: adminModeNamespace + value: "litmus" + - name: appLabel + value: "nginx" + - name: fileName + value: "pod-app-kill-count.json" + templates: + - name: argowf-chaos + steps: + - - name: run-chaos + template: run-chaos + - name: run-benchmark + template: run-benchmark + - - name: revert-chaos + template: revert-chaos + + - name: run-chaos + inputs: + artifacts: + - name: run-chaos + path: /tmp/chaosengine.yaml + raw: + data: | + apiVersion: litmuschaos.io/v1alpha1 + kind: ChaosEngine + metadata: + name: nginx-chaos + namespace: {{workflow.parameters.adminModeNamespace}} + spec: + appinfo: + appns: {{workflow.parameters.appNamespace}} + applabel: "app={{workflow.parameters.appLabel}}" + appkind: deployment + jobCleanUpPolicy: retain + monitoring: false + annotationCheck: 'false' + engineState: 'active' + chaosServiceAccount: litmus-admin + experiments: + - name: k8-pod-delete + spec: + components: + env: + - name: NAME_SPACE + value: {{workflow.parameters.appNamespace}} + - name: LABEL_NAME + value: {{workflow.parameters.appLabel}} + - name: FILE + value: {{workflow.parameters.fileName}} + - name: REPORT + value: 'true' + - name: REPORT_ENDPOINT + value: 'none' + container: + image: lachlanevenson/k8s-kubectl + command: [sh, -c] + args: ['kubectl apply -f /tmp/chaosengine.yaml -n {{workflow.parameters.adminModeNamespace}} | echo "sleeping for 120s" | sleep 120 '] + + - name: run-benchmark + inputs: + artifacts: + - name: run-benchmark + path: /tmp/bench.yaml + raw: + data: | + apiVersion: batch/v1 + kind: Job + metadata: + labels: + app: nginx-bench + name: nginx-bench + spec: + template: + metadata: + labels: + app: nginx-bench + spec: + restartPolicy: Never + containers: + - args: + - -c + - /go/bin/main -r -c10 -t${BENCHMARK_DURATION} -n 10000000 http://${NGINX_SVC_NAME}:${NGINX_PORT_NUM}/; exit 0 + command: + - /bin/sh + env: + - name: NGINX_SVC_NAME + value: "nginx.default.svc.cluster.local" + - name: NGINX_PORT_NUM + value: "80" + - name: BENCHMARK_DURATION + value: "300" + image: devth/alpine-bench + imagePullPolicy: Always + name: nginx-bench + container: + image: lachlanevenson/k8s-kubectl + command: [sh, -c] + args: ['kubectl apply -f /tmp/bench.yaml -n {{workflow.parameters.appNamespace}}'] + + - name: revert-chaos + container: + image: lachlanevenson/k8s-kubectl + command: [sh, -c] + args: [' sleep 20 | kubectl delete chaosengine nginx-chaos -n {{workflow.parameters.adminModeNamespace}}'] \ No newline at end of file diff --git a/service-accounts/litmus-admin-rbac.yaml b/service-accounts/litmus-admin-rbac.yaml new file mode 100644 index 0000000..ab3751a --- /dev/null +++ b/service-accounts/litmus-admin-rbac.yaml @@ -0,0 +1,37 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: litmus-admin + namespace: litmus + labels: + name: litmus-admin +--- +# Source: openebs/templates/clusterrole.yaml +apiVersion: rbac.authorization.k8s.io/v1beta1 +kind: ClusterRole +metadata: + name: litmus-admin + labels: + name: litmus-admin +rules: +- apiGroups: ["","apps","batch","extensions","litmuschaos.io","openebs.io","storage.k8s.io"] + resources: ["chaosengines","chaosexperiments","chaosresults","cstorpools","cstorvolumereplicas","configmaps","secrets","pods","pods/exec","pods/log","pods/eviction","jobs","replicasets","deployments","daemonsets","statefulsets","persistentvolumeclaims","persistentvolumes","storageclasses","services","events"] + verbs: ["create","delete","get","list","patch","update"] +- apiGroups: [""] + resources: ["nodes"] + verbs: ["get","list","patch","update"] +--- +apiVersion: rbac.authorization.k8s.io/v1beta1 +kind: ClusterRoleBinding +metadata: + name: litmus-admin + labels: + name: litmus-admin +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: litmus-admin +subjects: +- kind: ServiceAccount + name: litmus-admin + namespace: litmus \ No newline at end of file diff --git a/workflows/.DS_Store b/workflows/.DS_Store new file mode 100644 index 0000000..975c493 Binary files /dev/null and b/workflows/.DS_Store differ diff --git a/workflows/node-cpu-hog/workflow.yaml b/workflows/node-cpu-hog/workflow.yaml index 44bd34e..c8a1685 100644 --- a/workflows/node-cpu-hog/workflow.yaml +++ b/workflows/node-cpu-hog/workflow.yaml @@ -1,54 +1,156 @@ -## Refer to https://github.com/litmuschaos/chaos-workflows.git to setup the argo infrastructure -## Uses admin mode of litmus execution - apiVersion: argoproj.io/v1alpha1 -kind: CronWorkflow +kind: Workflow metadata: - name: node-cpu-cron-wf + generateName: argowf-chaos-node-cpu-hog- + namespace: litmus spec: - schedule: "5/10 * * * *" - concurrencyPolicy: "Forbid" - startingDeadlineSeconds: 0 - workflowSpec: - entrypoint: argowf-chaos - serviceAccountName: argo-chaos - templates: + entrypoint: argowf-chaos + serviceAccountName: argo-chaos + arguments: + parameters: + - name: adminModeNamespace + value: "litmus" + templates: - name: argowf-chaos steps: - - name: run-node-cpu-hog - template: run-node-cpu-hog - - name: run-node-cpu-hog + - - name: install-experiment + template: install-experiment + - - name: run-chaos + template: run-chaos + - - name: revert-chaos + template: revert-chaos + + - name: install-experiment inputs: artifacts: - - name: run-node-cpu-hog - path: /tmp/chaosengine-1.yaml - raw: - data: | - apiVersion: litmuschaos.io/v1alpha1 - kind: ChaosEngine - metadata: - name: node-cpu-hog - namespace: litmus - spec: - appinfo: - appns: kube-system - applabel: "k8s-app=kube-proxy" - appkind: daemonset - jobCleanUpPolicy: retain - monitoring: true - annotationCheck: 'false' - engineState: 'active' - chaosServiceAccount: litmus-admin - experiments: - - name: node-cpu-hog - spec: - components: - env: - - name: TOTAL_CHAOS_DURATION - value: "60" - - name: NODE_CPU_CORE - value: "" + - name: install-experiment + path: /tmp/node-cpu-hog.yaml + raw: + data: | + apiVersion: litmuschaos.io/v1alpha1 + description: + message: | + Give a cpu spike on a node belonging to a deployment + kind: ChaosExperiment + metadata: + name: node-cpu-hog + version: 0.1.21 + spec: + definition: + scope: Cluster + permissions: + - apiGroups: + - "" + - "batch" + - "apps" + - "litmuschaos.io" + resources: + - "jobs" + - "pods" + - "pods/log" + - "events" + - "chaosengines" + - "chaosexperiments" + - "chaosresults" + verbs: + - "create" + - "list" + - "get" + - "patch" + - "update" + - "delete" + - apiGroups: + - "" + resources: + - "nodes" + verbs: + - "get" + - "list" + image: "litmuschaos/go-runner:latest" + imagePullPolicy: Always + args: + - -c + - ./experiments/node-cpu-hog + command: + - /bin/bash + env: + + - name: TOTAL_CHAOS_DURATION + value: '60' + + # Period to wait before and after injection of chaos in sec + - name: RAMP_TIME + value: '' + + ## ENTER THE NUMBER OF CORES OF CPU FOR CPU HOGGING + ## OPTIONAL VALUE IN CASE OF EMPTY VALUE IT WILL TAKE NODE CPU CAPACITY + - name: NODE_CPU_CORE + value: '' + + # PROVIDE THE LIB HERE + # ONLY LITMUS SUPPORTED + - name: LIB + value: 'litmus' + + # provide lib image + - name: LIB_IMAGE + value: 'litmuschaos/go-runner:latest' + + labels: + name: node-cpu-hog container: image: lachlanevenson/k8s-kubectl command: [sh, -c] - args: ['kubectl apply -f /tmp/chaosengine-1.yaml -n litmus'] + args: + [ + "kubectl apply -f /tmp/node-cpu-hog.yaml -n {{workflow.parameters.adminModeNamespace}}", + ] + + - name: run-chaos + inputs: + artifacts: + - name: run-chaos + path: /tmp/chaosengine.yaml + raw: + data: | + apiVersion: litmuschaos.io/v1alpha1 + kind: ChaosEngine + metadata: + name: kube-proxy-node-cpu-hog-chaos + namespace: {{workflow.parameters.adminModeNamespace}} + spec: + appinfo: + appns: kube-system + applabel: "k8s-app=kube-proxy" + appkind: daemonset + jobCleanUpPolicy: retain + monitoring: false + annotationCheck: 'false' + engineState: 'active' + chaosServiceAccount: litmus-admin + experiments: + - name: node-cpu-hog + spec: + components: + env: + - name: NODE_CPU_CORE + value: '1' + + - name: TOTAL_CHAOS_DURATION + value: '240' # in seconds + container: + image: lachlanevenson/k8s-kubectl + command: [sh, -c] + args: + [ + 'kubectl apply -f /tmp/chaosengine.yaml -n {{workflow.parameters.adminModeNamespace}} | echo "sleeping for 120s" | sleep 120 ', + ] + + - name: revert-chaos + container: + image: lachlanevenson/k8s-kubectl + command: [sh, -c] + args: + [ + " sleep 20 | kubectl delete chaosengine kube-proxy-node-cpu-hog-chaos -n {{workflow.parameters.adminModeNamespace}}", + ] diff --git a/workflows/node-memory-hog/workflow.yaml b/workflows/node-memory-hog/workflow.yaml index 479b26a..2ba5f66 100644 --- a/workflows/node-memory-hog/workflow.yaml +++ b/workflows/node-memory-hog/workflow.yaml @@ -1,55 +1,156 @@ -## Refer to https://github.com/litmuschaos/chaos-workflows.git to setup the argo infrastructure -## Uses admin mode of litmus execution - - apiVersion: argoproj.io/v1alpha1 -kind: CronWorkflow +kind: Workflow metadata: - name: node-memory-cron-wf + generateName: argowf-chaos-node-memory-hog- + namespace: litmus spec: - schedule: "0/10 * * * *" - concurrencyPolicy: "Forbid" - startingDeadlineSeconds: 0 - workflowSpec: - entrypoint: argowf-chaos - serviceAccountName: argo-chaos - templates: + entrypoint: argowf-chaos + serviceAccountName: argo-chaos + arguments: + parameters: + - name: adminModeNamespace + value: "litmus" + templates: - name: argowf-chaos steps: - - name: run-node-memory-hog - template: run-node-memory-hog - - name: run-node-memory-hog + - - name: install-experiment + template: install-experiment + - - name: run-chaos + template: run-chaos + - - name: revert-chaos + template: revert-chaos + + - name: install-experiment inputs: artifacts: - - name: run-node-memory-hog - path: /tmp/chaosengine-2.yaml - raw: - data: | - apiVersion: litmuschaos.io/v1alpha1 - kind: ChaosEngine - metadata: - name: node-memory-hog - namespace: litmus - spec: - appinfo: - appns: kube-system - applabel: "k8s-app=kube-proxy" - appkind: daemonset - jobCleanUpPolicy: retain - monitoring: true - annotationCheck: 'false' - engineState: 'active' - chaosServiceAccount: litmus-admin - experiments: - - name: node-memory-hog - spec: - components: - env: - - name: TOTAL_CHAOS_DURATION - value: "60" - - name: MEMORY_PERCENTAGE - value: "90" + - name: install-experiment + path: /tmp/node-memory-hog.yaml + raw: + data: | + apiVersion: litmuschaos.io/v1alpha1 + description: + message: | + Give a memory hog on a node belonging to a deployment + kind: ChaosExperiment + metadata: + name: node-memory-hog + version: 0.1.12 + spec: + definition: + scope: Cluster + permissions: + - apiGroups: + - "" + - "batch" + - "apps" + - "litmuschaos.io" + resources: + - "jobs" + - "pods" + - "pods/log" + - "events" + - "chaosengines" + - "chaosexperiments" + - "chaosresults" + verbs: + - "create" + - "list" + - "get" + - "patch" + - "update" + - "delete" + - apiGroups: + - "" + resources: + - "nodes" + verbs: + - "get" + - "list" + image: "litmuschaos/go-runner:latest" + imagePullPolicy: Always + args: + - -c + - ./experiments/node-memory-hog + command: + - /bin/bash + env: + + - name: TOTAL_CHAOS_DURATION + value: '120' + + ## specify the size as percent of total available memory (in percentage) + ## Default value "90" + - name: MEMORY_PERCENTAGE + value: '90' + + # Period to wait before and after injection of chaos in sec + - name: RAMP_TIME + value: '' + + # Provide the LIB here + # Only litmus supported + - name: LIB + value: 'litmus' + + # provide lib image + - name: LIB_IMAGE + value: 'litmuschaos/go-runner:latest' + + labels: + name: node-memory-hog container: image: lachlanevenson/k8s-kubectl command: [sh, -c] - args: ['kubectl apply -f /tmp/chaosengine-2.yaml -n litmus'] + args: + [ + "kubectl apply -f /tmp/node-memory-hog.yaml -n {{workflow.parameters.adminModeNamespace}}", + ] + + - name: run-chaos + inputs: + artifacts: + - name: run-chaos + path: /tmp/chaosengine.yaml + raw: + data: | + apiVersion: litmuschaos.io/v1alpha1 + kind: ChaosEngine + metadata: + name: kube-proxy-node-memory-hog-chaos + namespace: {{workflow.parameters.adminModeNamespace}} + spec: + appinfo: + appns: kube-system + applabel: "k8s-app=kube-proxy" + appkind: daemonset + jobCleanUpPolicy: retain + monitoring: false + annotationCheck: 'false' + engineState: 'active' + chaosServiceAccount: litmus-admin + experiments: + - name: node-memory-hog + spec: + components: + env: + - name: MEMORY_PERCENTAGE + value: '90' + + - name: TOTAL_CHAOS_DURATION + value: '240' # in seconds + container: + image: lachlanevenson/k8s-kubectl + command: [sh, -c] + args: + [ + 'kubectl apply -f /tmp/chaosengine.yaml -n {{workflow.parameters.adminModeNamespace}} | echo "sleeping for 120s" | sleep 120 ', + ] + + - name: revert-chaos + container: + image: lachlanevenson/k8s-kubectl + command: [sh, -c] + args: + [ + " sleep 20 | kubectl delete chaosengine kube-proxy-node-memory-hog-chaos -n {{workflow.parameters.adminModeNamespace}}", + ] diff --git a/workflows/pod-cpu-hog/workflow.yaml b/workflows/pod-cpu-hog/workflow.yaml new file mode 100644 index 0000000..4aa3607 --- /dev/null +++ b/workflows/pod-cpu-hog/workflow.yaml @@ -0,0 +1,157 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Workflow +metadata: + generateName: argowf-chaos-pod-cpu-hog- + namespace: litmus +spec: + entrypoint: argowf-chaos + serviceAccountName: argo-chaos + arguments: + parameters: + - name: adminModeNamespace + value: "litmus" + templates: + - name: argowf-chaos + steps: + - - name: install-experiment + template: install-experiment + - - name: run-chaos + template: run-chaos + - - name: revert-chaos + template: revert-chaos + + - name: install-experiment + inputs: + artifacts: + - name: install-experiment + path: /tmp/pod-cpu-hog.yaml + raw: + data: | + apiVersion: litmuschaos.io/v1alpha1 + description: + message: | + Injects cpu consumption on pods belonging to an app deployment + kind: ChaosExperiment + metadata: + name: pod-cpu-hog + version: 0.1.11 + spec: + definition: + scope: Namespaced + permissions: + - apiGroups: + - "" + - "batch" + - "litmuschaos.io" + resources: + - "jobs" + - "pods" + - "pods/log" + - "events" + - "chaosengines" + - "chaosexperiments" + - "chaosresults" + verbs: + - "create" + - "list" + - "get" + - "patch" + - "update" + - "delete" + image: "litmuschaos/go-runner:ci" + imagePullPolicy: Always + args: + - -c + - ./experiments/pod-cpu-hog + command: + - /bin/bash + env: + - name: TOTAL_CHAOS_DURATION + value: '30' + + - name: CHAOS_INTERVAL + value: '10' + + ## Number of CPU cores to stress + - name: CPU_CORES + value: '1' + + ## Percentage of total pods to target + - name: PODS_AFFECTED_PERC + value: '' + + ## Period to wait before and after injection of chaos in sec + - name: RAMP_TIME + value: '' + + - name: LIB + value: 'litmus' + + - name: TARGET_POD + value: '' + + labels: + name: pod-cpu-hog + container: + image: lachlanevenson/k8s-kubectl + command: [sh, -c] + args: + [ + "kubectl apply -f /tmp/pod-cpu-hog.yaml -n {{workflow.parameters.adminModeNamespace}}", + ] + + - name: run-chaos + inputs: + artifacts: + - name: run-chaos + path: /tmp/chaosengine.yaml + raw: + data: | + apiVersion: litmuschaos.io/v1alpha1 + kind: ChaosEngine + metadata: + name: kube-proxy-pod-cpu-hog-chaos + namespace: {{workflow.parameters.adminModeNamespace}} + spec: + appinfo: + appns: kube-system + applabel: "k8s-app=kube-proxy" + appkind: daemonset + jobCleanUpPolicy: retain + monitoring: false + annotationCheck: 'false' + engineState: 'active' + chaosServiceAccount: litmus-admin + experiments: + - name: pod-cpu-hog + spec: + components: + experimentImage: "litmuschaos/go-runner:ci" + env: + - name: TARGET_CONTAINER + value: 'kube-proxy' + + - name: CPU_CORES + value: '1' + + - name: TOTAL_CHAOS_DURATION + value: '240' # in seconds + + - name: CHAOS_KILL_COMMAND + value: "kill -9 $(ps afx | grep \"[md5sum] /dev/zero\" | awk '{print$1}' | tr '\n' ' ')" + container: + image: lachlanevenson/k8s-kubectl + command: [sh, -c] + args: + [ + 'kubectl apply -f /tmp/chaosengine.yaml -n {{workflow.parameters.adminModeNamespace}} | echo "sleeping for 120s" | sleep 120 ', + ] + + - name: revert-chaos + container: + image: lachlanevenson/k8s-kubectl + command: [sh, -c] + args: + [ + " sleep 20 | kubectl delete chaosengine kube-proxy-pod-cpu-hog-chaos -n {{workflow.parameters.adminModeNamespace}}", + ] diff --git a/workflows/pod-delete/workflow.yaml b/workflows/pod-delete/workflow.yaml new file mode 100644 index 0000000..6684ae3 --- /dev/null +++ b/workflows/pod-delete/workflow.yaml @@ -0,0 +1,157 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Workflow +metadata: + generateName: argowf-chaos-pod-delete- + namespace: litmus +spec: + entrypoint: argowf-chaos + serviceAccountName: argo-chaos + arguments: + parameters: + - name: adminModeNamespace + value: "litmus" + templates: + - name: argowf-chaos + steps: + - - name: install-experiment + template: install-experiment + - - name: run-chaos + template: run-chaos + - - name: revert-chaos + template: revert-chaos + + - name: install-experiment + inputs: + artifacts: + - name: install-experiment + path: /tmp/pod-delete.yaml + raw: + data: | + apiVersion: litmuschaos.io/v1alpha1 + description: + message: | + Deletes a pod belonging to a deployment/statefulset/daemonset + kind: ChaosExperiment + metadata: + name: pod-delete + version: 0.1.19 + spec: + definition: + scope: Namespaced + permissions: + - apiGroups: + - "" + - "apps" + - "batch" + - "litmuschaos.io" + resources: + - "deployments" + - "jobs" + - "pods" + - "pods/log" + - "events" + - "configmaps" + - "chaosengines" + - "chaosexperiments" + - "chaosresults" + verbs: + - "create" + - "list" + - "get" + - "patch" + - "update" + - "delete" + - apiGroups: + - "" + resources: + - "nodes" + verbs: + - "get" + - "list" + image: "litmuschaos/go-runner:latest" + imagePullPolicy: Always + args: + - -c + - ./experiments/pod-delete + command: + - /bin/bash + env: + + - name: TOTAL_CHAOS_DURATION + value: '15' + + # Period to wait before and after injection of chaos in sec + - name: RAMP_TIME + value: '' + + # provide the kill count + - name: KILL_COUNT + value: '' + + - name: FORCE + value: 'true' + + - name: CHAOS_INTERVAL + value: '5' + + - name: LIB + value: 'litmus' + labels: + name: pod-delete + container: + image: lachlanevenson/k8s-kubectl + command: [sh, -c] + args: + [ + "kubectl apply -f /tmp/pod-delete.yaml -n {{workflow.parameters.adminModeNamespace}}", + ] + + - name: run-chaos + inputs: + artifacts: + - name: run-chaos + path: /tmp/chaosengine.yaml + raw: + data: | + apiVersion: litmuschaos.io/v1alpha1 + kind: ChaosEngine + metadata: + name: kube-proxy-pod-delete-chaos + namespace: {{workflow.parameters.adminModeNamespace}} + spec: + appinfo: + appns: kube-system + applabel: "k8s-app=kube-proxy" + appkind: daemonset + jobCleanUpPolicy: retain + monitoring: false + annotationCheck: 'false' + engineState: 'active' + chaosServiceAccount: litmus-admin + experiments: + - name: pod-delete + spec: + components: + env: + - name: TOTAL_CHAOS_DURATION + value: "10" + - name: CHAOS_INTERVAL + value: "10" + - name: FORCE + value: "false" + container: + image: lachlanevenson/k8s-kubectl + command: [sh, -c] + args: + [ + 'kubectl apply -f /tmp/chaosengine.yaml -n {{workflow.parameters.adminModeNamespace}} | echo "sleeping for 120s" | sleep 120 ', + ] + + - name: revert-chaos + container: + image: lachlanevenson/k8s-kubectl + command: [sh, -c] + args: + [ + " sleep 20 | kubectl delete chaosengine kube-proxy-pod-delete-chaos -n {{workflow.parameters.adminModeNamespace}}", + ] diff --git a/workflows/pod-memory-hog/workflow.yaml b/workflows/pod-memory-hog/workflow.yaml new file mode 100644 index 0000000..33fa68d --- /dev/null +++ b/workflows/pod-memory-hog/workflow.yaml @@ -0,0 +1,158 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Workflow +metadata: + generateName: argowf-chaos-pod-memory-hog- + namespace: litmus +spec: + entrypoint: argowf-chaos + serviceAccountName: argo-chaos + arguments: + parameters: + - name: adminModeNamespace + value: "litmus" + templates: + - name: argowf-chaos + steps: + - - name: install-experiment + template: install-experiment + - - name: run-chaos + template: run-chaos + - - name: revert-chaos + template: revert-chaos + + - name: install-experiment + inputs: + artifacts: + - name: install-experiment + path: /tmp/pod-memory-hog.yaml + raw: + data: | + apiVersion: litmuschaos.io/v1alpha1 + description: + message: | + Injects memory consumption on pods belonging to an app deployment + kind: ChaosExperiment + metadata: + name: pod-memory-hog + version: 0.1.3 + spec: + definition: + scope: Namespaced + permissions: + - apiGroups: + - "" + - "batch" + - "litmuschaos.io" + resources: + - "jobs" + - "pods" + - "pods/log" + - "events" + - "chaosengines" + - "chaosexperiments" + - "chaosresults" + verbs: + - "create" + - "list" + - "get" + - "patch" + - "update" + - "delete" + image: "litmuschaos/go-runner:ci" + args: + - -c + - ./experiments/pod-memory-hog + command: + - /bin/bash + env: + - name: TOTAL_CHAOS_DURATION + value: '30' + + - name: CHAOS_INTERVAL + value: '10' + + ## enter the amount of memory in megabytes to be consumed by the application pod + - name: MEMORY_CONSUMPTION + value: '500' + + ## percentage of total pods to target + - name: PODS_AFFECTED_PERC + value: '' + + ## Period to wait before and after injection of chaos in sec + - name: RAMP_TIME + value: '' + + ## env var that describes the library used to execute the chaos + ## default: litmus. Supported values: litmus, powerfulseal, chaoskube + - name: LIB + value: 'litmus' + + - name: TARGET_POD + value: '' + + labels: + name: pod-memory-hog + container: + image: lachlanevenson/k8s-kubectl + command: [sh, -c] + args: + [ + "kubectl apply -f /tmp/pod-memory-hog.yaml -n {{workflow.parameters.adminModeNamespace}}", + ] + + - name: run-chaos + inputs: + artifacts: + - name: run-chaos + path: /tmp/chaosengine.yaml + raw: + data: | + apiVersion: litmuschaos.io/v1alpha1 + kind: ChaosEngine + metadata: + name: kube-proxy-pod-memory-hog-chaos + namespace: {{workflow.parameters.adminModeNamespace}} + spec: + appinfo: + appns: kube-system + applabel: "k8s-app=kube-proxy" + appkind: daemonset + jobCleanUpPolicy: retain + monitoring: false + annotationCheck: 'false' + engineState: 'active' + chaosServiceAccount: litmus-admin + experiments: + - name: pod-memory-hog + spec: + components: + experimentImage: "litmuschaos/go-runner:ci" + env: + - name: TARGET_CONTAINER + value: 'kube-proxy' + + - name: MEMORY_CONSUMPTION + value: '500' + + - name: TOTAL_CHAOS_DURATION + value: '240' # in seconds + + - name: CHAOS_KILL_COMMAND + value: "kill -9 $(ps afx | grep \"[dd] if /dev/zero\" | awk '{print $1}' | tr '\n' ' ')" + container: + image: lachlanevenson/k8s-kubectl + command: [sh, -c] + args: + [ + 'kubectl apply -f /tmp/chaosengine.yaml -n {{workflow.parameters.adminModeNamespace}} | echo "sleeping for 120s" | sleep 120 ', + ] + + - name: revert-chaos + container: + image: lachlanevenson/k8s-kubectl + command: [sh, -c] + args: + [ + " sleep 20 | kubectl delete chaosengine kube-proxy-pod-memory-hog-chaos -n {{workflow.parameters.adminModeNamespace}}", + ]