forked from EVOLVED-5G/NEF_emulator
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun-helm.sh
executable file
·65 lines (55 loc) · 2.48 KB
/
run-helm.sh
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
NAMESPACE=nef
RELEASE=nef
DOCKER_REGISTRY=localhost:5000
# help
for arg in "$@"; do
if [ "$arg" == "--help" ]; then
echo "Usage: cmd [-n NAMESPACE] [-r RELEASE] [-d DOCKER_REGISTRY] [--help]"
exit 0
fi
done
# get opts
while getopts "n:r:d" opt; do
case ${opt} in
n )
NAMESPACE=$OPTARG
;;
r )
RELEASE=$OPTARG
;;
d )
DOCKER_REGISTRY=$OPTARG
;;
\? )
echo "Invalid option: -$OPTARG" >&2
echo "Usage: cmd [-n NAMESPACE] [-r RELEASE] [-d DOCKER_REGISTRY] [--help]"
exit 1
;;
esac
done
kubectl create namespace $NAMESPACE
docker build -t $DOCKER_REGISTRY/backend -f backend/Dockerfile.backend --build-arg INSTALL_DEV=${INSTALL_DEV:-true} --build-arg INSTALL_JUPYTER=${INSTALL_JUPYTER:-true} backend
docker push $DOCKER_REGISTRY/backend
docker build -t $DOCKER_REGISTRY/report -f backend/Dockerfile.report --build-arg INSTALL_DEV=${INSTALL_DEV:-true} --build-arg INSTALL_JUPYTER=${INSTALL_JUPYTER:-true} backend
docker push $DOCKER_REGISTRY/report
helm -n $NAMESPACE upgrade --wait --install $RELEASE helm-chart --set backend.deployment.image=$DOCKER_REGISTRY/backend:latest --set report.deployment.image=$DOCKER_REGISTRY/report:latest
# get the external IP address of the service nef-backend if it exists, otherwise the cluster IP
NEF_BACKEND_IP=$(kubectl get svc $RELEASE-backend -n $NAMESPACE -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
if [ -z "$NEF_BACKEND_IP" ]; then
NEF_BACKEND_IP=$(kubectl get svc $RELEASE-backend -n $NAMESPACE -o jsonpath='{.spec.clusterIP}')
fi
# Get the service port
NEF_BACKEND_PORT=$(kubectl get svc $RELEASE-backend -n $NAMESPACE -o jsonpath='{.spec.ports[0].port}')
# Get the report service port
NEF_REPORT_PORT=$(kubectl get svc $RELEASE-report -n $NAMESPACE -o jsonpath='{.spec.ports[0].port}')
# Get the super user name and password
FIRST_SUPERUSER="$(kubectl get configmap $RELEASE-nef-config -n $NAMESPACE -o jsonpath='{.data.FIRST_SUPERUSER}')"
FIRST_SUPERUSER_PASSWORD="$(kubectl get secret $RELEASE-nef-secrets -n $NAMESPACE -o jsonpath='{.data.FIRST_SUPERUSER_PASSWORD}' | base64 -d)"
# Run the script to create the data
bash backend/app/app/db/init_simple.sh -h "http://$NEF_BACKEND_IP" -p "$NEF_BACKEND_PORT" -r "$NEF_REPORT_PORT" -u "$FIRST_SUPERUSER" -s "$FIRST_SUPERUSER_PASSWORD"
# echo the variables
printf "\n\n"
echo "NEF IP: $NEF_BACKEND_IP"
echo "NEF port: $NEF_BACKEND_PORT"
echo "Super user name: $FIRST_SUPERUSER"
echo "Super user password: $FIRST_SUPERUSER_PASSWORD"