Skip to content
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
40 changes: 28 additions & 12 deletions images/virtualization-artifact/Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,21 +111,37 @@ tasks:
- _ensure:mirrord
cmd: ./hack/mirrord.sh wipe --deployment=virtualization-api --namespace={{ .BaseNamespace }}

pyroscope:local:run:controller:
desc: "Run pyroscope locally for virtualization-controller"
cmd: ./hack/pyroscope.sh run --namespace={{ .BaseNamespace }} --service=virtualization-controller --port=8081
pyroscope:local:start:pyroscope-only:
desc: "Start pyroscope only"
cmd: ./hack/pyroscope.sh start-pyroscope

pyroscope:local:wipe:controller:
desc: "Wipe local pyroscope for virtualization-controller"
cmd: ./hack/pyroscope.sh wipe --namespace={{ .BaseNamespace }}
pyroscope:local:stop:pyroscope-only:
desc: "Stop pyroscope only"
cmd: ./hack/pyroscope.sh stop-pyroscope

pyroscope:local:run:vm-route-forge:
desc: "Run pyroscope locally for vm-route-forge"
cmd: ./hack/pyroscope.sh run --namespace={{ .BaseNamespace }} --service=vm-route-forge --port=8119
pyroscope:local:wipe-data:
desc: "Wipe local pyroscope data"
cmd: ./hack/pyroscope.sh wipe-data

pyroscope:local:wipe:vm-route-forge:
desc: "Wipe local pyroscope for vm-route-forge"
cmd: ./hack/pyroscope.sh wipe --namespace={{ .BaseNamespace }}
pyroscope:local:info-data:
desc: "Show local pyroscope data info"
cmd: ./hack/pyroscope.sh info-data

pyroscope:local:start:controller:
desc: "Start pyroscope locally for virtualization-controller"
cmd: ./hack/pyroscope.sh start --namespace={{ .BaseNamespace }} --service=virtualization-controller --port=8081

pyroscope:local:stop:controller:
desc: "Stop local pyroscope for virtualization-controller"
cmd: ./hack/pyroscope.sh stop --namespace={{ .BaseNamespace }}

pyroscope:local:start:vm-route-forge:
desc: "Start pyroscope locally for vm-route-forge"
cmd: ./hack/pyroscope.sh start --namespace={{ .BaseNamespace }} --service=vm-route-forge --port=8119

pyroscope:local:stop:vm-route-forge:
desc: "Stop local pyroscope for vm-route-forge"
cmd: ./hack/pyroscope.sh stop --namespace={{ .BaseNamespace }}

dlv:build:controller:
desc: "Build image virtualization-controller with dlv"
Expand Down
69 changes: 53 additions & 16 deletions images/virtualization-artifact/hack/pyroscope.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,31 @@ function usage {
Usage: $0 COMMAND OPTIONS

Commands:
run Run pyroscope.
Flags:
--namespace,-n (required) Namespace of application.
--service,-s (required) Connecting service.
--port,-p (required) Connecting port service.
start Start pyroscope and alloy.
Flags:
--namespace,-n (required) Namespace of application.
--service,-s (required) Connecting service.
--port,-p (required) Connecting port service.

wipe Stop and cleanup.
stop Stop pyroscope and alloy.
wipe-data Wipe pyroscope data.
info-data Show pyroscope data info.

start-pyroscope Start pyroscope only.
stop-pyroscope Stop pyroscope only.

Examples:
# Run"
$(basename "$0") run --service="your service" --port="your service port" --namespace="your namespace"
# Wipe"
$(basename "$0") wipe
# Start"
$(basename "$0") start --service="your service" --port="your service port" --namespace="your namespace"
# Stop"
$(basename "$0") stop
EOF
}

DIR="$(dirname "$0")"
DOCKER_COMPOSE_FILE="${DIR}/pyroscope/docker-compose.yaml"
DOCKER_COMPOSE_FILE_PYROSCOPE_ONLY="${DIR}/pyroscope/docker-compose-pyroscope-only.yaml"
PYROSCOPE_VOLUME_NAME="pyroscope_pyroscope-data"
PYROSCOPE_PORT="8081"
PROCESS_NAME="PyroscopePortForward"

Expand All @@ -49,7 +56,7 @@ function usage_exit {
exit "$rc"
}

function run() {
function start() {
if [[ -z $NAMESPACE ]] || [[ -z $SERVICE ]] || [[ -z $PORT ]]; then
usage_exit 1
fi
Expand All @@ -60,11 +67,27 @@ function run() {
docker compose -f "${DOCKER_COMPOSE_FILE}" up -d
}

function wipe() {
function stop() {
docker compose -f "${DOCKER_COMPOSE_FILE}" down
pkill -f "${PROCESS_NAME}"
}

function wipe-data() {
docker volume rm "${PYROSCOPE_VOLUME_NAME}"
}

function info-data() {
docker volume inspect "${PYROSCOPE_VOLUME_NAME}"
}

function start-pyroscope() {
docker compose -f "${DOCKER_COMPOSE_FILE_PYROSCOPE_ONLY}" up -d
}

function stop-pyroscope() {
docker compose -f "${DOCKER_COMPOSE_FILE_PYROSCOPE_ONLY}" down
}

source "${DIR}/args.sh"
set_flags_args "$@"

Expand All @@ -80,13 +103,27 @@ docker compose version &>/dev/null || (echo "No docker compose found" ; exit 1 )

CMD="${ARGS[0]}"
case "$CMD" in
"run")
run
"start")
start
echo "Pyroscope launched successfully."
echo "Open http://localhost:4040 in your browser."
;;
"stop")
stop
;;
"wipe-data")
wipe-data
;;
"info-data")
info-data
;;
"start-pyroscope")
start-pyroscope
echo "Pyroscope launched successfully."
echo "Open http://localhost:4040 in your browser."
;;
"wipe")
wipe
"stop-pyroscope")
stop-pyroscope
;;
*)
usage_exit 1
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
services:
pyroscope:
image: grafana/pyroscope:1.5.0
ports:
- "4040:4040"
command: ["server"]
volumes:
- "pyroscope-data:/data"

volumes:
pyroscope-data:
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ services:
ports:
- "4040:4040"
command: ["server"]
volumes:
- "pyroscope-data:/data"

volumes:
pyroscope-data:
Loading