@leverege/build-tools 2.14.0 → 2.14.2

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
@@ -44,16 +44,6 @@ const npmRunner = async script => {
44
44
  await npmRunner(script[i]);
45
45
  }
46
46
  } else {
47
- try {
48
- await execa('npm-check-updates', ['--color', '--packageFile', './package.json'], {
49
- stdio: 'inherit'
50
- });
51
- process.exit(0);
52
- } catch (err) {
53
- console.log({
54
- err
55
- }, 'npm-check-update failed');
56
- process.exit(err.exitCode);
57
- }
47
+ process.exit(0);
58
48
  }
59
49
  })();
@@ -44,16 +44,6 @@ const npmRunner = async script => {
44
44
  await npmRunner(script[i]);
45
45
  }
46
46
  } else {
47
- try {
48
- await execa('npm-check-updates', ['--color', '--packageFile', './package.json'], {
49
- stdio: 'inherit'
50
- });
51
- process.exit(0);
52
- } catch (err) {
53
- console.log({
54
- err
55
- }, 'npm-check-update failed');
56
- process.exit(err.exitCode);
57
- }
47
+ process.exit(0);
58
48
  }
59
49
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leverege/build-tools",
3
- "version": "2.14.0",
3
+ "version": "2.14.2",
4
4
  "description": "A collection of build / support tools for Leverege developers",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -61,7 +61,7 @@
61
61
  "inquirer": "^8.2.4",
62
62
  "js-yaml": "^4.1.0",
63
63
  "ncp": "^2.0.0",
64
- "npm-check-updates": "^13.0.3",
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",
@@ -76,6 +76,6 @@
76
76
  "@babel/node": "^7.17.10",
77
77
  "@leverege/babel-preset-leverege-node": "^2.0.0",
78
78
  "@leverege/eslint-config-leverege": "^3.0.1",
79
- "npm": "^8.11.0"
79
+ "npm": "^8.12.1"
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/helmup CHANGED
@@ -8,6 +8,8 @@
8
8
  # Load the standard helper functions
9
9
  . `build-tools --bashfun`
10
10
 
11
+ SHELMUP_ARGS=("$*")
12
+
11
13
  # removed geotile-server from standard platform 3/20/22 - low usage
12
14
  PLATFORM=(
13
15
  authz-server
@@ -39,6 +41,70 @@ SYSTEM=(
39
41
  monitoring # do monitoring last to show password
40
42
  )
41
43
 
44
+ # support for legacy bitnami charts
45
+ function addBitnamiRepo() {
46
+ if [ ! -z "$BITNAMI_LATEST" ];
47
+ then
48
+ BITNAMI_URL="https://charts.bitnami.com/bitnami"
49
+ else
50
+ cat<<CATNAMI
51
+ Using the pre 2022 legacy charts from bitnami. To use latest run:
52
+
53
+ `color y "BITNAMI_LATEST=1 $HELMUP_ARGS"`
54
+
55
+ CATNAMI
56
+ BITNAMI_URL="https://raw.githubusercontent.com/bitnami/charts/eb5f9a9513d987b519f0ecd732e7031241c50328/bitnami"
57
+ fi
58
+
59
+ addHelmRepo bitnami $BITNAMI_URL
60
+ }
61
+
62
+ function getProjectIdFromK8sContext() {
63
+ local currContext=`kubectl config current-context`
64
+
65
+ IFS='_'
66
+ read -ra ADDR <<< "$currContext"
67
+
68
+ echo ${ADDR[1]} # project id is the second string split by _
69
+ }
70
+
71
+ function bindWorkloadIdentity(){
72
+ PROJECT_ID=$(getProjectIdFromK8sContext)
73
+ SVC_ACCT=$1
74
+ NAMESPACE=$2
75
+ SVC_ACCT_EMAIL="${SVC_ACCT}@${PROJECT_ID}.iam.gserviceaccount.com"
76
+
77
+ cat<<WORKLOAD_ID
78
+ Binding workload identity IAM policy
79
+ Service Account : `color g $SVC_ACCT`
80
+ Project : `color g $PROJECT_ID`
81
+ Namespace : `color g $NAMESPACE`
82
+ Service Email : `color g $SVC_ACCT_EMAIL`
83
+
84
+ WORKLOAD_ID
85
+
86
+ gcloud iam service-accounts add-iam-policy-binding \
87
+ --project $PROJECT_ID \
88
+ --member "serviceAccount:$PROJECT_ID.svc.id.goog[${NAMESPACE}/${SVC_ACCT}]" \
89
+ --role roles/iam.workloadIdentityUser $SVC_ACCT_EMAIL
90
+ warnOnError $? "gcloud workload identity binding may have failed"
91
+
92
+ # Verify the Kubernetes SA and create it if necessary
93
+ printf "\nChecking for the $NAMESPACE/#SVC_ACCT k8s SA\n"
94
+ kubectl get sa -n $NAMESPACE $SVC_ACCT
95
+ if [[ $? -eq 1 ]];
96
+ then
97
+ printf "Creating the k8s SA $NAMESPACE/@$SVC_ACCT\n"
98
+ kubectl create sa -n $NAMESPACE $SVC_ACCT
99
+ fi
100
+
101
+ printf "\nAnnotating the k8s SA $NAMESPACE/@$SVC_ACCT\n"
102
+ kubectl annotate serviceaccount $SVC_ACCT \
103
+ --namespace $NAMESPACE --overwrite \
104
+ "iam.gke.io/gcp-service-account=$SVC_ACCT_EMAIL"
105
+ warnOnError $? "Failed to annotate service account $NAMESPACE/$SVC_ACCT - things may fail"
106
+ }
107
+
42
108
  function checkTimescalePassword(){
43
109
  kubectl get secret postgresql-password
44
110
  if [[ $? -eq 1 ]]; then
@@ -70,6 +136,18 @@ function createNamespaceIfNeeded(){
70
136
  fi
71
137
  }
72
138
 
139
+ function installPrometheus() {
140
+ # Add the community helm repositories
141
+ addHelmRepo prometheus-community https://prometheus-community.github.io/helm-charts
142
+
143
+ helm upgrade --install prometheus prometheus-community/prometheus \
144
+ --namespace monitoring \
145
+ --values prometheus/values.yaml \
146
+ --version 13
147
+
148
+ # removeHelmRepo prometheus-community
149
+ }
150
+
73
151
  function installMonitoringCharts(){
74
152
  showInstalling "Grafana Monitoring"
75
153
  createNamespaceIfNeeded monitoring
@@ -148,10 +226,7 @@ SA_EXISTS
148
226
  fi
149
227
 
150
228
  ## Install Prometheus
151
- helm upgrade --install prometheus prometheus-community/prometheus \
152
- --namespace monitoring \
153
- --values prometheus/values.yaml \
154
- --version 13
229
+ installPrometheus
155
230
 
156
231
  ## Installing ES exporter
157
232
  helm upgrade --install elasticsearch-exporter prometheus-community/prometheus-elasticsearch-exporter \
@@ -233,45 +308,43 @@ function getManagedSecret() {
233
308
  echo $SECRET
234
309
  }
235
310
 
236
- function getProjectIdFromK8sContext() {
237
- local currContext=`kubectl config current-context`
238
-
239
- IFS='_'
240
- read -ra ADDR <<< "$currContext"
241
-
242
- echo ${ADDR[1]} # project id is the second string split by _
243
- }
244
-
245
311
  # https://github.com/estafette/estafette-gke-preemptible-killer
246
312
  function installPreemptibleKiller() {
247
313
  showInstalling "Preemptible Node Killing Adjusticator"
314
+ NAMESPACE="estafette"
248
315
  PROJECT_ID="$(getProjectIdFromK8sContext)"
249
- createNamespaceIfNeeded estafette
316
+ SVC_ACCT="preemptible-killer"
317
+
318
+ createNamespaceIfNeeded $NAMESPACE
250
319
  addHelmRepo estafette https://helm.estafette.io
251
320
 
252
- gcloud iam service-accounts create preemptible-killer \
253
- --project=$PROJECT_ID \
254
- --display-name preemptible-killer
321
+ printf "\nCreating the gcloud $SVC_ACCT service account (SA)\n"
322
+ gcloud iam service-accounts create $SVC_ACCT \
323
+ --project $PROJECT_ID \
324
+ --display-name "Estafette Node Killer"
325
+ warnOnError $? "SA creation may have failed or it already exists"
255
326
 
256
- gcloud iam roles create preemptible_killer \
327
+ printf "\nCreate the $SVC_ACCT IAM role\n"
328
+ gcloud iam roles create preemptibleKiller \
257
329
  --project $PROJECT_ID \
258
- --title preemptible-killer \
330
+ --title "Estafette Node Killer" \
259
331
  --description "Delete compute instances" \
260
332
  --permissions compute.instances.delete
333
+ warnOnError $? "Role creation may have failed or it already exists"
261
334
 
262
- local service_account_email=$(gcloud iam --project=$PROJECT_ID service-accounts list --filter preemptible-killer --format 'value([email])')
335
+ local service_account_email=$(gcloud iam --project=$PROJECT_ID service-accounts list --filter $SVC_ACCT --format 'value([email])')
336
+ printf "\nBinding the IAM role to the $SVC_ACCT SA\n"
263
337
  gcloud projects add-iam-policy-binding $PROJECT_ID \
264
338
  --member=serviceAccount:${service_account_email} \
265
- --role=projects/${PROJECT_ID}/roles/preemptible_killer &>/dev/null
339
+ --role=projects/${PROJECT_ID}/roles/preemptibleKiller &> /dev/null
340
+ warnOnError $? "Binding may have failed or it already exists"
266
341
 
267
- gcloud iam service-accounts keys create \
268
- --project=$PROJECT_ID \
269
- --iam-account $service_account_email \
270
- google_service_account.json &>/dev/null
342
+ bindWorkloadIdentity $SVC_ACCT $NAMESPACE
271
343
 
272
344
  helm upgrade --install estafette-gke-preemptible-killer \
273
345
  estafette/estafette-gke-preemptible-killer \
274
- --namespace estafette \
346
+ --namespace ${NAMESPACE} \
347
+ --set secret.workloadIdentityServiceAccount="$SVC_ACCT@$PROJECT_ID.iam.gserviceaccount.com" \
275
348
  --set extraEnv.BLACKLIST_HOURS="10:00-02:00" # No killing from 5AM-9PM EST
276
349
  # --set extraEnv.WHITELIST_HOURS="12:30-13:30"
277
350
  [ -f "google_service_account.json" ] && rm google_service_account.json
@@ -559,7 +632,7 @@ function installVelero() {
559
632
 
560
633
  kubectl annotate serviceaccount velero \
561
634
  --namespace velero \
562
- iam.gke.io/gcp-service-account=$SERVICE_ACCOUNT_EMAIL
635
+ "iam.gke.io/gcp-service-account=$SERVICE_ACCOUNT_EMAIL"
563
636
  warnOnError $? "Failed to annotate k8s SA - things may fail"
564
637
 
565
638
  gsutil iam ch serviceAccount:$SERVICE_ACCOUNT_EMAIL:objectAdmin gs://$BUCKET
@@ -680,7 +753,7 @@ CHARTVER=
680
753
  FROM_VERSIONS=
681
754
  function doInstall() {
682
755
 
683
- helm repo update # XXX &> /dev/null
756
+ helm repo update &> /dev/null
684
757
 
685
758
  for PARAM in "$@";
686
759
  do
@@ -745,14 +818,18 @@ function doInstall() {
745
818
 
746
819
  "postgres"|"postgresql")
747
820
  showInstalling "PostgreSQL Database"
748
- addHelmRepo bitnami https://charts.bitnami.com/bitnami
821
+ addBitnamiRepo
749
822
  helm upgrade --install postgres bitnami/postgresql -f postgres/postgres-values.yaml --version 8.9.6
750
823
  removeHelmRepo bitnami
751
824
  ;;
752
825
 
826
+ "prometheus")
827
+ installPrometheus
828
+ ;;
829
+
753
830
  "redis")
754
831
  showInstalling "Redis Network Cache"
755
- addHelmRepo bitnami https://charts.bitnami.com/bitnami
832
+ addBitnamiRepo
756
833
  [ -z "$REDIS_HELM_CHART" ] && REDIS_HELM_CHART="13.0.1" # latest breaks us => "v14+"
757
834
  helm upgrade --install redis bitnami/redis \
758
835
  -f redis/redis-values.yaml \
package/src/unleash.js CHANGED
@@ -39,14 +39,6 @@ const npmRunner = async ( script ) => {
39
39
  await npmRunner( script[i] )
40
40
  }
41
41
  } else {
42
- try {
43
- await execa( 'npm-check-updates', [
44
- '--color', '--packageFile', './package.json',
45
- ], { stdio : 'inherit' } )
46
- process.exit( 0 )
47
- } catch ( err ) {
48
- console.log( { err }, 'npm-check-update failed' )
49
- process.exit( err.exitCode )
50
- }
42
+ process.exit( 0 )
51
43
  }
52
44
  } )()