Skip to content

Commit

Permalink
trait:pyroscope
Browse files Browse the repository at this point in the history
Signed-off-by: Xueliang Yang <[email protected]>
  • Loading branch information
oeular committed Jun 5, 2022
1 parent d969987 commit 27ee20c
Show file tree
Hide file tree
Showing 3 changed files with 281 additions and 0 deletions.
99 changes: 99 additions & 0 deletions addons/trait-pyroscope/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# pyroscope

This addon is for pyroscope


In this addon, the repo is from https://github.com/pyroscope-io/pyroscope

## install

```shell
vela addon enable pyroscope
```

## uninstall

```shell
vela addon disable pyroscope
```

# Supported workload type
Pyroscope Trait supports following component types: webservice、worker and cloneset.

# How to start
- Use a component typed webservice to start, keep the following to app-demo.yaml, then vela up -f app-demo.yaml
```shell
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: app-show
namespace: real-new-ns
spec:
components:
- name: web-show
type: webservice
properties:
exposeType: ClusterIP
image: beellzrocks/shippingservice
env:
- name: PORT
value: "50051"
- name: APPLICATION_NAME # Application name shown in the Pyroscope UI
value: "web-show"
- name: SERVER_ADDRESS # To change Pyroscope Server Port change the value, the naming rule is pyroscope-<component name>
value: "http://pyroscope-web-show:4040"
traits:
- type: pyroscope
```
- Check the app status
```shell
vela ls -n real-new-ns
APP COMPONENT TYPE TRAITS PHASE HEALTHY STATUS CREATED-TIME
app-show web-show webservice pyroscope running healthy Ready:1/1 2022-06-03 19:41:05 +0800 CST

vela status app-show -n real-new-ns
About:

Name: app-show
Namespace: real-new-ns
Created at: 2022-06-03 19:41:05 +0800 CST
Status: running

Workflow:

mode: DAG
finished: true
Suspend: false
Terminated: false
Steps
- id:zsbjvp7fg5
name:web-show
type:apply-component
phase:succeeded
message:

Services:

- Name: web-show
Cluster: local Namespace: real-new-ns
Type: webservice
Healthy Ready:1/1
Traits:
? pyroscope
```

- Use the port-forward to visit the pyroscope UI
```shell
vela port-forward app-show 8080:4040 -n real-new-ns
? You have 3 deployed resources in your app. Please choose one: Cluster: local | Namespace: real-new-ns | Kind: Service | Name: pyroscope-web-show
Forwarding from 127.0.0.1:8080 -> 4040
Forwarding from [::1]:8080 -> 4040

Forward successfully! Opening browser ...

Failed to open browser: exec: "xdg-open": executable file not found in $PATHHandling connection for 8080
Handling connection for 8080

Then you can visit the http://<your ip>:8080 in the browser
```

15 changes: 15 additions & 0 deletions addons/trait-pyroscope/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: pyroscope
description: "Continuous Profiling Platform. Debug performance issues down to a single line of code"
icon: "https://user-images.githubusercontent.com/662636/105129037-11334180-5a99-11eb-8951-1d4aaaed50de.png"
url: "https://github.com/pyroscope-io/pyroscope"

tags:
- extended_trait

deployTo:
control_plane: true

dependencies:
- name: fluxcd

invisible: false
167 changes: 167 additions & 0 deletions addons/trait-pyroscope/resources/pyroscope.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
pyroscope: {
annotations: {}
attributes: {
appliesToWorkloads: ["*"]
conflictsWith: []
podDisruptive: false
workloadRefPath: ""
}
description: ""
labels: {}
type: "trait"
}

template: {
outputs:
"pyroscope-deployment":{
metadata: {
name: "pyroscope-"+context.name
labels: {
"app.kubernetes.io/instance": "pyroscope-"+context.name
"app.kubernetes.io/name": "pyroscope-"+context.name
"app.kubernetes.io/version": "0.17.1"
}
namespace: context.namespace
}
spec: {
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector: matchLabels: {
"app.kubernetes.io/instance": "pyroscope-"+context.name
"app.kubernetes.io/name": "pyroscope-"+context.name
}
strategy: type: "Recreate"
template: {
metadata: {
labels: {
"app.kubernetes.io/instance": "pyroscope-"+context.name
"app.kubernetes.io/name": "pyroscope-"+context.name
}
creationTimestamp: null
}
spec: {
securityContext: fsGroup: 101
containers: [{
name: "pyroscope-"+context.name
args: ["server", "-config", "/tmp/config.yaml"]
image: "pyroscope/pyroscope:0.17.1"
imagePullPolicy: "IfNotPresent"
livenessProbe: {
failureThreshold: 3
httpGet: {
path: "/healthz"
port: 4040
scheme: "HTTP"
}
initialDelaySeconds: 30
periodSeconds: 15
successThreshold: 1
timeoutSeconds: 30
}
ports: [{
name: "api"
containerPort: 4040
protocol: "TCP"
}]
readinessProbe: {
failureThreshold: 3
httpGet: {
path: "/healthz"
port: 4040
scheme: "HTTP"
}
initialDelaySeconds: 30
periodSeconds: 5
successThreshold: 1
timeoutSeconds: 30
}
resources: {}
securityContext: {}
terminationMessagePath: "/dev/termination-log"
terminationMessagePolicy: "File"
volumeMounts: [{
name: "config"
mountPath: "/tmp/config.yaml"
subPath: "config.yaml"
}]
}]
dnsPolicy: "ClusterFirst"
restartPolicy: "Always"
schedulerName: "default-scheduler"
serviceAccount: "pyroscope-"+context.name
serviceAccountName: "pyroscope-"+context.name
terminationGracePeriodSeconds: 30
volumes: [{
name: "config"
configMap: {
name: "pyroscope-"+context.name
defaultMode: 420
}
}]
}
}
}
apiVersion: "apps/v1"
kind: "Deployment"
}
outputs:
"pyroscope-cm":{
apiVersion: "v1"
data: "config.yaml": """
{}
"""
kind: "ConfigMap"
metadata: {
name: "pyroscope-"+context.name
labels: {
"app.kubernetes.io/instance": "pyroscope-"+context.name
"app.kubernetes.io/name": "pyroscope-"+context.name
}
namespace: context.namespace
}
}
outputs:
"pyroscope-svc":{
apiVersion: "v1"
kind: "Service"
metadata: {
name: "pyroscope-"+context.name
labels: {
"app.kubernetes.io/instance": "pyroscope-"+context.name
"app.kubernetes.io/name": "pyroscope-"+context.name
}
namespace: context.namespace
}
spec: {
ports: [{
name: "http"
port: 4040
protocol: "TCP"
targetPort: "api"
}]
selector: {
"app.kubernetes.io/instance": "pyroscope-"+context.name
"app.kubernetes.io/name": "pyroscope-"+context.name
}
sessionAffinity: "None"
type: "ClusterIP"
}
}

outputs:
"pyroscope-sa": {
apiVersion: "v1"
kind: "ServiceAccount"
metadata: {
name: "pyroscope-"+context.name
labels: {
"app.kubernetes.io/instance": "pyroscope-"+context.name
"app.kubernetes.io/name": "pyroscope-"+context.name
}
namespace: context.namespace
}
}
parameter: {}
}

0 comments on commit 27ee20c

Please sign in to comment.