@leverege/build-tools 2.5.22 → 2.5.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/server/repo-init/config.tgz +0 -0
- package/package.json +3 -3
- package/src/bash-funcs +11 -0
- package/src/helmdn +22 -0
- package/src/helmup +61 -113
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leverege/build-tools",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.23",
|
|
4
4
|
"description": "A collection of build / support tools for Leverege developers",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"ncp": "^2.0.0",
|
|
66
66
|
"npm-check-updates": "^11.1.1",
|
|
67
67
|
"npm-registry-fetch": "^9.0.0",
|
|
68
|
-
"open": "^7.
|
|
68
|
+
"open": "^7.4.0",
|
|
69
69
|
"ora": "^5.3.0",
|
|
70
70
|
"parse-gitignore": "^1.0.1",
|
|
71
71
|
"readline-sync": "^1.4.10",
|
|
@@ -78,6 +78,6 @@
|
|
|
78
78
|
"@babel/node": "^7.12.10",
|
|
79
79
|
"@leverege/babel-preset-leverege-node": "^1.1.1",
|
|
80
80
|
"@leverege/eslint-config-leverege": "^2.2.0",
|
|
81
|
-
"npm": "^
|
|
81
|
+
"npm": "^7.5.2"
|
|
82
82
|
}
|
|
83
83
|
}
|
package/src/bash-funcs
CHANGED
|
@@ -17,6 +17,9 @@ function color() {
|
|
|
17
17
|
esac
|
|
18
18
|
printf "\e[$color$2\e[0m"
|
|
19
19
|
}
|
|
20
|
+
RED_ERROR=`color r '***ERROR:'`
|
|
21
|
+
YELO_WARN="`color y '***WARNING:'`"
|
|
22
|
+
GREEN_INFO=`color g '***INFO:'`
|
|
20
23
|
|
|
21
24
|
function clearlyWarn() {
|
|
22
25
|
[ -z "$1" ] && clear
|
|
@@ -27,6 +30,10 @@ function clearlyWarn() {
|
|
|
27
30
|
CLEARWARN
|
|
28
31
|
}
|
|
29
32
|
|
|
33
|
+
function warnOnError() {
|
|
34
|
+
[ $1 -ne 0 ] && printf "\n$YELO_WARN $2\n"
|
|
35
|
+
}
|
|
36
|
+
|
|
30
37
|
function errorExit() {
|
|
31
38
|
cat <<ERREXIT
|
|
32
39
|
|
|
@@ -36,6 +43,10 @@ ERREXIT
|
|
|
36
43
|
exit 1
|
|
37
44
|
}
|
|
38
45
|
|
|
46
|
+
function exitOnError() {
|
|
47
|
+
[ $1 -ne 0 ] && errorExit $2
|
|
48
|
+
}
|
|
49
|
+
|
|
39
50
|
function yesOrSkipToContinue() {
|
|
40
51
|
printf "\n Enter \"`color g yes`\" ${1}, \"`color y skip`\" to skip this step, or anything else to exit.\n\n"
|
|
41
52
|
read ANS
|
package/src/helmdn
CHANGED
|
@@ -68,12 +68,34 @@ npm run ahoy
|
|
|
68
68
|
|
|
69
69
|
helm repo update # old helm2 => helm search chartmuseum
|
|
70
70
|
|
|
71
|
+
function annihilateMonitoring() {
|
|
72
|
+
# Detect Project ID
|
|
73
|
+
currContext=`kubectl config current-context`
|
|
74
|
+
|
|
75
|
+
IFS='_'
|
|
76
|
+
read -ra ADDR <<< "$currContext"
|
|
77
|
+
|
|
78
|
+
GCP_PROJECT_ID=${ADDR[1]} # project id is the second string split by _
|
|
79
|
+
|
|
80
|
+
kubectl delete sa -n monitoring stackdriver-exporter
|
|
81
|
+
gcloud iam service-accounts delete stackdriver-exporter@${GCP_PROJECT_ID}.iam.gserviceaccount.com --quiet
|
|
82
|
+
|
|
83
|
+
helm repo remove prometheus-community kube-state-metrics && helm repo update
|
|
84
|
+
helm uninstall -n monitoring grafana prometheus stackdriver-exporter elasticsearch-exporter
|
|
85
|
+
helm ls -n monitoring
|
|
86
|
+
}
|
|
87
|
+
|
|
71
88
|
function doNuking() {
|
|
72
89
|
|
|
73
90
|
for PARAM in "$@";
|
|
74
91
|
do
|
|
75
92
|
SERVICE=${PARAM%/} # strip trailing / if it's there
|
|
76
93
|
|
|
94
|
+
if [ "$SERVICE" == "monitoring" ];
|
|
95
|
+
then
|
|
96
|
+
annihilateMonitoring && exit $?
|
|
97
|
+
fi
|
|
98
|
+
|
|
77
99
|
if [ "$SERVICE" == "platform" ];
|
|
78
100
|
then
|
|
79
101
|
doNuking "${PLATFORM[@]}" && exit $?
|
package/src/helmup
CHANGED
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
# for adding / updating deployments on a fluster.
|
|
5
5
|
#
|
|
6
6
|
# printf "\n***** RUNNING LOCALLY *****\n" && sleep 2
|
|
7
|
+
|
|
8
|
+
# Load the standard helper functions
|
|
9
|
+
. `build-tools --bashfun`
|
|
10
|
+
|
|
7
11
|
PLATFORM=(
|
|
8
12
|
authz-server
|
|
9
13
|
api-server
|
|
@@ -29,28 +33,6 @@ SYSTEM=(
|
|
|
29
33
|
monitoring
|
|
30
34
|
)
|
|
31
35
|
|
|
32
|
-
# Simple ANSI color coded string generator.
|
|
33
|
-
function color() {
|
|
34
|
-
local color=
|
|
35
|
-
case "$1" in
|
|
36
|
-
'g') color="92m" ;; # green
|
|
37
|
-
'c') color="96m" ;; # lt blue
|
|
38
|
-
'y') color="93m" ;; # yellow
|
|
39
|
-
'r') color="91m" ;; # red
|
|
40
|
-
'toast') color="1;3;7;91;103;5m" ;;
|
|
41
|
-
esac
|
|
42
|
-
printf "\e[$color$2\e[0m"
|
|
43
|
-
}
|
|
44
|
-
RED_ERROR=`color r '***ERROR:'`
|
|
45
|
-
YELO_WARN="`color y '***WARNING:'`"
|
|
46
|
-
GREEN_INFO=`color g '***INFO:'`
|
|
47
|
-
|
|
48
|
-
function setOrUnset() {
|
|
49
|
-
local setting=`color toast "NEEDS TO BE SET"`
|
|
50
|
-
[ ! -z "$1" ] && setting=`color g $1`
|
|
51
|
-
echo "$setting"
|
|
52
|
-
}
|
|
53
|
-
|
|
54
36
|
function checkTimescalePassword(){
|
|
55
37
|
if [ -f values-databases.yaml ] || [ -d timescale-db ];
|
|
56
38
|
then
|
|
@@ -80,66 +62,18 @@ function generatePassword(){
|
|
|
80
62
|
echo $RANDOMPW
|
|
81
63
|
}
|
|
82
64
|
|
|
83
|
-
function
|
|
84
|
-
|
|
65
|
+
function installMonitoringCharts(){
|
|
66
|
+
# Check the namespace exists in kubernetes
|
|
67
|
+
kubectl get namespace monitoring &> /dev/null
|
|
85
68
|
if [[ $? -eq 1 ]]; then
|
|
86
69
|
printf "\n*** Creating monitoring namespace ***\n\n"
|
|
87
70
|
kubectl create namespace monitoring
|
|
88
71
|
fi
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function upgradeMonitoringCharts(){
|
|
92
|
-
if [[ `git status --porcelain` ]];
|
|
93
|
-
then
|
|
94
|
-
cat<<DIRTYGIT
|
|
95
|
-
|
|
96
|
-
$RED_ERROR This git repo must be clean before we can do the monitoring
|
|
97
|
-
upgrade so either commit or stash and rerun.
|
|
98
|
-
|
|
99
|
-
`git status`
|
|
100
|
-
|
|
101
|
-
DIRTYGIT
|
|
102
|
-
exit 1
|
|
103
|
-
fi
|
|
104
|
-
|
|
105
|
-
if [ -f values-monitoring.yaml ] || [ -d monitoring ];
|
|
106
|
-
then
|
|
107
|
-
rm -rf values-monitoring.yaml monitoring
|
|
108
|
-
git add -A
|
|
109
|
-
fi
|
|
110
72
|
|
|
111
|
-
#
|
|
112
|
-
helm
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
# Make certain the baseline branch is up to date
|
|
117
|
-
git fetch origin ${NEWBASELINE}:${NEWBASELINE}
|
|
118
|
-
|
|
119
|
-
NEWMON="elasticsearch-exporter grafana prometheus stackdriver-exporter"
|
|
120
|
-
for SOURCE in $NEWMON;
|
|
121
|
-
do
|
|
122
|
-
printf "Grabbing $SOURCE from ${NEWBASELINE}\n"
|
|
123
|
-
git checkout --quiet ${NEWBASELINE} $SOURCE
|
|
124
|
-
done
|
|
125
|
-
|
|
126
|
-
cat<<RERUN
|
|
127
|
-
|
|
128
|
-
`git status`
|
|
129
|
-
|
|
130
|
-
$GREEN_INFO Make certain the staged mods to this git repo are committed and
|
|
131
|
-
pushed so things don't get twisted up and sad.
|
|
132
|
-
|
|
133
|
-
$GREEN_INFO Preparing to rerun overwhelm before continuing with the upgrade.
|
|
134
|
-
|
|
135
|
-
Hit return to coninue...
|
|
136
|
-
RERUN
|
|
137
|
-
|
|
138
|
-
read ANS && overwhelm
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
function installMonitoringCharts(){
|
|
142
|
-
upgradeMonitoringCharts
|
|
73
|
+
# Add necessary helm repositories - note that stable is deprecated
|
|
74
|
+
printf "\nAdding and updating helm repositories...\n"
|
|
75
|
+
helm repo add stable https://charts.helm.sh/stable &> /dev/null
|
|
76
|
+
helm repo update
|
|
143
77
|
|
|
144
78
|
## Set the project id by parsing current context
|
|
145
79
|
currContext=`kubectl config current-context`
|
|
@@ -147,49 +81,64 @@ function installMonitoringCharts(){
|
|
|
147
81
|
IFS='_'
|
|
148
82
|
read -ra ADDR <<< "$currContext"
|
|
149
83
|
|
|
150
|
-
|
|
84
|
+
KUBERNETES_ENV=${ADDR[0]} # should be either gke or eks
|
|
151
85
|
|
|
152
86
|
## Installing stackdriver exporter in GKE
|
|
153
|
-
if [[ "$
|
|
154
|
-
|
|
155
|
-
kubectl get sa -n monitoring stackdriver-exporter
|
|
156
|
-
if [[ $? -eq
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
GCP_PROJECT_ID=${ADDR[1]} # project id is the second string split by _
|
|
168
|
-
|
|
169
|
-
# Create GCP SA and bind policies
|
|
170
|
-
printf "\n*** Creating GCP SA with monitoring/viewer ***\n\n"
|
|
171
|
-
gcloud iam service-accounts create stackdriver-exporter --project "$GCP_PROJECT_ID"
|
|
172
|
-
|
|
173
|
-
gcloud projects add-iam-policy-binding "$GCP_PROJECT_ID" \
|
|
174
|
-
--member "serviceAccount:stackdriver-exporter@$GCP_PROJECT_ID.iam.gserviceaccount.com" \
|
|
175
|
-
--role "roles/monitoring.viewer"
|
|
176
|
-
|
|
177
|
-
gcloud iam service-accounts add-iam-policy-binding \
|
|
178
|
-
--role roles/iam.workloadIdentityUser \
|
|
179
|
-
--member "serviceAccount:$GCP_PROJECT_ID.svc.id.goog[monitoring/stackdriver-exporter]" \
|
|
180
|
-
"stackdriver-exporter@$GCP_PROJECT_ID.iam.gserviceaccount.com"
|
|
181
|
-
|
|
182
|
-
# Annotate Kubernetes SA
|
|
183
|
-
kubectl annotate serviceaccount stackdriver-exporter \
|
|
184
|
-
"iam.gke.io/gcp-service-account=stackdriver-exporter@$GCP_PROJECT_ID.iam.gserviceaccount.com" \
|
|
185
|
-
--namespace monitoring
|
|
87
|
+
if [[ "$KUBERNETES_ENV" = "gke" ]];
|
|
88
|
+
then
|
|
89
|
+
kubectl get sa -n monitoring stackdriver-exporter &> /dev/null
|
|
90
|
+
if [[ $? -eq 0 ]];
|
|
91
|
+
then
|
|
92
|
+
cat<<SA_EXISTS
|
|
93
|
+
|
|
94
|
+
The stackdriver-exporter SA already exists which means installing the
|
|
95
|
+
helm chart is going to fail because it wants to manage that aspect of the
|
|
96
|
+
system.
|
|
97
|
+
|
|
98
|
+
SA_EXISTS
|
|
99
|
+
kubectl get sa -n monitoring stackdriver-exporter
|
|
100
|
+
exitOnError 1 "Must remove the SA in order to proceed - `color r DANGER`"
|
|
186
101
|
fi
|
|
187
102
|
|
|
103
|
+
GCP_PROJECT_ID=${ADDR[1]} # project id is the second string split by _
|
|
104
|
+
SDEXP_SA='stackdriver-exporter'
|
|
188
105
|
helm upgrade --install stackdriver-exporter \
|
|
189
106
|
stable/stackdriver-exporter \
|
|
190
107
|
--namespace monitoring \
|
|
191
|
-
|
|
108
|
+
--values stackdriver-exporter/values.yaml \
|
|
192
109
|
--version 1.3.0
|
|
110
|
+
|
|
111
|
+
# Verify the Kubernetes SA
|
|
112
|
+
kubectl get sa -n monitoring $SDEXP_SA
|
|
113
|
+
exitOnError $? "The $SDEXP_SA SA seems to be missing"
|
|
114
|
+
|
|
115
|
+
# NOTE: The k8s SA != GCP SA - the former is created by the helm chart
|
|
116
|
+
# that installs the stackdriver-exporter, the latter is handled here in
|
|
117
|
+
# order to provide the proper IAM permissions to the exporter.
|
|
118
|
+
|
|
119
|
+
# Create GCP SA and bind policies
|
|
120
|
+
printf "\n*** Creating GCP SA with monitoring/viewer ***\n"
|
|
121
|
+
gcloud iam service-accounts create $SDEXP_SA \
|
|
122
|
+
--project "$GCP_PROJECT_ID"
|
|
123
|
+
warnOnError $? "the GCP SA $SDEXP_SA may already exist"
|
|
124
|
+
|
|
125
|
+
printf "\n*** Binding IAM role of monitoring viewer to stackdriver-exporter in $GCP_PROJECT_ID\n"
|
|
126
|
+
gcloud projects add-iam-policy-binding "$GCP_PROJECT_ID" \
|
|
127
|
+
--role "roles/monitoring.viewer" \
|
|
128
|
+
--member "serviceAccount:$SDEXP_SA@$GCP_PROJECT_ID.iam.gserviceaccount.com"
|
|
129
|
+
|
|
130
|
+
printf "\n*** Binding IAM role of workloadIdentityUser to stackdriver-exporter\n"
|
|
131
|
+
gcloud iam service-accounts add-iam-policy-binding \
|
|
132
|
+
--project "$GCP_PROJECT_ID" \
|
|
133
|
+
--role "roles/iam.workloadIdentityUser" \
|
|
134
|
+
--member "serviceAccount:$GCP_PROJECT_ID.svc.id.goog[monitoring/$SDEXP_SA]" \
|
|
135
|
+
"$SDEXP_SA@$GCP_PROJECT_ID.iam.gserviceaccount.com"
|
|
136
|
+
|
|
137
|
+
# Annotate Kubernetes SA
|
|
138
|
+
printf "\n*** Annotating the stackdriver-exporter SA\n"
|
|
139
|
+
kubectl annotate serviceaccount $SDEXP_SA \
|
|
140
|
+
"iam.gke.io/gcp-service-account=$SDEXP_SA@$GCP_PROJECT_ID.iam.gserviceaccount.com" \
|
|
141
|
+
--namespace monitoring
|
|
193
142
|
fi
|
|
194
143
|
|
|
195
144
|
## Install Prometheus
|
|
@@ -458,7 +407,6 @@ function doInstall() {
|
|
|
458
407
|
;;
|
|
459
408
|
|
|
460
409
|
"monitoring")
|
|
461
|
-
checkMonitoringNS
|
|
462
410
|
installMonitoringCharts
|
|
463
411
|
monitoringHelp
|
|
464
412
|
;;
|