diff --git a/Dockerfile.loadtester b/Dockerfile.loadtester index dafc9b49..220c2738 100644 --- a/Dockerfile.loadtester +++ b/Dockerfile.loadtester @@ -13,10 +13,15 @@ RUN curl -sSL "https://get.helm.sh/helm-v2.12.3-linux-amd64.tar.gz" | tar xvz && chmod +x linux-amd64/helm && mv linux-amd64/helm /usr/local/bin/helm && \ rm -rf linux-amd64 +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 && \ +mv /tmp/ghz /usr/local/bin && chmod +x /usr/local/bin/ghz && rm -rf /tmp/ghz-web + +RUN ls /tmp + COPY ./bin/loadtester . RUN chown -R app:app ./ USER app -ENTRYPOINT ["./loadtester"] \ No newline at end of file +ENTRYPOINT ["./loadtester"] diff --git a/artifacts/loadtester/deployment.yaml b/artifacts/loadtester/deployment.yaml index b5e61e1d..c5f1004d 100644 --- a/artifacts/loadtester/deployment.yaml +++ b/artifacts/loadtester/deployment.yaml @@ -17,7 +17,7 @@ spec: spec: containers: - name: loadtester - image: weaveworks/flagger-loadtester:0.4.0 + image: weaveworks/flagger-loadtester:0.5.0 imagePullPolicy: IfNotPresent ports: - name: http diff --git a/charts/loadtester/Chart.yaml b/charts/loadtester/Chart.yaml index 3772b661..53f5c232 100644 --- a/charts/loadtester/Chart.yaml +++ b/charts/loadtester/Chart.yaml @@ -1,10 +1,10 @@ apiVersion: v1 name: loadtester -version: 0.4.1 -appVersion: 0.4.0 +version: 0.5.0 +appVersion: 0.5.0 kubeVersion: ">=1.11.0-0" engine: gotpl -description: Flagger's load testing services based on rakyll/hey that generates traffic during canary analysis when configured as a webhook. +description: Flagger's load testing services based on rakyll/hey and bojand/ghz that generates traffic during canary analysis when configured as a webhook. home: https://docs.flagger.app icon: https://raw.githubusercontent.com/weaveworks/flagger/master/docs/logo/flagger-icon.png sources: diff --git a/cmd/loadtester/main.go b/cmd/loadtester/main.go index 962397b1..a042f3b7 100644 --- a/cmd/loadtester/main.go +++ b/cmd/loadtester/main.go @@ -10,7 +10,7 @@ import ( "time" ) -var VERSION = "0.4.0" +var VERSION = "0.5.0" var ( logLevel string port string diff --git a/docs/gitbook/how-it-works.md b/docs/gitbook/how-it-works.md index 1f41f2c9..439821c7 100644 --- a/docs/gitbook/how-it-works.md +++ b/docs/gitbook/how-it-works.md @@ -677,7 +677,7 @@ that generates traffic during analysis when configured as a webhook. ![Flagger Load Testing Webhook](https://raw.githubusercontent.com/weaveworks/flagger/master/docs/diagrams/flagger-load-testing.png) -First you need to deploy the load test runner in a namespace with Istio sidecar injection enabled: +First you need to deploy the load test runner in a namespace with sidecar injection enabled: ```bash 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 in the background, if they are not already running. This will ensure that during the analysis, the `podinfo-canary.test` service will receive a steady stream of GET and POST requests. -If your workload is exposed outside the mesh with the Istio Gateway and TLS you can point `hey` to the +If your workload is exposed outside the mesh you can point `hey` to the public URL and use HTTP2. ```yaml @@ -733,6 +733,18 @@ webhooks: cmd: "hey -z 1m -q 10 -c 2 -h2 https://podinfo.example.com/" ``` +For gRPC services you can use [bojand/ghz](https://github.com/bojand/ghz) which is a similar tool to Hey but for gPRC: + +```yaml +webhooks: + - name: grpc-load-test + url: http://flagger-loadtester.test/ + timeout: 5s + metadata: + type: cmd + cmd: "ghz -z 1m -q 10 -c 2 --insecure podinfo.test:9898" +``` + The load tester can run arbitrary commands as long as the binary is present in the container image. For example if you you want to replace `hey` with another CLI, you can create your own Docker image: diff --git a/kustomize/tester/deployment.yaml b/kustomize/tester/deployment.yaml new file mode 100644 index 00000000..c5f1004d --- /dev/null +++ b/kustomize/tester/deployment.yaml @@ -0,0 +1,67 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: flagger-loadtester + labels: + app: flagger-loadtester +spec: + selector: + matchLabels: + app: flagger-loadtester + template: + metadata: + labels: + app: flagger-loadtester + annotations: + prometheus.io/scrape: "true" + spec: + containers: + - name: loadtester + image: weaveworks/flagger-loadtester:0.5.0 + imagePullPolicy: IfNotPresent + ports: + - name: http + containerPort: 8080 + command: + - ./loadtester + - -port=8080 + - -log-level=info + - -timeout=1h + livenessProbe: + exec: + command: + - wget + - --quiet + - --tries=1 + - --timeout=4 + - --spider + - http://localhost:8080/healthz + timeoutSeconds: 5 + readinessProbe: + exec: + command: + - wget + - --quiet + - --tries=1 + - --timeout=4 + - --spider + - http://localhost:8080/healthz + timeoutSeconds: 5 + resources: + limits: + memory: "512Mi" + cpu: "1000m" + requests: + memory: "32Mi" + cpu: "10m" + securityContext: + readOnlyRootFilesystem: true + runAsUser: 10001 +# volumeMounts: +# - name: tests +# mountPath: /bats +# readOnly: true +# volumes: +# - name: tests +# configMap: +# name: flagger-loadtester-bats \ No newline at end of file diff --git a/kustomize/tester/kustomization.yaml b/kustomize/tester/kustomization.yaml new file mode 100644 index 00000000..1c928795 --- /dev/null +++ b/kustomize/tester/kustomization.yaml @@ -0,0 +1,7 @@ +namespace: test +resources: + - service.yaml + - deployment.yaml +images: + - name: weaveworks/flagger-loadtester + newTag: 0.5.0 diff --git a/kustomize/tester/service.yaml b/kustomize/tester/service.yaml new file mode 100644 index 00000000..772b20af --- /dev/null +++ b/kustomize/tester/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: flagger-loadtester + labels: + app: flagger-loadtester +spec: + type: ClusterIP + selector: + app: flagger-loadtester + ports: + - name: http + port: 80 + protocol: TCP + targetPort: http \ No newline at end of file