Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/dev/preview/portforward-monitoring-satellite.sh
2492 views
1
#!/usr/bin/env bash
2
#
3
# Exposes Prometheus and Grafana's UI
4
#
5
6
if [[ -z "${VM_NAME:-}" ]]; then
7
VM_NAME="$(previewctl get name)"
8
fi
9
10
echo "
11
Starting port-forwarding:
12
13
Prometheus:
14
$(gp url 9090)
15
16
Grafana:
17
$(gp url 3000)
18
19
"
20
21
# This is just a bit of extra safety to ensure that no other port-forwards are running
22
# e.g. maybe you forgot you had it running in another terminal etc.
23
pkill -f "kubectl port-forward (.*)3000:3000"
24
pkill -f "kubectl port-forward (.*)9090:9090"
25
26
# We're using xargs here to run the commands in parallel. This has two benefits as xargs
27
#
28
# 1. Will show the stdout/stderr of both processes, making it easier to diagnose issues
29
# 2. Deals with process termination. If you ^C this script xargs will kill the underlying
30
#. processes.
31
#
32
echo "svc/grafana 3000:3000 svc/prometheus-k8s 9090:9090" | xargs -n 2 -P 2 kubectl port-forward --context="$VM_NAME" -n "monitoring-satellite"
33
34