Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add a locust-loadgen chaos fault #643

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions faults/load/experiments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
---
Binary file added faults/load/icons/locust-loadgen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions faults/load/load.chartserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
3 changes: 3 additions & 0 deletions faults/load/load.package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
48 changes: 48 additions & 0 deletions faults/load/locust-loadgen/engine.yaml
Original file line number Diff line number Diff line change
@@ -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"
102 changes: 102 additions & 0 deletions faults/load/locust-loadgen/fault.yaml
Original file line number Diff line number Diff line change
@@ -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
29 changes: 29 additions & 0 deletions faults/load/locust-loadgen/locust-loadgen.chartserviceversion.yaml
Original file line number Diff line number Diff line change
@@ -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: [email protected]
minKubeVersion: 1.33.0
links:
- name: Documentation
url: https://litmuschaos.github.io/litmus/experiments/categories/contents
icon:
- url:
mediatype: ""