#!/bin/bash
REDIRECT_OUTPUT=true

while getopts "q" opt; do
    case $opt in
        q)
            REDIRECT_OUTPUT=false
            ;;
        *)
            ;;
    esac
done

if $REDIRECT_OUTPUT; then
    REDIRECT="1>/dev/null 2>&1"
else
    REDIRECT=""
fi

POD_NAME=$(kubectl get pods -n monitoring -l app=chronograf -o jsonpath="{.items[0].metadata.name}")
kubectl port-forward --address 127.0.0.1 --request-timeout=0 -n monitoring $POD_NAME 8888:8888 $REDIRECT