Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trait pyroscope #363

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions addons/trait-pyroscope/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# 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
```

167 changes: 167 additions & 0 deletions addons/trait-pyroscope/definitions/pyroscope.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
pyroscope: {
annotations: {}
attributes: {
appliesToWorkloads: ["webservice","worker","cloneset"]
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: {}
}
13 changes: 13 additions & 0 deletions addons/trait-pyroscope/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: pyroscope
version: v0.17.1
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

invisible: false
18 changes: 18 additions & 0 deletions addons/vela-prism/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# vela-prism

This addon is for vela-prism


In this addon, the repo is from https://charts.kubevela.net/prism

## install

```shell
vela addon enable vela-prism
```

## uninstall

```shell
vela addon disable vela-prism
```
16 changes: 16 additions & 0 deletions addons/vela-prism/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: vela-prism
version: v1.4.0
description: "Prism provides API Extensions to the core KubeVela. It works as a Kubernetes Aggregated API Server."
icon: "https://github.com/kubevela/prism/blob/master/hack/prism-arch.jpg"
url: "https://github.com/kubevela/prism"

tags:
- vela-prism

deployTo:
control_plane: true

dependencies:
- name: fluxcd

invisible: false
4 changes: 4 additions & 0 deletions addons/vela-prism/resources/parameter.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
parameter: {
"replicacount": *1 | int
"enabled": *true | bool
}
14 changes: 14 additions & 0 deletions addons/vela-prism/resources/vela-prism.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
output: {
type: "helm"
properties: {
repoType: "helm"
url: "https://charts.kubevela.net/prism"
chart: "vela-prism"
values: {
replicaCount: parameter["replicacount"]
secureTLS: {
enabled: parameter["enabled"]
}
}
}
}
6 changes: 6 additions & 0 deletions addons/vela-prism/template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: vela-prism
namespace: vela-system
spec: