Skip to content

Commit

Permalink
Trait:vegeta (#359)
Browse files Browse the repository at this point in the history
Signed-off-by: Xueliang Yang <[email protected]>
  • Loading branch information
oeular authored Jun 2, 2022
1 parent 8eb2a12 commit 1cba0fa
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 8 deletions.
16 changes: 8 additions & 8 deletions addons/fluxcd/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
48 changes: 48 additions & 0 deletions addons/vegeta/definitions/vegeta.cue
Original file line number Diff line number Diff line change
@@ -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
}
}
13 changes: 13 additions & 0 deletions addons/vegeta/metadata.yaml
Original file line number Diff line number Diff line change
@@ -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
84 changes: 84 additions & 0 deletions addons/vegeta/readme.md
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1cba0fa

Please sign in to comment.