summaryrefslogtreecommitdiffstats
path: root/kubernetes/portal/launch-onap-portal.sh
blob: d9f64c121be2056c1cfaab6dd247f7db21a9d47e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash

usage () { echo "Usage : $0 <namespace> <helm release name>"; }

READY_JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'

NAMESPACE=$1
RELEASE_NAME=$2

if [ ! "$NAMESPACE" ] || [ ! "$RELEASE_NAME" ]
then
  usage
  exit 1
fi

PORTAL_POD_NAME=`kubectl get pods --namespace $NAMESPACE --selector=app=portal-app,release=$RELEASE_NAME \
-o jsonpath='{.items[*].metadata.name}' -o jsonpath="$READY_JSONPATH" | grep "Ready=True"|awk -F: '{print $1}' `
SDC_POD_NAME=`kubectl get pods --namespace $NAMESPACE --selector=app=sdc-fe,release=$RELEASE_NAME \
-o jsonpath='{.items[*].metadata.name}' -o jsonpath="$READY_JSONPATH" | grep "Ready=True" |awk -F: '{print $1}'`
VID_POD_NAME=`kubectl get pods --namespace $NAMESPACE --selector=app=vid,release=$RELEASE_NAME \
-o jsonpath='{.items[*].metadata.name}' -o jsonpath="$READY_JSONPATH" | grep "Ready=True" |awk -F: '{print $1}'`
POLICY_POD_NAME=`kubectl get pods --namespace $NAMESPACE --selector=app=pap,release=$RELEASE_NAME \
-o jsonpath='{.items[*].metadata.name}' -o jsonpath="$READY_JSONPATH" | grep "Ready=True" |awk -F: '{print $1}'`
PORTALSDK_POD_NAME=`kubectl get pods --namespace $NAMESPACE --selector=app=portal-sdk,release=$RELEASE_NAME \
-o jsonpath='{.items[*].metadata.name}' -o jsonpath="$READY_JSONPATH" | grep "Ready=True" |awk -F: '{print $1}'`

#TODO: Add more as testing progresses
[[ -z "$PORTAL_POD_NAME" ]] && { echo "WARNING: portal-app is not running in your Kubernetes cluster"; }
[[ -z "$SDC_POD_NAME" ]] && { echo "WARNING: sdc-fe is not running in your Kubernetes cluster"; }
[[ -z "$VID_POD_NAME" ]] && { echo "WARNING: vid is not running in your Kubernetes cluster"; }
[[ -z "$POLICY_POD_NAME" ]] && { echo "WARNING: pap is not running in your Kubernetes cluster"; }
[[ -z "$PORTALSDK_POD_NAME" ]] && { echo "WARNING: portal-sdk is not running in your Kubernetes cluster"; }

if [ ! -z "$PORTAL_POD_NAME" ]
then
  kubectl -n $NAMESPACE port-forward "$PORTAL_POD_NAME" 8989:8080 &
  PORTAL_PID=$!
fi

if [ ! -z "$VID_POD_NAME" ]
then
  kubectl -n $NAMESPACE port-forward "$VID_POD_NAME" 8080:8080 &
  VID_PID=$!
fi

if [ ! -z "$SDC_POD_NAME" ]
then
  kubectl -n $NAMESPACE port-forward "$SDC_POD_NAME" 8181:8181 &
  SDC_PID=$!
fi

if [ ! -z "$POLICY_POD_NAME" ]
then
  kubectl -n $NAMESPACE port-forward "$POLICY_POD_NAME" 8443:8443 &
  POLICY_PID=$!
fi

if [ ! -z "$PORTALSDK_POD_NAME" ]
then
  kubectl -n $NAMESPACE port-forward "$PORTALSDK_POD_NAME" 8990:8080 &
  PORTALSDK_PID=$!
fi

trap "{ kill -9 $PORTAL_PID $VID_PID $SDC_PID $POLICY_PID $PORTALSDK_PID; exit 0; }" INT
echo -e $'Press Ctrl+C to exit...\n'

while :
do
  sleep 60
done