Skip to content

Commit a0a4d4c

Browse files
authored
Merge pull request #248 from weaveworks/ghz
Add gRPC load testing tool
2 parents d2cbd40 + 970a589 commit a0a4d4c

File tree

8 files changed

+114
-8
lines changed

8 files changed

+114
-8
lines changed

Dockerfile.loadtester

+6-1
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,15 @@ RUN curl -sSL "https://get.helm.sh/helm-v2.12.3-linux-amd64.tar.gz" | tar xvz &&
1313
chmod +x linux-amd64/helm && mv linux-amd64/helm /usr/local/bin/helm && \
1414
rm -rf linux-amd64
1515

16+
RUN curl -sSL "https://github.com/bojand/ghz/releases/download/v0.39.0/ghz_0.39.0_Linux_x86_64.tar.gz" | tar xz -C /tmp && \
17+
mv /tmp/ghz /usr/local/bin && chmod +x /usr/local/bin/ghz && rm -rf /tmp/ghz-web
18+
19+
RUN ls /tmp
20+
1621
COPY ./bin/loadtester .
1722

1823
RUN chown -R app:app ./
1924

2025
USER app
2126

22-
ENTRYPOINT ["./loadtester"]
27+
ENTRYPOINT ["./loadtester"]

artifacts/loadtester/deployment.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ spec:
1717
spec:
1818
containers:
1919
- name: loadtester
20-
image: weaveworks/flagger-loadtester:0.4.0
20+
image: weaveworks/flagger-loadtester:0.5.0
2121
imagePullPolicy: IfNotPresent
2222
ports:
2323
- name: http

charts/loadtester/Chart.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
apiVersion: v1
22
name: loadtester
3-
version: 0.4.1
4-
appVersion: 0.4.0
3+
version: 0.5.0
4+
appVersion: 0.5.0
55
kubeVersion: ">=1.11.0-0"
66
engine: gotpl
7-
description: Flagger's load testing services based on rakyll/hey that generates traffic during canary analysis when configured as a webhook.
7+
description: Flagger's load testing services based on rakyll/hey and bojand/ghz that generates traffic during canary analysis when configured as a webhook.
88
home: https://docs.flagger.app
99
icon: https://raw.githubusercontent.com/weaveworks/flagger/master/docs/logo/flagger-icon.png
1010
sources:

cmd/loadtester/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"time"
1111
)
1212

13-
var VERSION = "0.4.0"
13+
var VERSION = "0.5.0"
1414
var (
1515
logLevel string
1616
port string

docs/gitbook/how-it-works.md

+14-2
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ that generates traffic during analysis when configured as a webhook.
677677

678678
![Flagger Load Testing Webhook](https://raw.githubusercontent.com/weaveworks/flagger/master/docs/diagrams/flagger-load-testing.png)
679679

680-
First you need to deploy the load test runner in a namespace with Istio sidecar injection enabled:
680+
First you need to deploy the load test runner in a namespace with sidecar injection enabled:
681681

682682
```bash
683683
export REPO=https://raw.githubusercontent.com/weaveworks/flagger/master
@@ -720,7 +720,7 @@ When the canary analysis starts, Flagger will call the webhooks and the load tes
720720
in the background, if they are not already running. This will ensure that during the
721721
analysis, the `podinfo-canary.test` service will receive a steady stream of GET and POST requests.
722722

723-
If your workload is exposed outside the mesh with the Istio Gateway and TLS you can point `hey` to the
723+
If your workload is exposed outside the mesh you can point `hey` to the
724724
public URL and use HTTP2.
725725

726726
```yaml
@@ -733,6 +733,18 @@ webhooks:
733733
cmd: "hey -z 1m -q 10 -c 2 -h2 https://podinfo.example.com/"
734734
```
735735

736+
For gRPC services you can use [bojand/ghz](https://github.com/bojand/ghz) which is a similar tool to Hey but for gPRC:
737+
738+
```yaml
739+
webhooks:
740+
- name: grpc-load-test
741+
url: http://flagger-loadtester.test/
742+
timeout: 5s
743+
metadata:
744+
type: cmd
745+
cmd: "ghz -z 1m -q 10 -c 2 --insecure podinfo.test:9898"
746+
```
747+
736748
The load tester can run arbitrary commands as long as the binary is present in the container image.
737749
For example if you you want to replace `hey` with another CLI, you can create your own Docker image:
738750

kustomize/tester/deployment.yaml

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: flagger-loadtester
5+
labels:
6+
app: flagger-loadtester
7+
spec:
8+
selector:
9+
matchLabels:
10+
app: flagger-loadtester
11+
template:
12+
metadata:
13+
labels:
14+
app: flagger-loadtester
15+
annotations:
16+
prometheus.io/scrape: "true"
17+
spec:
18+
containers:
19+
- name: loadtester
20+
image: weaveworks/flagger-loadtester:0.5.0
21+
imagePullPolicy: IfNotPresent
22+
ports:
23+
- name: http
24+
containerPort: 8080
25+
command:
26+
- ./loadtester
27+
- -port=8080
28+
- -log-level=info
29+
- -timeout=1h
30+
livenessProbe:
31+
exec:
32+
command:
33+
- wget
34+
- --quiet
35+
- --tries=1
36+
- --timeout=4
37+
- --spider
38+
- http://localhost:8080/healthz
39+
timeoutSeconds: 5
40+
readinessProbe:
41+
exec:
42+
command:
43+
- wget
44+
- --quiet
45+
- --tries=1
46+
- --timeout=4
47+
- --spider
48+
- http://localhost:8080/healthz
49+
timeoutSeconds: 5
50+
resources:
51+
limits:
52+
memory: "512Mi"
53+
cpu: "1000m"
54+
requests:
55+
memory: "32Mi"
56+
cpu: "10m"
57+
securityContext:
58+
readOnlyRootFilesystem: true
59+
runAsUser: 10001
60+
# volumeMounts:
61+
# - name: tests
62+
# mountPath: /bats
63+
# readOnly: true
64+
# volumes:
65+
# - name: tests
66+
# configMap:
67+
# name: flagger-loadtester-bats

kustomize/tester/kustomization.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace: test
2+
resources:
3+
- service.yaml
4+
- deployment.yaml
5+
images:
6+
- name: weaveworks/flagger-loadtester
7+
newTag: 0.5.0

kustomize/tester/service.yaml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: flagger-loadtester
5+
labels:
6+
app: flagger-loadtester
7+
spec:
8+
type: ClusterIP
9+
selector:
10+
app: flagger-loadtester
11+
ports:
12+
- name: http
13+
port: 80
14+
protocol: TCP
15+
targetPort: http

0 commit comments

Comments
 (0)