-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwrite_frontend_yaml.sh
executable file
·58 lines (55 loc) · 1.71 KB
/
write_frontend_yaml.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
#/bin/bash
TYPE=$1
CONFIG_DIR="../ts-ra-config"
SRC_DIR="../../typescript/ts-reserve-assets/"
FE_PORT=$(cat ${SRC_DIR}/package.json | jq --raw-output .config.${TYPE})
echo FE_PORT is $FE_PORT
VITE_TYPE=$(jq '.ITEM_NAME' ${CONFIG_DIR}/config.${TYPE}.json)
echo vite_type is $VITE_TYPE
MK=$(which minikube)
if [ $MK ]; then
echo "HAVE minikube";
MKURL=$(minikube service ${TYPE}-backend --url)
echo MKURL is $MKURL
END_POINT=$(echo ${MKURL} | awk -F '//' '{print $2}')
echo endpoint is $END_POINT
END_POINT_IP=$(echo ${END_POINT} | awk -F: '{print $1}')
echo endpoint_ip is $END_POINT_IP
END_POINT_PORT=$(echo ${END_POINT} | awk -F: '{print $2}')
echo endpoint_port is $END_POINT_PORT
else
INGRESS=$(kubectl describe service/${TYPE}-backend | grep ^LoadBa | awk '{print $NF}')
END_POINTS=$(kubectl describe service/${TYPE}-backend | grep ^Endpoints: | awk '{print $NF}')
echo endpoints is $END_POINTS
END_POINT_IP=$INGRESS
# END_POINT_IP=$(echo ${END_POINTS} | awk -F: '{print $1}')
echo endpoint_ip is $END_POINT_IP
END_POINT_PORT=$(echo ${END_POINTS} | awk -F: '{print $2}')
echo endpoint_port is $END_POINT_PORT
fi
cat << EOF > ${TYPE}-frontend.yaml
---
apiVersion: v1
kind: Pod
metadata:
name: ${TYPE}-frontend
labels:
app: web
spec:
containers:
- name: ${TYPE}-frontend
image: robertwilkinsonwork299/reserve-assets-${TYPE}-frontend
ports:
- containerPort: ${FE_PORT}
env:
- name: SSL_CERT
value: /certs/localhost.crt
- name: SSL_KEY
value: /certs/localhost.key
- name: VITE_API_IP
value: "${END_POINT_IP}"
- name: VITE_API_PORT
value: "${END_POINT_PORT}"
- name: VITE_TYPE
value: ${VITE_TYPE}
EOF