From 1cba0fa837165d7df939f386524793dc4c357f20 Mon Sep 17 00:00:00 2001 From: Xueliang Yang <102161631+oeular@users.noreply.github.com> Date: Thu, 2 Jun 2022 13:59:20 +0800 Subject: [PATCH] Trait:vegeta (#359) Signed-off-by: Xueliang Yang --- addons/fluxcd/readme.md | 16 +++--- addons/vegeta/definitions/vegeta.cue | 48 ++++++++++++++++ addons/vegeta/metadata.yaml | 13 +++++ addons/vegeta/readme.md | 84 ++++++++++++++++++++++++++++ 4 files changed, 153 insertions(+), 8 deletions(-) create mode 100644 addons/vegeta/definitions/vegeta.cue create mode 100644 addons/vegeta/metadata.yaml create mode 100644 addons/vegeta/readme.md diff --git a/addons/fluxcd/readme.md b/addons/fluxcd/readme.md index ffd25d17..259acf82 100644 --- a/addons/fluxcd/readme.md +++ b/addons/fluxcd/readme.md @@ -20,14 +20,14 @@ git repo / helm repo / S3 compatible bucket. ## Note - In this Fluxcd Addon, there are five controllers to be installed by default -|CONTROLLER NAME |DEFINITION NAME |DEFINITION TYPE |DEFINITION DESCRIPTION| -| :----: | :----: | :----: | ---| -|helm-controller |config-helm-repository |ComponentDefinition |Config information to authenticate helm chart repository| -|helm-controller |helm |ComponentDefinition |helm release is a group of K8s resources from either gitrepository or helm repo| -|kustomize-controller |kustomize |ComponentDefinition |kustomize can fetching, building, updating and applying Kustomize manifests from git repo| -|kustomize-controller |kustomize-json-patch |TraitDefinition |A list of JSON6902 patch to selected target| -|kustomize-controller |kustomize-patch |TraitDefinition |A list of StrategicMerge or JSON6902 patch to selected target| -|kustomize-controller |kustomize-strategy-merge |TraitDefinition |A list of strategic merge to kustomize config +|DEFINITION NAME |DEFINITION TYPE |DEFINITION DESCRIPTION| SUPPORT CONTROLLER | +|:----: | :----: | ---| :----: | +|config-helm-repository |ComponentDefinition |Config information to authenticate helm chart repository| helm-controller | +|helm |ComponentDefinition |helm release is a group of K8s resources from either gitrepository or helm repo|helm-controller | +|kustomize |ComponentDefinition |kustomize can fetching, building, updating and applying Kustomize manifests from git repo|kustomize-controller | +|kustomize-json-patch |TraitDefinition |A list of JSON6902 patch to selected target|kustomize-controller | +|kustomize-patch |TraitDefinition |A list of StrategicMerge or JSON6902 patch to selected target |kustomize-controller | +|kustomize-strategy-merge |TraitDefinition |A list of strategic merge to kustomize config |kustomize-controller | - Source controller - The source-controller is a Kubernetes operator, specialised in artifacts acquisition from external sources such as Git, Helm repositories and S3 buckets. The source-controller implements the source.toolkit.fluxcd.io API and is a core component of the GitOps toolkit. diff --git a/addons/vegeta/definitions/vegeta.cue b/addons/vegeta/definitions/vegeta.cue new file mode 100644 index 00000000..3fbb403d --- /dev/null +++ b/addons/vegeta/definitions/vegeta.cue @@ -0,0 +1,48 @@ +vegeta: { + annotations: {} + attributes: { + appliesToWorkloads: ["webservice","worker","cloneset"] + conflictsWith: [] + podDisruptive: false + workloadRefPath: "" + } + description: "" + labels: {} + type: "trait" +} + +template: { + outputs:"vegeta":{ + metadata: { + name: context.name + namespace: context.namespace + } + spec: { + backoffLimit: parameter.backofflimit + completions: parameter.parallelism + parallelism: parameter.parallelism + template: { + metadata: name: context.name + spec: { + containers: [{ + name: context.name + args: ["echo '" + parameter.dorequest + "'"+ "|"+parameter.vegetacli] + command: ["/bin/sh", "-c"] + image: parameter.image + }] + restartPolicy: parameter.restartPolicy + } + } + } + apiVersion: "batch/v1" + kind: "Job" + } + parameter: { + backofflimit: *0|int + parallelism: *1|int + image:*"quay.io/karansingh/vegeta-ubi"|string + restartPolicy: *"OnFailure"|string + dorequest: string + vegetacli: *"vegeta attack -rate 5000 -duration 10000m | vegeta encode"|string + } +} diff --git a/addons/vegeta/metadata.yaml b/addons/vegeta/metadata.yaml new file mode 100644 index 00000000..b3edabbf --- /dev/null +++ b/addons/vegeta/metadata.yaml @@ -0,0 +1,13 @@ +name: vegeta +version: 12.8.4 +description: Vegeta is a versatile HTTP load testing tool built out of a need to drill HTTP services with a constant request rate. It can be used both as a command line utility and a library. +url: https://github.com/tsenart/vegeta +icon: https://camo.githubusercontent.com/faf9be097f4731212debdd24210c750b2dc276d0a17df19c6a8ac026427c09e9/687474703a2f2f666330392e64657669616e746172742e6e65742f667334392f692f323030392f3139382f632f632f73736a325f7665676574615f62795f7472756e6b7332342e6a7067 + +tags: + - extended_trait + +deployTo: + control_plane: true + +invisible: false diff --git a/addons/vegeta/readme.md b/addons/vegeta/readme.md new file mode 100644 index 00000000..3055d203 --- /dev/null +++ b/addons/vegeta/readme.md @@ -0,0 +1,84 @@ + +# Supported workload type +Vegeta Trait supports following component types: webservice态worker and cloneset. + +# How to start +- Use a component typed webservice to start, keep the following to show-vegeta.yaml, then vela up -f show-vegeta.yaml +```shell +apiVersion: core.oam.dev/v1beta1 +kind: Application +metadata: + name: new-vegeta + namespace: vegeta +spec: + components: + - name: new-vegeta + type: webservice + properties: + exposeType: ClusterIP + image: nginx:latest + ports: + - expose: true + port: 80 + protocol: TCP + ports: 80 + traits: + - type: vegeta + properties: + dorequest: 'GET http://show-vegeta:80' + parallelism: 1 + backofflimit: 10 +``` + +- Check the app status and trait status +```shell +vela ls app -n vegeta +APP COMPONENT TYPE TRAITS PHASE HEALTHY STATUS CREATED-TIME +new-vegeta new-vegeta webservice vegeta running healthy Ready:1/1 2022-05-31 21:24:28 +0800 CST + +vela status new-vegeta -n vegeta +About: + + Name: new-vegeta + Namespace: vegeta + Created at: 2022-05-31 21:24:28 +0800 CST + Status: running + +Workflow: + + mode: DAG + finished: true + Suspend: false + Terminated: false + Steps + - id:rqfzusuxgj + name:new-vegeta + type:apply-component + phase:succeeded + message: + +Services: + + - Name: new-vegeta + Cluster: local Namespace: vegeta + Type: webservice + Healthy Ready:1/1 + Traits: + ? vegeta + +vela logs new-vegeta --name new-vegeta -n vegeta +? You have 2 deployed resources in your app. Please choose one: [Use arrows to move, type to filter] +> Cluster: local | Namespace: vegeta | Kind: Deployment | Name: new-vegeta + Cluster: local | Namespace: vegeta | Kind: Job | Name: new-vegeta + +Choose the Job to show testing data logs +``` + +- If you want a more nice demo, use the two tools: jaggr and jplot to show the data +```shell +kubectl logs new-vegeta--1-qrh67 -n vegeta -f | jaggr @count=rps hist\[100,200,300,400,500\]:code p25,p50,p95:latency sum:bytes_in sum:bytes_out | jplot rps+code.hist.100+code.hist.200+code.hist.300+code.hist.400+code.hist.500 latency.p95+latency.p50+latency.p25 bytes_in.sum+bytes_out.sum +``` + +- How to install jplot and jagrr + - https://github.com/rs/jplot + - https://github.com/rs/jaggr