Mandeep Khinda | f8b8f07 | 2018-04-26 14:35:38 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | usage () { echo "Usage : $0 <namespace> <helm release name>"; } |
| 4 | |
| 5 | READY_JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}' |
| 6 | |
| 7 | NAMESPACE=$1 |
| 8 | RELEASE_NAME=$2 |
| 9 | |
| 10 | if [ ! "$NAMESPACE" ] || [ ! "$RELEASE_NAME" ] |
| 11 | then |
| 12 | usage |
| 13 | exit 1 |
| 14 | fi |
| 15 | |
| 16 | PORTAL_POD_NAME=`kubectl get pods --namespace $NAMESPACE --selector=app=portal-app,release=$RELEASE_NAME \ |
| 17 | -o jsonpath='{.items[*].metadata.name}' -o jsonpath="$READY_JSONPATH" | grep "Ready=True"|awk -F: '{print $1}' ` |
| 18 | SDC_POD_NAME=`kubectl get pods --namespace $NAMESPACE --selector=app=sdc-fe,release=$RELEASE_NAME \ |
| 19 | -o jsonpath='{.items[*].metadata.name}' -o jsonpath="$READY_JSONPATH" | grep "Ready=True" |awk -F: '{print $1}'` |
| 20 | VID_POD_NAME=`kubectl get pods --namespace $NAMESPACE --selector=app=vid,release=$RELEASE_NAME \ |
| 21 | -o jsonpath='{.items[*].metadata.name}' -o jsonpath="$READY_JSONPATH" | grep "Ready=True" |awk -F: '{print $1}'` |
| 22 | POLICY_POD_NAME=`kubectl get pods --namespace $NAMESPACE --selector=app=pap,release=$RELEASE_NAME \ |
| 23 | -o jsonpath='{.items[*].metadata.name}' -o jsonpath="$READY_JSONPATH" | grep "Ready=True" |awk -F: '{print $1}'` |
| 24 | PORTALSDK_POD_NAME=`kubectl get pods --namespace $NAMESPACE --selector=app=portal-sdk,release=$RELEASE_NAME \ |
| 25 | -o jsonpath='{.items[*].metadata.name}' -o jsonpath="$READY_JSONPATH" | grep "Ready=True" |awk -F: '{print $1}'` |
| 26 | |
| 27 | #TODO: Add more as testing progresses |
| 28 | [[ -z "$PORTAL_POD_NAME" ]] && { echo "WARNING: portal-app is not running in your Kubernetes cluster"; } |
| 29 | [[ -z "$SDC_POD_NAME" ]] && { echo "WARNING: sdc-fe is not running in your Kubernetes cluster"; } |
| 30 | [[ -z "$VID_POD_NAME" ]] && { echo "WARNING: vid is not running in your Kubernetes cluster"; } |
| 31 | [[ -z "$POLICY_POD_NAME" ]] && { echo "WARNING: pap is not running in your Kubernetes cluster"; } |
| 32 | [[ -z "$PORTALSDK_POD_NAME" ]] && { echo "WARNING: portal-sdk is not running in your Kubernetes cluster"; } |
| 33 | |
| 34 | if [ ! -z "$PORTAL_POD_NAME" ] |
| 35 | then |
| 36 | kubectl -n $NAMESPACE port-forward "$PORTAL_POD_NAME" 8989:8080 & |
| 37 | PORTAL_PID=$! |
| 38 | fi |
| 39 | |
| 40 | if [ ! -z "$VID_POD_NAME" ] |
| 41 | then |
| 42 | kubectl -n $NAMESPACE port-forward "$VID_POD_NAME" 8080:8080 & |
| 43 | VID_PID=$! |
| 44 | fi |
| 45 | |
| 46 | if [ ! -z "$SDC_POD_NAME" ] |
| 47 | then |
| 48 | kubectl -n $NAMESPACE port-forward "$SDC_POD_NAME" 8181:8181 & |
| 49 | SDC_PID=$! |
| 50 | fi |
| 51 | |
| 52 | if [ ! -z "$POLICY_POD_NAME" ] |
| 53 | then |
| 54 | kubectl -n $NAMESPACE port-forward "$POLICY_POD_NAME" 8443:8443 & |
| 55 | POLICY_PID=$! |
| 56 | fi |
| 57 | |
| 58 | if [ ! -z "$PORTALSDK_POD_NAME" ] |
| 59 | then |
| 60 | kubectl -n $NAMESPACE port-forward "$PORTALSDK_POD_NAME" 8990:8080 & |
| 61 | PORTALSDK_PID=$! |
| 62 | fi |
| 63 | |
| 64 | trap "{ kill -9 $PORTAL_PID $VID_PID $SDC_PID $POLICY_PID $PORTALSDK_PID; exit 0; }" INT |
| 65 | echo -e $'Press Ctrl+C to exit...\n' |
| 66 | |
| 67 | while : |
| 68 | do |
| 69 | sleep 60 |
| 70 | done |