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

Introduce new way to deploy and configure workers #183

Merged
merged 12 commits into from
Sep 2, 2024
57 changes: 57 additions & 0 deletions charts/zeebe-benchmark/templates/workers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{{- range $workerName, $worker := .Values.workers }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ $workerName }}-worker
labels:
app: {{ $workerName }}-worker
spec:
selector:
matchLabels:
app: {{ $workerName }}-worker
replicas: {{ $worker.replicas | default 3}}
template:
metadata:
labels:
app: {{ $workerName }}-worker
app.kubernetes.io/component: zeebe-client
spec:
containers:
- name: {{ $workerName }}-worker
image: "{{ $.Values.global.image.repository }}/worker:{{ $.Values.global.image.tag }}"
imagePullPolicy: {{ $.Values.global.image.pullPolicy }}
env:
- name: JDK_JAVA_OPTIONS
value: >-
-Dconfig.override_with_env_vars=true
-Dapp.brokerUrl={{ $.Release.Name }}-zeebe-gateway:26500
-Dzeebe.client.requestTimeout=62000
{{- if $worker.capacity }}
-Dapp.worker.capacity={{ $worker.capacity }}
{{- end }}
-Dapp.worker.pollingDelay=1ms
-Dapp.worker.completionDelay=50ms
-Dapp.worker.workerName={{ $workerName | quote }}
{{- if $worker.jobType }}
-Dapp.worker.jobType={{ $worker.jobType | quote }}
{{- end }}
{{- if $worker.payloadPath }}
-Dapp.worker.payloadPath={{ $worker.payloadPath | quote }}
{{- end}}
{{- if $worker.completionDelay }}
-Dapp.worker.completionDelay={{ $worker.completionDelay }}
{{- end}}
-XX:+HeapDumpOnOutOfMemoryError
{{- if $worker.logLevel }}
- name: LOG_LEVEL
value: {{ $worker.logLevel | quote }}
{{- end }}
{{- if $worker.resources }}
resources:
{{- toYaml $worker.resources | nindent 12 }}
{{- end }}
ports:
- containerPort: 9600
name: "http"
---
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ spec:
imagePullPolicy: Always
securityContext:
allowPrivilegeEscalation: true
capabilities:
add:
- NET_ADMIN
privileged: true
readOnlyRootFilesystem: true
runAsNonRoot: true
Expand Down
2 changes: 1 addition & 1 deletion charts/zeebe-benchmark/test/golden/worker.golden.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ spec:
selector:
matchLabels:
app: worker
replicas: 3
replicas: 0
template:
metadata:
labels:
Expand Down
87 changes: 87 additions & 0 deletions charts/zeebe-benchmark/test/golden/workers.golden.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
---
# Source: zeebe-benchmark/templates/workers.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: benchmark-worker
labels:
app: benchmark-worker
spec:
selector:
matchLabels:
app: benchmark-worker
replicas: 3
template:
metadata:
labels:
app: benchmark-worker
app.kubernetes.io/component: zeebe-client
spec:
containers:
- name: benchmark-worker
image: "gcr.io/zeebe-io/worker:SNAPSHOT"
imagePullPolicy: Always
env:
- name: JDK_JAVA_OPTIONS
value: >-
-Dconfig.override_with_env_vars=true
-Dapp.brokerUrl=benchmark-test-zeebe-gateway:26500
-Dzeebe.client.requestTimeout=62000
-Dapp.worker.capacity=60
-Dapp.worker.pollingDelay=1ms
-Dapp.worker.completionDelay=50ms
-Dapp.worker.workerName="benchmark"
-Dapp.worker.jobType="benchmark-task"
-Dapp.worker.payloadPath="bpmn/big_payload.json"
-Dapp.worker.completionDelay=300ms
-XX:+HeapDumpOnOutOfMemoryError
- name: LOG_LEVEL
value: "WARN"
resources:
limits:
cpu: 500m
memory: 256Mi
requests:
cpu: 500m
memory: 256Mi
ports:
- containerPort: 9600
name: "http"
---
# Source: zeebe-benchmark/templates/workers.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: otherWorker-worker
labels:
app: otherWorker-worker
spec:
selector:
matchLabels:
app: otherWorker-worker
replicas: 1
template:
metadata:
labels:
app: otherWorker-worker
app.kubernetes.io/component: zeebe-client
spec:
containers:
- name: otherWorker-worker
image: "gcr.io/zeebe-io/worker:SNAPSHOT"
imagePullPolicy: Always
env:
- name: JDK_JAVA_OPTIONS
value: >-
-Dconfig.override_with_env_vars=true
-Dapp.brokerUrl=benchmark-test-zeebe-gateway:26500
-Dzeebe.client.requestTimeout=62000
-Dapp.worker.capacity=10
-Dapp.worker.pollingDelay=1ms
-Dapp.worker.completionDelay=50ms
-Dapp.worker.workerName="otherWorker"
-Dapp.worker.jobType="otherWorker-job"
-XX:+HeapDumpOnOutOfMemoryError
ports:
- containerPort: 9600
name: "http"
26 changes: 25 additions & 1 deletion charts/zeebe-benchmark/test/golden_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/stretchr/testify/suite"
)

func TestGoldenCuratorDefaults(t *testing.T) {
func TestGoldenDefaults(t *testing.T) {

chartPath, err := filepath.Abs("../")
require.NoError(t, err)
Expand All @@ -28,3 +28,27 @@ func TestGoldenCuratorDefaults(t *testing.T) {
})
}
}

func TestGoldenWorkers(t *testing.T) {

chartPath, err := filepath.Abs("../")
require.NoError(t, err)
templateNames := []string{"workers"}

values := map[string]string{
"workers.otherWorker.jobType": "otherWorker-job",
"workers.otherWorker.replicas": "1",
"workers.otherWorker.capacity": "10",
}

for _, name := range templateNames {
suite.Run(t, &golden.TemplateGoldenTest{
ChartPath: chartPath,
Release: "benchmark-test",
Namespace: "benchmark-" + strings.ToLower(random.UniqueId()),
GoldenFileName: name,
Templates: []string{"templates/" + name + ".yaml"},
SetValues: values,
})
}
}
56 changes: 52 additions & 4 deletions charts/zeebe-benchmark/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,61 @@ global:
auth:
enabled: false

# Worker configuration for the to be deployed worker application
# DEPRECATED worker configuration for the to be deployed worker application
worker:
# Worker.replicas defines how many replicas of the worker application should be deployed
replicas: 3
# Worker.capacity defines how many jobs the worker should activate and work on
# Worker.benchmark.replicas defines how many replicas of the benchmark worker should be deployed
replicas: 0 # disabled per default as it is deprecated
# Worker.benchmark.capacity defines how many jobs the worker should activate and work on
capacity: 60

# Workers configuration for the to be deployed worker application
# => New way to deploy workers <=
workers:
# Workers.benchmark defines the configuration for the default benchmark worker
# See below if you want additional workers
benchmark:
# Workers.benchmark.replicas defines how many replicas of the benchmark worker should be deployed
replicas: 3
# Workers.benchmark.capacity defines how many jobs the worker should activate and work on
capacity: 60
# Workers.benchmark.jobType defines the job type which should be used by the worker
jobType: "benchmark-task"
# Workers.benchmark.payloadPath defines the path (inside the worker app) to the payload resource
# that should be used to complete the corresponding jobs
payloadPath: "bpmn/big_payload.json"
# Workers.benchmark.payloadPath defines the delay of the worker before completing a job
completionDelay: 300ms
# Workers.benchmark.logLevel defines the logging level for the benchmark worker
logLevel: "WARN"
# Workers.benchmark.resources defines the resources for the benchmark worker
resources:
limits:
cpu: 500m
memory: 256Mi
requests:
cpu: 500m
memory: 256Mi

# Workers.benchmark defines the configuration for the default benchmark worker
# Adding more and different worker can be done via adding a new map like:
# benchmark-2:
# # Workers.benchmark.replicas defines how many replicas of the benchmark worker should be deployed
# replicas: 3
# # Workers.benchmark.capacity defines how many jobs the worker should activate and work on
# capacity: 60
# # Workers.benchmark.jobType defines the job type which should be used by the worker
# jobType: "benchmark-2-task"
# # Workers.benchmark.logLevel defines the logging level for the benchmark worker
# logLevel: "WARN"
# # Workers.benchmark.resources defines the resources for the benchmark worker
# resources:
# limits:
# cpu: 500m
# memory: 256Mi
# requests:
# cpu: 500m
# memory: 256Mi

# Starter configuration for the to be deployed starter application
starter:
# Starter.replicas defines how many replicas of the application should be deployed
Expand Down