blob: d9f64c121be2056c1cfaab6dd247f7db21a9d47e [file] [log] [blame]
Mandeep Khindaf8b8f072018-04-26 14:35:38 +00001#!/bin/bash
2
3usage () { echo "Usage : $0 <namespace> <helm release name>"; }
4
5READY_JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'
6
7NAMESPACE=$1
8RELEASE_NAME=$2
9
10if [ ! "$NAMESPACE" ] || [ ! "$RELEASE_NAME" ]
11then
12 usage
13 exit 1
14fi
15
16PORTAL_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}' `
18SDC_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}'`
20VID_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}'`
22POLICY_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}'`
24PORTALSDK_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
34if [ ! -z "$PORTAL_POD_NAME" ]
35then
36 kubectl -n $NAMESPACE port-forward "$PORTAL_POD_NAME" 8989:8080 &
37 PORTAL_PID=$!
38fi
39
40if [ ! -z "$VID_POD_NAME" ]
41then
42 kubectl -n $NAMESPACE port-forward "$VID_POD_NAME" 8080:8080 &
43 VID_PID=$!
44fi
45
46if [ ! -z "$SDC_POD_NAME" ]
47then
48 kubectl -n $NAMESPACE port-forward "$SDC_POD_NAME" 8181:8181 &
49 SDC_PID=$!
50fi
51
52if [ ! -z "$POLICY_POD_NAME" ]
53then
54 kubectl -n $NAMESPACE port-forward "$POLICY_POD_NAME" 8443:8443 &
55 POLICY_PID=$!
56fi
57
58if [ ! -z "$PORTALSDK_POD_NAME" ]
59then
60 kubectl -n $NAMESPACE port-forward "$PORTALSDK_POD_NAME" 8990:8080 &
61 PORTALSDK_PID=$!
62fi
63
64trap "{ kill -9 $PORTAL_PID $VID_PID $SDC_PID $POLICY_PID $PORTALSDK_PID; exit 0; }" INT
65echo -e $'Press Ctrl+C to exit...\n'
66
67while :
68do
69 sleep 60
70done