Path: blob/main/dev/preview/portforward-monitoring-satellite.sh
2492 views
#!/usr/bin/env bash1#2# Exposes Prometheus and Grafana's UI3#45if [[ -z "${VM_NAME:-}" ]]; then6VM_NAME="$(previewctl get name)"7fi89echo "10Starting port-forwarding:1112Prometheus:13$(gp url 9090)1415Grafana:16$(gp url 3000)1718"1920# This is just a bit of extra safety to ensure that no other port-forwards are running21# e.g. maybe you forgot you had it running in another terminal etc.22pkill -f "kubectl port-forward (.*)3000:3000"23pkill -f "kubectl port-forward (.*)9090:9090"2425# We're using xargs here to run the commands in parallel. This has two benefits as xargs26#27# 1. Will show the stdout/stderr of both processes, making it easier to diagnose issues28# 2. Deals with process termination. If you ^C this script xargs will kill the underlying29#. processes.30#31echo "svc/grafana 3000:3000 svc/prometheus-k8s 9090:9090" | xargs -n 2 -P 2 kubectl port-forward --context="$VM_NAME" -n "monitoring-satellite"323334