diff --git a/faults/load/experiments.yaml b/faults/load/experiments.yaml index 0dd544a4b..42c07bf97 100644 --- a/faults/load/experiments.yaml +++ b/faults/load/experiments.yaml @@ -94,3 +94,106 @@ spec: app.kubernetes.io/component: experiment-job app.kubernetes.io/version: ci --- +--- +apiVersion: litmuschaos.io/v1alpha1 +description: + message: | + Execute the locust engine using the Python script +kind: ChaosExperiment +metadata: + name: locust-loadgen + labels: + name: locust-loadgen + app.kubernetes.io/part-of: litmus + app.kubernetes.io/component: chaosexperiment + app.kubernetes.io/version: ci +spec: + definition: + scope: Namespaced + permissions: + # Create and monitor the experiment & helper pods + - apiGroups: [""] + resources: ["pods"] + verbs: + [ + "create", + "delete", + "get", + "list", + "patch", + "update", + "deletecollection", + ] + # Performs CRUD operations on the events inside chaosengine and chaosresult + - apiGroups: [""] + resources: ["events"] + verbs: ["create", "get", "list", "patch", "update"] + # Fetch configmaps & secrets details and mount it to the experiment pod (if specified) + - apiGroups: [""] + resources: ["configmaps"] + verbs: ["get", "list"] + # Track and get the runner, experiment, and helper pods log + - apiGroups: [""] + resources: ["pods/log"] + verbs: ["get", "list", "watch"] + # for creating and managing to execute commands inside target container + - apiGroups: [""] + resources: ["pods/exec"] + verbs: ["get", "list", "create"] + # for configuring and monitor the experiment job by the chaos-runner pod + - apiGroups: ["batch"] + resources: ["jobs"] + verbs: ["create", "list", "get", "delete", "deletecollection"] + # for creation, status polling and deletion of litmus chaos resources used within a chaos workflow + - apiGroups: ["litmuschaos.io"] + resources: ["chaosengines", "chaosexperiments", "chaosresults"] + verbs: ["create", "list", "get", "patch", "update", "delete"] + image: "litmuschaos.docker.scarf.sh/litmuschaos/go-runner:latest" + imagePullPolicy: Always + args: + - -c + - ./experiments -name locust-loadgen + command: + - /bin/bash + env: + # set chaos duration (in sec) as desired + - name: TOTAL_CHAOS_DURATION + value: "30" + + # Period to wait before and after injection of chaos in sec + - name: RAMP_TIME + value: "0" + + - name: HOST + value: "" + + # Define maximum users + - name: USERS + value: "40" + + # Generate users per second + - name: SPAWN_RATE + value: "30" + + # Provide the secret key of the Python script + - name: CONFIG_MAP_FILE + value: "locust-script" + + # Provide the ConfigMap key of the Python script + - name: CONFIG_MAP_KEY + value: "config.py" + + # Provide the image name of the helper pod + - name: LIB_IMAGE + value: "locustio/locust" + + # Provide the image pull policy of the helper pod + - name: LIB_IMAGE_PULL_POLICY + value: "Always" + + labels: + name: locust-loadgen + app.kubernetes.io/part-of: litmus + app.kubernetes.io/component: experiment-job + app.kubernetes.io/version: ci +--- \ No newline at end of file diff --git a/faults/load/icons/locust-loadgen.png b/faults/load/icons/locust-loadgen.png new file mode 100644 index 000000000..da0a10ea6 Binary files /dev/null and b/faults/load/icons/locust-loadgen.png differ diff --git a/faults/load/load.chartserviceversion.yaml b/faults/load/load.chartserviceversion.yaml index 95465e231..e74c886f6 100644 --- a/faults/load/load.chartserviceversion.yaml +++ b/faults/load/load.chartserviceversion.yaml @@ -16,6 +16,9 @@ spec: - name: k6-loadgen description: It injects the load on the application using k6 load generator displayName: "k6 Load Generator" + - name: locust-loadgen + description: It injects the load on the application using locust load generator + displayName: "locust Load Generator" keywords: - Load maintainers: @@ -27,6 +30,8 @@ spec: url: https://kubernetes.io - name: k6 Website url: https://k6.io/ + - name: locust Website + url: https://locust.io/ icon: - url: https://github.com/litmuschaos/chaos-charts/blob/master/faults/load/icons/k6-loadgen.png mediatype: image/png diff --git a/faults/load/load.package.yaml b/faults/load/load.package.yaml index 5a423e34b..7af6e0030 100644 --- a/faults/load/load.package.yaml +++ b/faults/load/load.package.yaml @@ -4,3 +4,6 @@ experiments: - name: k6-loadgen CSV: k6-loadgen.chartserviceversion.yaml desc: "k6-loadgen" + - name: locust-loadgen + CSV: locust-loadgen.chartserviceversion.yaml + desc: "locust-loadgen" \ No newline at end of file diff --git a/faults/load/locust-loadgen/engine.yaml b/faults/load/locust-loadgen/engine.yaml new file mode 100644 index 000000000..fef7cdc33 --- /dev/null +++ b/faults/load/locust-loadgen/engine.yaml @@ -0,0 +1,48 @@ +--- +apiVersion: litmuschaos.io/v1alpha1 +kind: ChaosEngine +metadata: + name: nginx-chaos + namespace: default +spec: + engineState: 'active' + chaosServiceAccount: litmus-admin + experiments: + - name: locust-loadgen + spec: + components: + env: + # set chaos duration (in sec) as desired + - name: TOTAL_CHAOS_DURATION + value: "30" + + # Period to wait before and after injection of chaos in sec + - name: RAMP_TIME + value: "0" + + - name: HOST + value: "" + + # Define maximum users + - name: USERS + value: "40" + + # Generate users per second + - name: SPAWN_RATE + value: "30" + + # Provide the ConfigMap key of the Python script + - name: CONFIG_MAP_NAME + value: "locust-script" + + # Provide the ConfigMap key of the Python script + - name: CONFIG_MAP_KEY + value: "config.py" + + # Provide the image name of the helper pod + - name: LIB_IMAGE + value: "locustio/locust" + + # Provide the image pull policy of the helper pod + - name: LIB_IMAGE_PULL_POLICY + value: "Always" \ No newline at end of file diff --git a/faults/load/locust-loadgen/fault.yaml b/faults/load/locust-loadgen/fault.yaml new file mode 100644 index 000000000..87b268bf9 --- /dev/null +++ b/faults/load/locust-loadgen/fault.yaml @@ -0,0 +1,102 @@ +--- +apiVersion: litmuschaos.io/v1alpha1 +description: + message: | + Execute the locust engine using the Python script +kind: ChaosExperiment +metadata: + name: locust-loadgen + labels: + name: locust-loadgen + app.kubernetes.io/part-of: litmus + app.kubernetes.io/component: chaosexperiment + app.kubernetes.io/version: ci +spec: + definition: + scope: Namespaced + permissions: + # Create and monitor the experiment & helper pods + - apiGroups: [""] + resources: ["pods"] + verbs: + [ + "create", + "delete", + "get", + "list", + "patch", + "update", + "deletecollection", + ] + # Performs CRUD operations on the events inside chaosengine and chaosresult + - apiGroups: [""] + resources: ["events"] + verbs: ["create", "get", "list", "patch", "update"] + # Fetch configmaps & secrets details and mount it to the experiment pod (if specified) + - apiGroups: [""] + resources: ["configmaps"] + verbs: ["get", "list"] + # Track and get the runner, experiment, and helper pods log + - apiGroups: [""] + resources: ["pods/log"] + verbs: ["get", "list", "watch"] + # for creating and managing to execute commands inside target container + - apiGroups: [""] + resources: ["pods/exec"] + verbs: ["get", "list", "create"] + # for configuring and monitor the experiment job by the chaos-runner pod + - apiGroups: ["batch"] + resources: ["jobs"] + verbs: ["create", "list", "get", "delete", "deletecollection"] + # for creation, status polling and deletion of litmus chaos resources used within a chaos workflow + - apiGroups: ["litmuschaos.io"] + resources: ["chaosengines", "chaosexperiments", "chaosresults"] + verbs: ["create", "list", "get", "patch", "update", "delete"] + image: "litmuschaos.docker.scarf.sh/litmuschaos/go-runner:latest" + imagePullPolicy: Always + args: + - -c + - ./experiments -name locust-loadgen + command: + - /bin/bash + env: + # set chaos duration (in sec) as desired + - name: TOTAL_CHAOS_DURATION + value: "30" + + # Period to wait before and after injection of chaos in sec + - name: RAMP_TIME + value: "0" + + - name: HOST + value: "" + + # Define maximum users + - name: USERS + value: "40" + + # Generate users per second + - name: SPAWN_RATE + value: "30" + + # Provide the ConfigMap name that contains Python script + - name: CONFIG_MAP_NAME + value: "locust-script" + + # Provide the ConfigMap key of the Python script + - name: CONFIG_MAP_KEY + value: "config.py" + + # Provide the image name of the helper pod + - name: LIB_IMAGE + value: "locustio/locust" + + # Provide the image pull policy of the helper pod + - name: LIB_IMAGE_PULL_POLICY + value: "Always" + + labels: + name: locust-loadgen + app.kubernetes.io/part-of: litmus + app.kubernetes.io/component: experiment-job + app.kubernetes.io/version: ci \ No newline at end of file diff --git a/faults/load/locust-loadgen/locust-loadgen.chartserviceversion.yaml b/faults/load/locust-loadgen/locust-loadgen.chartserviceversion.yaml new file mode 100644 index 000000000..b229f42ee --- /dev/null +++ b/faults/load/locust-loadgen/locust-loadgen.chartserviceversion.yaml @@ -0,0 +1,29 @@ +--- +apiVersion: litmuschaos.io/v1alpha1 +kind: ChartServiceVersion +metadata: + createdAt: 2024-11-27T01:00:00Z + name: locust-loadgen + version: 0.1.0 + annotations: + categories: Load + vendor: LitmusChaos +spec: + displayName: locust Load Generator + categoryDescription: | + Locust is an open-source load testing tool designed to make performance testing simple, efficient, and scalable for engineering teams. With Locust, you can define user behavior and simulate traffic using a single, flexible Python script. With its distributed testing capabilities, you can efficiently simulate millions of users. + keywords: + - locust + - Load + platforms: + - kubernetes + maintainers: + - name: DongYoung Kim + email: kwx4957@gmail.com + minKubeVersion: 1.33.0 + links: + - name: Documentation + url: https://litmuschaos.github.io/litmus/experiments/categories/contents + icon: + - url: + mediatype: ""