@leverege/build-tools 2.13.3 → 2.14.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
@@ -44,9 +44,16 @@ const npmRunner = async script => {
44
44
  await npmRunner(script[i]);
45
45
  }
46
46
  } else {
47
- await execa('npm-check-updates', ['--color'], {
48
- stdio: 'inherit'
49
- });
50
- process.exit(0);
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
+ }
51
58
  }
52
59
  })();
@@ -44,9 +44,16 @@ const npmRunner = async script => {
44
44
  await npmRunner(script[i]);
45
45
  }
46
46
  } else {
47
- await execa('npm-check-updates', ['--color'], {
48
- stdio: 'inherit'
49
- });
50
- process.exit(0);
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
+ }
51
58
  }
52
59
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leverege/build-tools",
3
- "version": "2.13.3",
3
+ "version": "2.14.0",
4
4
  "description": "A collection of build / support tools for Leverege developers",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -57,11 +57,11 @@
57
57
  "dotenv": "^16.0.1",
58
58
  "execa": "^5.1.1",
59
59
  "figlet": "^1.5.2",
60
- "glob": "^7.2.0",
60
+ "glob": "^7.2.3",
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.1",
64
+ "npm-check-updates": "^13.0.3",
65
65
  "npm-registry-fetch": "^11.0.0",
66
66
  "open": "^8.4.0",
67
67
  "ora": "^5.4.1",
@@ -72,10 +72,10 @@
72
72
  },
73
73
  "devDependencies": {
74
74
  "@babel/cli": "^7.17.10",
75
- "@babel/core": "^7.18.0",
75
+ "@babel/core": "^7.18.2",
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.10.0"
79
+ "npm": "^8.11.0"
80
80
  }
81
81
  }
package/src/bash-funcs CHANGED
@@ -105,3 +105,7 @@ REPOADD
105
105
  helm repo add $chart $url &> /dev/null
106
106
  helm repo update &> /dev/null
107
107
  }
108
+
109
+ function removeHelmRepo(){
110
+ helm repo remove $1 &>/dev/null
111
+ }
package/src/helmup CHANGED
@@ -165,6 +165,10 @@ SA_EXISTS
165
165
  --namespace monitoring \
166
166
  --values grafana/values-grafana.yaml \
167
167
  --version 6.26.5 # latest v8 grafana
168
+
169
+ ## Clean up
170
+ removeHelmRepo prometheus-community
171
+ removeHelmRepo grafana
168
172
  }
169
173
 
170
174
  function monitoringHelp(){
@@ -271,6 +275,7 @@ function installPreemptibleKiller() {
271
275
  --set extraEnv.BLACKLIST_HOURS="10:00-02:00" # No killing from 5AM-9PM EST
272
276
  # --set extraEnv.WHITELIST_HOURS="12:30-13:30"
273
277
  [ -f "google_service_account.json" ] && rm google_service_account.json
278
+ removeHelmRepo estafette
274
279
  }
275
280
 
276
281
  function installCronZombieKiller() {
@@ -403,6 +408,7 @@ DELAY
403
408
  check certs: `color g "kubectl -n cert-manager describe certificate"`
404
409
 
405
410
  HINTS
411
+ removeHelmRepo jetstack
406
412
  }
407
413
 
408
414
  function installTraefik() {
@@ -450,19 +456,18 @@ deployment:
450
456
  TRAEFIK_CFG
451
457
  fi
452
458
 
453
- # old chart => traefik https://containous.github.io/traefik-helm-chart
454
- helm repo remove traefik &> /dev/null
455
459
  addHelmRepo traefik https://helm.traefik.io/traefik
456
460
 
457
461
  helm upgrade --install traefik traefik/traefik \
458
462
  --namespace traefik \
459
463
  --values $TRAEFIK_HA_YAML
464
+
465
+ removeHelmRepo traefik
460
466
  }
461
467
 
462
468
  function installVelero() {
469
+ # Follows instructions => https://github.com/vmware-tanzu/velero-plugin-for-gcp
463
470
  showInstalling "Velero Backup Management"
464
- open https://velero.io/docs
465
- yesToContinue "when you are done checking the docs"
466
471
 
467
472
  ## Set the project id by parsing current context
468
473
  currContext=`kubectl config current-context`
@@ -483,7 +488,9 @@ function installVelero() {
483
488
  ## Create a service account
484
489
  printf "\nCreating the service account\n"
485
490
  gcloud iam service-accounts create velero \
486
- --display-name "Velero service account" &>/dev/null
491
+ --project $PROJECT_ID \
492
+ --display-name "Velero service account" \
493
+ --description "Velero service account" &>/dev/null
487
494
  if [ $? -eq 0 ];
488
495
  then
489
496
  # no error means a new SA was created - slight delay to let it update
@@ -504,6 +511,11 @@ function installVelero() {
504
511
  compute.snapshots.useReadOnly
505
512
  compute.snapshots.delete
506
513
  compute.zones.get
514
+ iam.serviceAccounts.actAs
515
+ storage.objects.create
516
+ storage.objects.delete
517
+ storage.objects.get
518
+ storage.objects.list
507
519
  )
508
520
 
509
521
  printf "\nAssigning roles to the SA\n"
@@ -511,43 +523,64 @@ function installVelero() {
511
523
  --project $PROJECT_ID \
512
524
  --title "Velero Server" \
513
525
  --permissions "$(IFS=","; echo "${ROLE_PERMISSIONS[*]}")" &>/dev/null
526
+ if [ $? -ne 0 ];
527
+ then
528
+ # assume error is that role exists so try updating instead
529
+ printf "\nUpdating roles on the SA\n"
530
+ gcloud iam roles update velero.server \
531
+ --project $PROJECT_ID \
532
+ --title "Velero Server" \
533
+ --permissions "$(IFS=","; echo "${ROLE_PERMISSIONS[*]}")" &>/dev/null
534
+ fi
514
535
  warnOnError $? "Failed to add roles to velero.server - perhaps they already exist?"
515
536
 
516
537
  printf "\nBinding IAM policy to the SA\n"
517
538
  gcloud projects add-iam-policy-binding $PROJECT_ID \
539
+ --project $PROJECT_ID \
518
540
  --member serviceAccount:$SERVICE_ACCOUNT_EMAIL \
541
+ --condition 'None' \
519
542
  --role projects/$PROJECT_ID/roles/velero.server &>/dev/null
520
543
  warnOnError $? "gcloud problem binding IAM policy"
521
544
 
522
- gsutil iam ch serviceAccount:$SERVICE_ACCOUNT_EMAIL:objectAdmin gs://$BUCKET
523
-
524
- ## Create keys
525
- VELERO_CREDS="velero-credentials"
526
- gcloud iam service-accounts keys create $VELERO_CREDS \
527
- --iam-account $SERVICE_ACCOUNT_EMAIL
545
+ printf "\nBinding workload identity IAM policy to the SA\n"
546
+ gcloud iam service-accounts add-iam-policy-binding \
547
+ --member "serviceAccount:$PROJECT_ID.svc.id.goog[velero/velero]" \
548
+ --role roles/iam.workloadIdentityUser \
549
+ $SERVICE_ACCOUNT_EMAIL
550
+ warnOnError $? "gcloud workload identity binding may have failed"
528
551
 
529
552
  ## Create velero namespace
530
553
  kubectl get namespaces velero &>/dev/null
531
554
  [ $? -eq 1 ] && kubectl create ns velero
532
555
 
533
- ## Create kubernetes secret
534
- printf "\nStoring the credentials in $VELERO_CREDS k8s secret\n"
535
- kubectl delete secret $VELERO_CREDS --namespace velero &>/dev/null # toss old key if exists
536
- kubectl create secret generic $VELERO_CREDS --namespace velero --from-file cloud=${VELERO_CREDS}
556
+ printf "\nCreate and annotate the k8s SA\n"
557
+ kubectl create serviceaccount velero --namespace velero
558
+ warnOnError $? "Failed to create k8s SA - perhaps it already exists?"
559
+
560
+ kubectl annotate serviceaccount velero \
561
+ --namespace velero \
562
+ iam.gke.io/gcp-service-account=$SERVICE_ACCOUNT_EMAIL
563
+ warnOnError $? "Failed to annotate k8s SA - things may fail"
564
+
565
+ gsutil iam ch serviceAccount:$SERVICE_ACCOUNT_EMAIL:objectAdmin gs://$BUCKET
537
566
 
538
567
  ## Clean up from previous failed install
539
568
  kubectl delete volumesnapshotlocation.velero.io -n velero gcp &>/dev/null
540
569
 
541
- ## Install velero
570
+ ## Install velero chart => https://github.com/vmware-tanzu/helm-charts/blob/main/charts/velero/values.yaml
571
+ ## Helpful debugging link => https://github.com/vmware-tanzu/helm-charts/issues/351
542
572
  addHelmRepo vmware-tanzu https://vmware-tanzu.github.io/helm-charts
543
573
  helm upgrade --install velero vmware-tanzu/velero \
544
574
  --namespace velero \
575
+ --set credentials.useSecret="false" \
545
576
  --set configuration.provider="gcp" \
546
577
  --set configuration.backupStorageLocation.name=default \
547
578
  --set configuration.backupStorageLocation.bucket="${BUCKET}" \
579
+ --set configuration.backupStorageLocation.config.serviceAccount=$SERVICE_ACCOUNT_EMAIL \
580
+ --set serviceAccount.server.create="false" \
581
+ --set serviceAccount.server.name="velero" \
548
582
  --set snapshotsEnabled="true" \
549
583
  --set configuration.volumeSnapshotLocation.name=default \
550
- --set credentials.existingSecret="${VELERO_CREDS}" \
551
584
  --set "initContainers[0].name"="velero-plugin-for-gcp" \
552
585
  --set "initContainers[0].image"="velero/velero-plugin-for-gcp:v1.0.0" \
553
586
  --set "initContainers[0].volumeMounts[0].mountPath"="/target" \
@@ -564,8 +597,11 @@ function installVelero() {
564
597
  --set schedules.timescale.template.snapshotVolumes="true"
565
598
 
566
599
  velero get backups
567
- printf "\n\nVelero keys => kubectl get secret $VELERO_CREDS --namespace velero\n\n"
568
- /bin/rm -f $VELERO_CREDS
600
+ cat<<DONE_VELERO
601
+
602
+ Velero docs => `color g 'open https://velero.io/docs'`
603
+ DONE_VELERO
604
+ removeHelmRepo vmware-tanzu
569
605
  echo -n "npm run ahoy && velero get backups" | pbcopy
570
606
  }
571
607
 
@@ -644,8 +680,7 @@ CHARTVER=
644
680
  FROM_VERSIONS=
645
681
  function doInstall() {
646
682
 
647
- # helm repo remove stable &> /dev/null # stable was deprecated
648
- helm repo update &> /dev/null
683
+ helm repo update # XXX &> /dev/null
649
684
 
650
685
  for PARAM in "$@";
651
686
  do
@@ -692,6 +727,7 @@ function doInstall() {
692
727
  helm upgrade --install elasticsearch elastic/elasticsearch \
693
728
  --values $LOCAL_ES_VALUES \
694
729
  --set volumeClaimTemplate.storageClassName="ssd"
730
+ removeHelmRepo elastic
695
731
  ;;
696
732
 
697
733
  "estafette"|"preemptible-killer")
@@ -711,6 +747,7 @@ function doInstall() {
711
747
  showInstalling "PostgreSQL Database"
712
748
  addHelmRepo bitnami https://charts.bitnami.com/bitnami
713
749
  helm upgrade --install postgres bitnami/postgresql -f postgres/postgres-values.yaml --version 8.9.6
750
+ removeHelmRepo bitnami
714
751
  ;;
715
752
 
716
753
  "redis")
@@ -721,12 +758,14 @@ function doInstall() {
721
758
  -f redis/redis-values.yaml \
722
759
  --version $REDIS_HELM_CHART
723
760
  printf "\n\nTo start a specific version => `color g 'REDIS_HELM_CHART="13.0.1" helmup redis'`\n\n"
761
+ removeHelmRepo bitnami
724
762
  ;;
725
763
 
726
764
  "reloader")
727
765
  showInstalling "Stakater ConfigMap Reloader"
728
766
  addHelmRepo stakater https://stakater.github.io/stakater-charts
729
767
  helm upgrade --install reloader stakater/reloader
768
+ removeHelmRepo stakater
730
769
  ;;
731
770
 
732
771
  "timescale-db")
package/src/unleash.js CHANGED
@@ -39,7 +39,14 @@ const npmRunner = async ( script ) => {
39
39
  await npmRunner( script[i] )
40
40
  }
41
41
  } else {
42
- await execa( 'npm-check-updates', [ '--color', ], { stdio : 'inherit' } )
43
- process.exit( 0 )
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
+ }
44
51
  }
45
52
  } )()