@leverege/build-tools 2.43.10 → 2.43.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leverege/build-tools",
3
- "version": "2.43.10",
3
+ "version": "2.43.12",
4
4
  "description": "A collection of build / support tools for Leverege developers",
5
5
  "main": "index.js",
6
6
  "repository": {
package/src/bash-funcs CHANGED
@@ -161,7 +161,18 @@ EOSLACK
161
161
  # of the standard setup scripts.
162
162
  function ifPluggedIn() {
163
163
  local INVOKED_AS=`basename $0`
164
- local PLUGIN="$1/$INVOKED_AS.plugin"
164
+ local PLUGIN=
165
+ case "$INVOKED_AS" in
166
+ "helmup"|"helmwhat" )
167
+ PLUGIN="$1/helmup.plugin"
168
+ ;;
169
+ "helmdn" )
170
+ PLUGIN="$1/helmdn.plugin"
171
+ ;;
172
+ *)
173
+ ;;
174
+ esac
175
+
165
176
  [ ! -f $PLUGIN ] && return 1
166
177
 
167
178
  if [ ! -x $PLUGIN ];
@@ -174,7 +185,9 @@ PLUGIN_NOEXEC
174
185
  exit 1
175
186
  fi
176
187
 
177
- printf "\n***Executing local plugin code => `color y $PLUGIN`\n\n" && sleep 2
188
+ local OPERATION="Executing local plugin code"
189
+ [ ! -z "$HELM_WHAT" ] && OPERATION="Performing a DRY RUN"
190
+ printf "\n***$OPERATION => `color y $PLUGIN`\n\n" && sleep 2
178
191
  export HELM_WHAT
179
192
  . $PLUGIN # executing with . allows the plugin to use functions like color
180
193
  sendToSlack "$PLUGIN"
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ helm uninstall --namespace cnpg-system cnpg # cnpg-cloudnative-pg
@@ -0,0 +1,10 @@
1
+ #!/bin/bash
2
+ #
3
+ # See => https://github.com/cloudnative-pg/charts
4
+ addHelmRepo cnpg https://cloudnative-pg.github.io/charts
5
+
6
+ helm upgrade --install cnpg cnpg/cloudnative-pg \
7
+ --namespace cnpg-system --create-namespace \
8
+ --set webhook.port="10250"
9
+
10
+ removeHelmRepo cnpg
package/src/helmup.sh CHANGED
@@ -46,13 +46,13 @@ AUXILIARY=(
46
46
  vin-decoder-server
47
47
  )
48
48
 
49
+ # zombie-killer disabled 20231228
49
50
  SYSTEM=(
50
51
  elasticsearch8
51
52
  redis
52
53
  postgres
53
54
  timescale-db
54
55
  preemptible-killer
55
- zombie-killer
56
56
  reloader
57
57
  traefik
58
58
  velero
@@ -456,6 +456,83 @@ NEED_MANAGED_SECRET
456
456
  fi
457
457
  }
458
458
 
459
+ function installCnpgOperatorEnvironment() {
460
+ # See => https://github.com/cloudnative-pg/charts
461
+
462
+ gcloud config set project $GCP_PROJECT_ID
463
+
464
+ # create an SA in the cnpg namespace for the operands to bind to
465
+ CNPG_NAMESPACE="cnpg-operands"
466
+ CNPG_SVC_ACCT="$CNPG_NAMESPACE-sa"
467
+ CNPG_SVC_EMAIL="$CNPG_SVC_ACCT@$GCP_PROJECT_ID.iam.gserviceaccount.com"
468
+
469
+ kubectl delete serviceaccounts -n $CNPG_NAMESPACE $CNPG_SVC_ACCT &> $DEVNULL
470
+ gcloud --quiet iam service-accounts delete $CNPG_SVC_EMAIL --project $GCP_PROJECT_ID&> $DEVNULL
471
+
472
+ createNamespaceIfNeeded $CNPG_NAMESPACE
473
+
474
+ # Create GCP SA and bind policies
475
+ printf "\nCreating the gcloud $CNPG_SVC_ACCT service account (SA)\n"
476
+ gcloud iam service-accounts create $CNPG_SVC_ACCT \
477
+ --project "$GCP_PROJECT_ID" \
478
+ --description "CNPG Operands SA" \
479
+ --display-name "CNPG Operands SA" &> $DEVNULL
480
+ warnOnError $? "the GCP SA $CNPG_SVC_ACCT may already exist"
481
+
482
+ CNPG_OPS_ROLE="cnpg.operands"
483
+ printf "\nCreating the $CNPG_OPS_ROLE IAM role\n"
484
+ ## Attach roles
485
+ ROLE_PERMISSIONS=(
486
+ iam.serviceAccounts.actAs
487
+ iam.serviceAccounts.getAccessToken
488
+ iam.serviceAccounts.signBlob
489
+ orgpolicy.policy.get
490
+ resourcemanager.projects.get
491
+ storage.buckets.create
492
+ storage.buckets.get
493
+ storage.buckets.getIamPolicy
494
+ storage.buckets.list
495
+ storage.buckets.update
496
+ storage.objects.create
497
+ storage.objects.delete
498
+ storage.objects.get
499
+ storage.objects.getIamPolicy
500
+ storage.objects.list
501
+ )
502
+ gcloud iam roles create $CNPG_OPS_ROLE \
503
+ --project $GCP_PROJECT_ID \
504
+ --title "CNPG Operands" \
505
+ --description "CNPG Operands" \
506
+ --permissions "$(IFS=","; echo "${ROLE_PERMISSIONS[*]}")" &> $DEVNULL
507
+ if [ $? -ne 0 ];
508
+ then
509
+ # assume error is that role exists so try updating instead
510
+ printf "\nUpdating roles on the SA\n"
511
+ gcloud iam roles update $CNPG_OPS_ROLE \
512
+ --project $GCP_PROJECT_ID \
513
+ --title "CNPG Operands" \
514
+ --permissions "$(IFS=","; echo "${ROLE_PERMISSIONS[*]}")" &> $DEVNULL
515
+ fi
516
+ warnOnError $? "Failed to add roles to $CNPG_OPS_ROLE - perhaps they already exist?"
517
+
518
+ printf "\nBinding IAM role to the SA\n"
519
+ gcloud projects add-iam-policy-binding $GCP_PROJECT_ID \
520
+ --project $GCP_PROJECT_ID \
521
+ --member serviceAccount:$CNPG_SVC_EMAIL \
522
+ --condition 'None' \
523
+ --role "roles/owner" &> $DEVNULL # temp bind to Owner
524
+ # --role "roles/storage.admin" &> $DEVNULL
525
+ # --role "roles/owner" &> $DEVNULL
526
+ # --role projects/$GCP_PROJECT_ID/roles/$CNPG_OPS_ROLE &> $DEVNULL
527
+ warnOnError $? "gcloud problem binding IAM policy"
528
+
529
+ sleep 2 # give the IAM binding a chance to complete before moving on
530
+
531
+ bindWorkloadIdentity $CNPG_SVC_ACCT $CNPG_NAMESPACE
532
+
533
+ gsutil iam ch serviceAccount:$CNPG_SVC_EMAIL:objectAdmin gs://$GCP_PROJECT_ID-barman
534
+ }
535
+
459
536
  function installVeleroEnvironment() {
460
537
  # Follows instructions => https://github.com/vmware-tanzu/velero-plugin-for-gcp
461
538
  showInstalling "Velero Backup Management"
@@ -660,6 +737,11 @@ CATBACKUP
660
737
  bootstrapLocalSetup $SERVICE
661
738
  ;;
662
739
 
740
+ "cnpg-operator")
741
+ installCnpgOperatorEnvironment
742
+ bootstrapLocalSetup $SERVICE
743
+ ;;
744
+
663
745
  "cronZombieKiller"|"zombie-killer")
664
746
  installCronZombieKiller # eradicate the gke 1.20+ zombies
665
747
  ;;
package/src/overwhelm.mjs CHANGED
@@ -82,7 +82,7 @@ debug( { over, yaml, }, '<==Contents of the over and yaml structs' )
82
82
  let cfgs = yaml[context]
83
83
 
84
84
  // If we just need to check context return 0 if cfgs exists, else error.
85
- if ( args.checkctx ) { process.exit( !cfgs ) }
85
+ if ( args.checkctx ) { process.exit( !cfgs ? 1 : 0 ) }
86
86
 
87
87
  if ( !cfgs ) {
88
88
  log( `***ERROR: Unknown context => [${context}]\n` )