@leverege/build-tools 2.14.1 → 2.15.0

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.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leverege/build-tools",
3
- "version": "2.14.1",
3
+ "version": "2.15.0",
4
4
  "description": "A collection of build / support tools for Leverege developers",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -61,21 +61,21 @@
61
61
  "inquirer": "^8.2.4",
62
62
  "js-yaml": "^4.1.0",
63
63
  "ncp": "^2.0.0",
64
- "npm-check-updates": "^13.1.1",
64
+ "npm-check-updates": "^13.1.2",
65
65
  "npm-registry-fetch": "^11.0.0",
66
66
  "open": "^8.4.0",
67
67
  "ora": "^5.4.1",
68
68
  "parse-gitignore": "^1.0.1",
69
69
  "readline-sync": "^1.4.10",
70
70
  "semver": "^7.3.7",
71
- "simple-git": "^3.7.1"
71
+ "simple-git": "^3.9.0"
72
72
  },
73
73
  "devDependencies": {
74
74
  "@babel/cli": "^7.17.10",
75
- "@babel/core": "^7.18.2",
76
- "@babel/node": "^7.17.10",
75
+ "@babel/core": "^7.18.5",
76
+ "@babel/node": "^7.18.5",
77
77
  "@leverege/babel-preset-leverege-node": "^2.0.0",
78
78
  "@leverege/eslint-config-leverege": "^3.0.1",
79
- "npm": "^8.12.1"
79
+ "npm": "^8.12.2"
80
80
  }
81
81
  }
package/src/bash-funcs CHANGED
@@ -95,6 +95,8 @@ INSTALLING
95
95
  }
96
96
 
97
97
  function addHelmRepo() {
98
+ [ ! -z "$HELM_REPO_SKIP" ] && return
99
+
98
100
  local chart=$1
99
101
  local url=$2
100
102
 
@@ -107,5 +109,6 @@ REPOADD
107
109
  }
108
110
 
109
111
  function removeHelmRepo(){
112
+ [ ! -z "$HELM_REPO_SKIP" ] && return
110
113
  helm repo remove $1 &>/dev/null
111
114
  }
package/src/helmdn CHANGED
@@ -52,6 +52,7 @@ PLATFORM=(
52
52
  scheduler
53
53
  transponder-bq
54
54
  transponder-postgres
55
+ transponder-tsdb
55
56
  transponder-rt
56
57
  )
57
58
 
package/src/helmup CHANGED
@@ -8,7 +8,7 @@
8
8
  # Load the standard helper functions
9
9
  . `build-tools --bashfun`
10
10
 
11
- HELMUP_ARGS=("$*")
11
+ SHELMUP_ARGS=("$*")
12
12
 
13
13
  # removed geotile-server from standard platform 3/20/22 - low usage
14
14
  PLATFORM=(
@@ -25,6 +25,7 @@ PLATFORM=(
25
25
  transponder-bq
26
26
  transponder-rt
27
27
  transponder-postgres
28
+ transponder-tsdb
28
29
  )
29
30
 
30
31
  SYSTEM=(
@@ -59,6 +60,52 @@ CATNAMI
59
60
  addHelmRepo bitnami $BITNAMI_URL
60
61
  }
61
62
 
63
+ function getProjectIdFromK8sContext() {
64
+ local currContext=`kubectl config current-context`
65
+
66
+ IFS='_'
67
+ read -ra ADDR <<< "$currContext"
68
+
69
+ echo ${ADDR[1]} # project id is the second string split by _
70
+ }
71
+
72
+ function bindWorkloadIdentity(){
73
+ PROJECT_ID=$(getProjectIdFromK8sContext)
74
+ SVC_ACCT=$1
75
+ NAMESPACE=$2
76
+ SVC_ACCT_EMAIL="${SVC_ACCT}@${PROJECT_ID}.iam.gserviceaccount.com"
77
+
78
+ cat<<WORKLOAD_ID
79
+ Binding workload identity IAM policy
80
+ Service Account : `color g $SVC_ACCT`
81
+ Project : `color g $PROJECT_ID`
82
+ Namespace : `color g $NAMESPACE`
83
+ Service Email : `color g $SVC_ACCT_EMAIL`
84
+
85
+ WORKLOAD_ID
86
+
87
+ gcloud iam service-accounts add-iam-policy-binding \
88
+ --project $PROJECT_ID \
89
+ --member "serviceAccount:$PROJECT_ID.svc.id.goog[${NAMESPACE}/${SVC_ACCT}]" \
90
+ --role roles/iam.workloadIdentityUser $SVC_ACCT_EMAIL
91
+ warnOnError $? "gcloud workload identity binding may have failed"
92
+
93
+ # Verify the Kubernetes SA and create it if necessary
94
+ printf "\nChecking for the $NAMESPACE/#SVC_ACCT k8s SA\n"
95
+ kubectl get sa -n $NAMESPACE $SVC_ACCT
96
+ if [[ $? -eq 1 ]];
97
+ then
98
+ printf "Creating the k8s SA $NAMESPACE/@$SVC_ACCT\n"
99
+ kubectl create sa -n $NAMESPACE $SVC_ACCT
100
+ fi
101
+
102
+ printf "\nAnnotating the k8s SA $NAMESPACE/@$SVC_ACCT\n"
103
+ kubectl annotate serviceaccount $SVC_ACCT \
104
+ --namespace $NAMESPACE --overwrite \
105
+ "iam.gke.io/gcp-service-account=$SVC_ACCT_EMAIL"
106
+ warnOnError $? "Failed to annotate service account $NAMESPACE/$SVC_ACCT - things may fail"
107
+ }
108
+
62
109
  function checkTimescalePassword(){
63
110
  kubectl get secret postgresql-password
64
111
  if [[ $? -eq 1 ]]; then
@@ -90,8 +137,20 @@ function createNamespaceIfNeeded(){
90
137
  fi
91
138
  }
92
139
 
140
+ function installPrometheus() {
141
+ # Add the community helm repositories
142
+ addHelmRepo prometheus-community https://prometheus-community.github.io/helm-charts
143
+
144
+ helm upgrade --install prometheus prometheus-community/prometheus \
145
+ --namespace monitoring \
146
+ --values prometheus/values.yaml \
147
+ --version 13
148
+
149
+ # removeHelmRepo prometheus-community
150
+ }
151
+
93
152
  function installMonitoringCharts(){
94
- showInstalling "Grafana Monitoring"
153
+ showInstalling "Monitoring Components"
95
154
  createNamespaceIfNeeded monitoring
96
155
 
97
156
  # Add necessary helm repositories - note that stable is deprecated
@@ -102,8 +161,8 @@ function installMonitoringCharts(){
102
161
 
103
162
  IFS='_'
104
163
  read -ra ADDR <<< "$currContext"
105
-
106
164
  KUBERNETES_ENV=${ADDR[0]} # should be either gke or eks
165
+ GCP_PROJECT_ID=${ADDR[1]} # project id is the second string split by _
107
166
 
108
167
  ## Installing stackdriver exporter in GKE
109
168
  if [[ "$KUBERNETES_ENV" = "gke" ]];
@@ -115,28 +174,16 @@ function installMonitoringCharts(){
115
174
 
116
175
  The stackdriver-exporter SA already exists which means installing the
117
176
  helm chart is going to fail because it wants to manage that aspect of the
118
- system.
177
+ system. This most likely because the stackdriver exporter is already
178
+ installed and running. Run the following helm command to uninstall first:
179
+
180
+ `color y "overwhelm && helm uninstall -n monitoring stackdriver-exporter"`
119
181
 
120
182
  SA_EXISTS
121
- kubectl get sa -n monitoring stackdriver-exporter
122
- exitOnError 1 "Must remove the SA in order to proceed - `color r DANGER`"
183
+ exitOnError 1 "uninstall the existing deployment in order to proceed"
123
184
  fi
124
185
 
125
- GCP_PROJECT_ID=${ADDR[1]} # project id is the second string split by _
126
186
  SDEXP_SA='stackdriver-exporter'
127
- helm upgrade --install stackdriver-exporter \
128
- prometheus-community/prometheus-stackdriver-exporter \
129
- --namespace monitoring \
130
- --values stackdriver-exporter/values.yaml \
131
- --version 1.12.0
132
-
133
- # Verify the Kubernetes SA
134
- kubectl get sa -n monitoring $SDEXP_SA
135
- if [[ $? -eq 1 ]];
136
- then
137
- printf "The $SDEXP_SA SA seems to be missing, which is weird - creating it now\n"
138
- kubectl create sa -n monitoring stackdriver-exporter
139
- fi
140
187
 
141
188
  # NOTE: The k8s SA != GCP SA - the former is created by the helm chart
142
189
  # that installs the stackdriver-exporter, the latter is handled here in
@@ -145,7 +192,8 @@ SA_EXISTS
145
192
  # Create GCP SA and bind policies
146
193
  printf "\n*** Creating GCP SA with monitoring/viewer ***\n"
147
194
  gcloud iam service-accounts create $SDEXP_SA \
148
- --project "$GCP_PROJECT_ID"
195
+ --project "$GCP_PROJECT_ID" \
196
+ --display-name "Prometheus Stackdriver Exporter"
149
197
  warnOnError $? "the GCP SA $SDEXP_SA may already exist"
150
198
 
151
199
  printf "\n*** Binding IAM role of monitoring viewer to stackdriver-exporter in $GCP_PROJECT_ID\n"
@@ -160,31 +208,43 @@ SA_EXISTS
160
208
  --member "serviceAccount:$GCP_PROJECT_ID.svc.id.goog[monitoring/$SDEXP_SA]" \
161
209
  "$SDEXP_SA@$GCP_PROJECT_ID.iam.gserviceaccount.com"
162
210
 
163
- # Annotate Kubernetes SA
164
- printf "\n*** Annotating the stackdriver-exporter SA\n"
165
- kubectl annotate serviceaccount $SDEXP_SA \
166
- "iam.gke.io/gcp-service-account=$SDEXP_SA@$GCP_PROJECT_ID.iam.gserviceaccount.com" \
167
- --namespace monitoring
211
+ # The GCP SA is now up but slight delay before launch helm to let the IAM update occur
212
+ sleep 2
213
+ helm upgrade --install stackdriver-exporter \
214
+ prometheus-community/prometheus-stackdriver-exporter \
215
+ --namespace monitoring \
216
+ --values stackdriver-exporter/values.yaml \
217
+ --version 3
218
+
219
+ # Verify the Kubernetes SA
220
+ kubectl get sa -n monitoring $SDEXP_SA
221
+ if [[ $? -eq 1 ]];
222
+ then
223
+ printf "The $SDEXP_SA SA seems to be missing - did startup fail?\n"
224
+ else
225
+ # Annotate Kubernetes SA
226
+ printf "\n*** Annotating the stackdriver-exporter SA\n"
227
+ kubectl annotate serviceaccount $SDEXP_SA \
228
+ "iam.gke.io/gcp-service-account=$SDEXP_SA@$GCP_PROJECT_ID.iam.gserviceaccount.com" \
229
+ --namespace monitoring
230
+ fi
168
231
  fi
169
232
 
170
233
  ## Install Prometheus
171
- helm upgrade --install prometheus prometheus-community/prometheus \
172
- --namespace monitoring \
173
- --values prometheus/values.yaml \
174
- --version 13
234
+ installPrometheus
175
235
 
176
236
  ## Installing ES exporter
177
237
  helm upgrade --install elasticsearch-exporter prometheus-community/prometheus-elasticsearch-exporter \
178
238
  --namespace monitoring \
179
239
  --values elasticsearch-exporter/values-es-exporter.yaml \
180
- --version 4.11
240
+ --version 4.13
181
241
 
182
242
  ## Install Grafana
183
243
  addHelmRepo grafana https://grafana.github.io/helm-charts
184
244
  helm upgrade --install grafana grafana/grafana \
185
245
  --namespace monitoring \
186
246
  --values grafana/values-grafana.yaml \
187
- --version 6.26.5 # latest v8 grafana
247
+ --version 6 # latest v8 grafana
188
248
 
189
249
  ## Clean up
190
250
  removeHelmRepo prometheus-community
@@ -253,45 +313,42 @@ function getManagedSecret() {
253
313
  echo $SECRET
254
314
  }
255
315
 
256
- function getProjectIdFromK8sContext() {
257
- local currContext=`kubectl config current-context`
258
-
259
- IFS='_'
260
- read -ra ADDR <<< "$currContext"
261
-
262
- echo ${ADDR[1]} # project id is the second string split by _
263
- }
264
-
265
316
  # https://github.com/estafette/estafette-gke-preemptible-killer
266
317
  function installPreemptibleKiller() {
267
318
  showInstalling "Preemptible Node Killing Adjusticator"
319
+ NAMESPACE="estafette"
268
320
  PROJECT_ID="$(getProjectIdFromK8sContext)"
269
- createNamespaceIfNeeded estafette
321
+ SVC_ACCT="preemptible-killer"
322
+
323
+ createNamespaceIfNeeded $NAMESPACE
270
324
  addHelmRepo estafette https://helm.estafette.io
271
325
 
272
- gcloud iam service-accounts create preemptible-killer \
273
- --project=$PROJECT_ID \
274
- --display-name preemptible-killer
326
+ printf "\nCreating the gcloud $SVC_ACCT service account (SA)\n"
327
+ gcloud iam service-accounts create $SVC_ACCT \
328
+ --project $PROJECT_ID \
329
+ warnOnError $? "SA creation may have failed or it already exists"
275
330
 
276
- gcloud iam roles create preemptible_killer \
331
+ printf "\nCreate the $SVC_ACCT IAM role\n"
332
+ gcloud iam roles create preemptibleKiller \
277
333
  --project $PROJECT_ID \
278
- --title preemptible-killer \
334
+ --title "Estafette Node Killer" \
279
335
  --description "Delete compute instances" \
280
336
  --permissions compute.instances.delete
337
+ warnOnError $? "Role creation may have failed or it already exists"
281
338
 
282
- local service_account_email=$(gcloud iam --project=$PROJECT_ID service-accounts list --filter preemptible-killer --format 'value([email])')
339
+ local service_account_email=$(gcloud iam --project=$PROJECT_ID service-accounts list --filter $SVC_ACCT --format 'value([email])')
340
+ printf "\nBinding the IAM role to the $SVC_ACCT SA\n"
283
341
  gcloud projects add-iam-policy-binding $PROJECT_ID \
284
342
  --member=serviceAccount:${service_account_email} \
285
- --role=projects/${PROJECT_ID}/roles/preemptible_killer &>/dev/null
343
+ --role=projects/${PROJECT_ID}/roles/preemptibleKiller &> /dev/null
344
+ warnOnError $? "Binding may have failed or it already exists"
286
345
 
287
- gcloud iam service-accounts keys create \
288
- --project=$PROJECT_ID \
289
- --iam-account $service_account_email \
290
- google_service_account.json &>/dev/null
346
+ bindWorkloadIdentity $SVC_ACCT $NAMESPACE
291
347
 
292
348
  helm upgrade --install estafette-gke-preemptible-killer \
293
349
  estafette/estafette-gke-preemptible-killer \
294
- --namespace estafette \
350
+ --namespace ${NAMESPACE} \
351
+ --set secret.workloadIdentityServiceAccount="$SVC_ACCT@$PROJECT_ID.iam.gserviceaccount.com" \
295
352
  --set extraEnv.BLACKLIST_HOURS="10:00-02:00" # No killing from 5AM-9PM EST
296
353
  # --set extraEnv.WHITELIST_HOURS="12:30-13:30"
297
354
  [ -f "google_service_account.json" ] && rm google_service_account.json
@@ -403,7 +460,7 @@ NEED_MANAGED_SECRET
403
460
  addHelmRepo jetstack https://charts.jetstack.io
404
461
  helm upgrade --install cert-manager jetstack/cert-manager \
405
462
  --namespace cert-manager --set installCRDs=true \
406
- --version v1.7.0
463
+ --version v1.8
407
464
 
408
465
  cat<<DELAY
409
466
 
@@ -478,10 +535,12 @@ TRAEFIK_CFG
478
535
 
479
536
  addHelmRepo traefik https://helm.traefik.io/traefik
480
537
 
538
+ [ -z "$TRAEFIK_HELM_CHART" ] && TRAEFIK_HELM_CHART="10"
481
539
  helm upgrade --install traefik traefik/traefik \
482
540
  --namespace traefik \
483
- --values $TRAEFIK_HA_YAML
484
-
541
+ --version $TRAEFIK_HELM_CHART \
542
+ --values $TRAEFIK_HA_YAML
543
+
485
544
  removeHelmRepo traefik
486
545
  }
487
546
 
@@ -579,7 +638,7 @@ function installVelero() {
579
638
 
580
639
  kubectl annotate serviceaccount velero \
581
640
  --namespace velero \
582
- iam.gke.io/gcp-service-account=$SERVICE_ACCOUNT_EMAIL
641
+ "iam.gke.io/gcp-service-account=$SERVICE_ACCOUNT_EMAIL"
583
642
  warnOnError $? "Failed to annotate k8s SA - things may fail"
584
643
 
585
644
  gsutil iam ch serviceAccount:$SERVICE_ACCOUNT_EMAIL:objectAdmin gs://$BUCKET
@@ -591,6 +650,7 @@ function installVelero() {
591
650
  ## Helpful debugging link => https://github.com/vmware-tanzu/helm-charts/issues/351
592
651
  addHelmRepo vmware-tanzu https://vmware-tanzu.github.io/helm-charts
593
652
  helm upgrade --install velero vmware-tanzu/velero \
653
+ --version 2.29 \
594
654
  --namespace velero \
595
655
  --set credentials.useSecret="false" \
596
656
  --set configuration.provider="gcp" \
@@ -745,6 +805,7 @@ function doInstall() {
745
805
  checkSSDStorageClass
746
806
  addHelmRepo elastic https://helm.elastic.co
747
807
  helm upgrade --install elasticsearch elastic/elasticsearch \
808
+ --version 7 \
748
809
  --values $LOCAL_ES_VALUES \
749
810
  --set volumeClaimTemplate.storageClassName="ssd"
750
811
  removeHelmRepo elastic
@@ -770,12 +831,17 @@ function doInstall() {
770
831
  removeHelmRepo bitnami
771
832
  ;;
772
833
 
834
+ "prometheus")
835
+ installPrometheus
836
+ ;;
837
+
773
838
  "redis")
774
839
  showInstalling "Redis Network Cache"
775
840
  addBitnamiRepo
776
841
  [ -z "$REDIS_HELM_CHART" ] && REDIS_HELM_CHART="13.0.1" # latest breaks us => "v14+"
777
842
  helm upgrade --install redis bitnami/redis \
778
843
  -f redis/redis-values.yaml \
844
+ --set auth.enabled=false \
779
845
  --version $REDIS_HELM_CHART
780
846
  printf "\n\nTo start a specific version => `color g 'REDIS_HELM_CHART="13.0.1" helmup redis'`\n\n"
781
847
  removeHelmRepo bitnami