This operator is a layer above kubernetes jobs that allows you to manage them in much easier and IAC-oriented way. I came up with the idea when load-testing my site using k8s job, because I manually had to increase the load every time. this operator will let you configure your load-test initial load, max load, interval and hatch-rate, and most important - be able to reproduce the exact same load test over and over again
Apply the CRD:
kubectl apply -f https://raw.githubusercontent.com/Efrat19/kubeload/master/crd.yaml
Customize your load manager:
apiVersion: kubeload.kubeload.efrat19.io/v1
kind: LoadManager
metadata:
name: loadmanager-sample
spec:
loadSetup:
# How many pods the load should start with:
initialLoad: 2
# How much time to wait before increasing the pod count:
interval: 1m
# How many pods should be added on each interval:
hatchRate: 2
# The manager will stop increasing the pods count once hitting maxLoad:
maxLoad: 8
selector:
# Only jobs that has this set of labels will be controlled by this manager
matchLabels:
app: load-test
Once the above load manager will be applied, all jobs with the label app: load-test
will be updated with pod count 2 - (the initialRate
). than, every 1m (the interval
), the loadmanager will increase the pod count by 2 more pods (the hatchRate
), until reaching 8 pods (maxLoad
).
Any time you can annotate controlled jobs with kubeload.efrat19.io/freeze
. the load manager will not increase the pods count as long as this annotation is set to true
, For example - to freeze a job:
k annotate job load-test kubeload.efrat19.io/freeze="true"
To unfreeze-
k annotate job load-test kubeload.efrat19.io/freeze-
apply an example job and behold the results
apiVersion: batch/v1
kind: Job
metadata:
name: load-test
namespace: kubeload
labels:
app: load-test
# annotations:
# kubeload.efrat19.io/freeze: "true"
spec:
parallelism: 1
template:
spec:
containers:
- name: load-test
image: efrat19/locust-test:latest
command: [ "locust","--host=https://www.zdnet.com","--no-web", "-c 1", "-r 1"]
restartPolicy: Never
in addition to regular go metrics, the operator also exports a custom metric-
- Type: Gauge
- Description: specifies pod count on a given time.
- Labels: job, namespace
- build CI
- Documentation
- Example
- Helm chart
- Export Metrics
- Grafana Dashboard
- Tests
make install
make run