This repository has been archived by the owner on Sep 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-helm.sh
executable file
·122 lines (109 loc) · 3.34 KB
/
build-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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/bash
set -e
stty sane # dont show backspace char during prompts
script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
## Get Project Name
project=$1
if [[ -z "${project}" ]]; then
read -rp "Enter the name for the google cloud project (Ex. switchboard-oracle-cluster): " project
fi
project=$(echo "${project// /-}" | awk '{print tolower($0)}') # Replace spaces with dashes and make lower case
echo -e "project: $project"
envFile="$project.env"
if [ -f "$envFile" ]
then
envFile=$(realpath "${envFile}")
echo "env file: $envFile"
else
echo "failed to find env file: $envFile"
exit 1
fi
set -a
. "$envFile"
set +a
prefix="kubernetes-"
outputPath=$(realpath "$prefix$project")
echo "output path: $outputPath";
mkdir -p "$outputPath"
cp -r "${script_dir}/helm/" "$outputPath/"
files=(
"$outputPath/dashboard.yaml"
"$outputPath/grafana-values.yaml"
"$outputPath/nginx-values.yaml"
"$outputPath/vmetrics-values.yaml"
"$outputPath/switchboard-oracle/values.yaml"
)
if [[ -z "${CLUSTER}" ]]; then
echo "failed to set CLUSTER"
exit 1
elif [[ "$CLUSTER" != "devnet" && "$CLUSTER" != "mainnet-beta" && "$CLUSTER" != "localnet" ]]; then
echo "invalid CLUSTER ($CLUSTER) - [devnet, mainnet-beta, or localnet]"
exit 1
fi
if [[ -z "${RPC_URL}" ]]; then
echo "failed to set RPC_URL"
exit 1
fi
if [[ -z "${WS_URL}" ]]; then
WS_URL=""
fi
if [[ -z "${TASK_RUNNER_SOLANA_RPC}" ]]; then
TASK_RUNNER_SOLANA_RPC="https://api.mainnet-beta.solana.com"
fi
if [[ -z "${ORACLE_KEY}" ]]; then
echo "failed to set ORACLE_KEY"
exit 1
fi
if [[ -z "${HEARTBEAT_INTERVAL}" ]]; then
HEARTBEAT_INTERVAL="15"
fi
if [[ -z "${GOOGLE_PAYER_SECRET_PATH}" ]]; then
echo "failed to set GOOGLE_PAYER_SECRET_PATH"
exit 1
fi
if [[ -z "${GCP_CONFIG_BUCKET}" ]]; then
GCP_CONFIG_BUCKET="oracle-configs:configs.json"
fi
if [[ -z "${SERVICE_ACCOUNT_BASE64}" ]]; then
echo "failed to set SERVICE_ACCOUNT_BASE64"
exit 1
fi
if [[ -z "${EXTERNAL_IP}" ]]; then
echo "failed to set EXTERNAL_IP"
exit 1
fi
if [[ -z "${PAGERDUTY_EVENT_KEY}" ]]; then
PAGERDUTY_EVENT_KEY=""
fi
if [[ -z "${GRAFANA_HOSTNAME}" ]]; then
echo "failed to set GRAFANA_HOSTNAME"
exit 1
fi
if [[ -z "${GRAFANA_ADMIN_PASSWORD}" ]]; then
GRAFANA_ADMIN_PASSWORD="${GRAFANA_ADMIN_PASSWORD:-SbCongraph50!}"
fi
if [[ -z "${GRAFANA_TLS_CRT}" ]]; then
echo "failed to set GRAFANA_TLS_CRT"
exit 1
fi
if [[ -z "${GRAFANA_TLS_KEY}" ]]; then
echo "failed to set GRAFANA_TLS_KEY"
exit 1
fi
if [[ -z "${METRICS_EXPORTER}" ]]; then
METRICS_EXPORTER="${METRICS_EXPORTER:-prometheus}"
elif [[ "$METRICS_EXPORTER" != "prometheus" && "$CLUSTER" != "gcp" && "$CLUSTER" != "opentelemetry-collector" ]]; then
echo "invalid METRICS_EXPORTER ($METRICS_EXPORTER) - [prometheus, gcp, or opentelemetry-collector]"
exit 1
fi
for f in "${files[@]}"; do
PAGERDUTY_EVENT_KEY="$PAGERDUTY_EVENT_KEY" \
METRICS_EXPORTER="$METRICS_EXPORTER" \
GRAFANA_ADMIN_PASSWORD="$GRAFANA_ADMIN_PASSWORD"\
envsubst '$CLUSTER $RPC_URL $WS_URL $TASK_RUNNER_SOLANA_RPC $ORACLE_KEY $HEARTBEAT_INTERVAL $GOOGLE_PAYER_SECRET_PATH $GCP_CONFIG_BUCKET $SERVICE_ACCOUNT_BASE64 $EXTERNAL_IP $PAGERDUTY_EVENT_KEY $GRAFANA_HOSTNAME $GRAFANA_ADMIN_PASSWORD $GRAFANA_TLS_CRT $GRAFANA_TLS_KEY $METRICS_EXPORTER' < "$f" \
| tee "$outputPath/tmp.txt" \
> /dev/null ;
cat "$outputPath/tmp.txt" > "$f";
done
rm "$outputPath/tmp.txt"
exit 0