@leverege/build-tools 2.80.1-beta.2 → 2.81.1

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.
Files changed (29) hide show
  1. package/.vscode/launch.json +22 -0
  2. package/package.json +5 -4
  3. package/src/Utils.mjs +2 -2
  4. package/src/helm-charts/argocd/.nohelm +0 -0
  5. package/src/helm-charts/argocd/.nohelmdn +0 -0
  6. package/src/helm-charts/argocd/helmup.bootstrap +3 -0
  7. package/src/helm-charts/argocd/helmup.plugin +3 -0
  8. package/src/helm-charts/cnpg-db-pgbench/helmup.bootstrap +11 -0
  9. package/src/helm-charts/cnpg-db-psql-stack/helmup.bootstrap +11 -0
  10. package/src/helm-charts/cnpg-db-psql-stack/helmup.plugin +1 -1
  11. package/src/helm-charts/cnpg-db-recovery/helmup.bootstrap +11 -0
  12. package/src/helm-charts/cnpg-db-recovery/helmup.plugin +1 -1
  13. package/src/helm-charts/cnpg-db-tsdb-basic/helmup.bootstrap +11 -0
  14. package/src/helm-charts/cnpg-db-tsdb-basic/helmup.plugin +1 -1
  15. package/src/helm-charts/cnpg-db-tsdb-dense/helmup.bootstrap +11 -0
  16. package/src/helm-charts/cnpg-db-tsdb-dense/helmup.plugin +1 -1
  17. package/src/helm-charts/cnpg-operator/helmdn.plugin +1 -1
  18. package/src/helm-charts/cnpg-operator/helmup.bootstrap +201 -0
  19. package/src/helm-charts/cnpg-operator/helmup.plugin +1 -1
  20. package/src/helm-charts/cnpg-operator/operand.bootstrap +41 -0
  21. package/src/helm-charts/pgbouncer/helmup.bootstrap +24 -0
  22. package/src/helm-charts/prom-operator/helmup.bootstrap +47 -0
  23. package/src/helm-charts/prom-operator/rules/traefik-rules.yaml +2 -2
  24. package/src/helm-charts/traefik/values-local.yaml +1 -1
  25. package/src/helm-charts/velero/helmup.bootstrap +104 -0
  26. package/src/helmdn.sh +2 -1
  27. package/src/helmup.sh +36 -582
  28. package/src/init-my-chart.mjs +18 -0
  29. package/.vscode/settings.json +0 -3
package/src/helmup.sh CHANGED
@@ -37,6 +37,7 @@ PLATFORM=(
37
37
  )
38
38
 
39
39
  AUXILIARY=(
40
+ argocd
40
41
  fota-server
41
42
  geotile-server
42
43
  overdose
@@ -48,8 +49,15 @@ AUXILIARY=(
48
49
  vin-decoder-server
49
50
  )
50
51
 
51
- # zombie-killer re-enabled 20240801
52
+ # There's a chicken / egg situation that arises with new clusters in that
53
+ # traefik wants to enable a prometheus service monitor, but the prom operator
54
+ # CRDs are yet to be installed - and the operator wants to define a traefik
55
+ # route for grafana so traefik needs to exist early. Note, this is only a
56
+ # problem on clean installs where the CRDs for those services are not yet
57
+ # installed.
52
58
  SYSTEM=(
59
+ traefik
60
+ prom-operator
53
61
  elasticsearch8
54
62
  redis
55
63
  cnpg-operator
@@ -57,30 +65,21 @@ SYSTEM=(
57
65
  zombie-killer
58
66
  reflector
59
67
  reloader
60
- traefik
61
68
  velero
62
69
  cnpg-db-psql-stack
63
70
  cnpg-db-tsdb-basic
64
- prom-operator
65
71
  )
66
72
 
67
73
  SYSTEM_LEGACY=(
68
- elasticsearch8
69
- redis
74
+ elasticsearch
70
75
  postgres
71
76
  timescale-db
72
- preemptible-killer
73
- zombie-killer
74
- reflector
75
- reloader
76
- traefik
77
- velero
78
77
  monitoring # do monitoring last to show password
79
78
  )
80
79
 
81
80
  function isLeveregeService() {
82
81
  local answer=0
83
- [[ ${PLATFORM[@]} =~ $1 || ${AUXILIARY[@]} =~ $1 || ${SYSTEM_LEGACY[@]}} =~ 1 || ${SYSTEM[@]} =~ $1 ]] && answer=1
82
+ [[ ${PLATFORM[@]} =~ $1 || ${AUXILIARY[@]} =~ $1 || ${SYSTEM_LEGACY[@]}} =~ $1 || ${SYSTEM[@]} =~ $1 ]] && answer=1
84
83
  echo $answer
85
84
  }
86
85
 
@@ -199,30 +198,9 @@ function setupStackBuckets() {
199
198
  makeUniformBucketWithCors geotile-server PUBLIC
200
199
  }
201
200
 
202
- function setupPgbouncerSecret() {
203
- # pgbouncer uses a k8s secret for the user access list which is in the form
204
- # of => "user" "password" - this function will create the pgbouncer secret
205
- # if it does not exist by pulling the password from the PG_PASSWORD secret
206
- # managed by the Google Secret Manager service.
207
- USERLIST_SECRET='pgbouncer-userlist-secret'
208
- kubectl get secret $USERLIST_SECRET &> $DEVNULL
209
- [[ $? -eq 0 ]] && return # already exists - bail
210
-
211
- cat<<PGB_SECRET
212
-
213
- `color y "Creatng $USERLIST_SECRET k8s secret from secret manager PG_PASSWORD secret..."`
214
-
215
- PGB_SECRET
216
- DECODED_PSQL_PASSWORD=$(gcloud secrets versions access latest --secret=PG_PASSWORD --project $GCP_PROJECT_ID)
217
- exitOnError $? "Failed to fetch PG_PASSWORD from the secret manager"
218
-
219
- kubectl create secret generic $USERLIST_SECRET --from-literal=userlist.txt="\"postgres\" \"$DECODED_PSQL_PASSWORD\""
220
- exitOnError $? "Failed to create the $USERLIST_SECRET k8s secret"
221
- }
222
-
223
201
  function doPlatormPreInstallChecks() {
224
202
  # This is where we handle platform specific things that need to be setup,
225
- # usuall once, and then promptly forgotten about.
203
+ # usually once, and then promptly forgotten about.
226
204
  setupStackBuckets
227
205
  }
228
206
 
@@ -265,8 +243,25 @@ MISSING_HELMUP_PLUGIN
265
243
  cp -a $SERVICE_CHART .
266
244
  # because npm tends to not allow .gitinore files the easy way...
267
245
  find $SERVICE -type f -name "gitignore" -execdir mv {} .gitignore \;
268
- git add $SERVICE
269
246
  overwhelm --genvals
247
+ FIRST_RUN="$SERVICE/helmup.bootstrap"
248
+ if [ -f "$FIRST_RUN" ];
249
+ then
250
+ [ ! -x "$FIRST_RUN" ] && chmod +x "$FIRST_RUN" # force it to be executable
251
+ cat<<SERVICE_BOOTSTRAP
252
+
253
+ `color y "*** Bootstrapping $SERVICE with =>"` `color g "$FIRST_RUN"`
254
+
255
+ SERVICE_BOOTSTRAP
256
+
257
+ . "$FIRST_RUN"
258
+ if [[ $? = 1 ]];
259
+ then
260
+ rm -rf "$SERVICE"
261
+ exit 1
262
+ fi
263
+ fi
264
+ git add $SERVICE
270
265
  ifPluggedIn $SERVICE
271
266
  }
272
267
 
@@ -298,110 +293,6 @@ function errorIfMissingSecret() {
298
293
  fi
299
294
  }
300
295
 
301
- function installFirebaseDatabases() {
302
- showInstalling "Firebase Realtime Databases"
303
-
304
- open https://console.firebase.google.com/u/0/project/${GCP_PROJECT_ID}/authentication/users
305
- yesToContinue "when you have pressed Get Started on the Firebase Authentication page"
306
-
307
- # create the firebase primary db
308
- firebase --project $GCP_PROJECT_ID database:instances:create ${PROJECT}
309
-
310
- # TODO: should maybe be more flexible with number of shards in the future
311
- for SHARD in {0..9}
312
- do
313
- SHARD="${GCP_PROJECT_ID}-rt-${SHARD}"
314
- printf "Creating shard $SHARD\n"
315
- firebase --project $GCP_PROJECT_ID database:instances:create ${SHARD}
316
- done
317
- }
318
-
319
- function installStackdriverExporterEnvironment() {
320
- showInstalling "Stackdriver Exporter Service Account Binding"
321
-
322
- # Add necessary helm repositories - note that stable is deprecated
323
- addHelmRepo prometheus-community https://prometheus-community.github.io/helm-charts
324
-
325
- local SDEXP_NS=${1:-monitoring}
326
- local SDEXP_SA="stackdriver-exporter"
327
- local SDEXP_EM="$SDEXP_SA@$GCP_PROJECT_ID.iam.gserviceaccount.com"
328
-
329
- createNamespaceIfNeeded $SDEXP_NS
330
-
331
- # guarantee any previous remnants of the exporter are gone
332
- printf "\n*** Removing the previous $SDEXP_SA installation...\n"
333
- helm uninstall -n $SDEXP_NS $SDEXP_SA &> $DEVNULL
334
- kubectl delete serviceaccounts -n $SDEXP_NS $SDEXP_SA &> $DEVNULL
335
- printf "!!! Skipping deletion of the gcloud SA $SDEXP_EM\n"
336
- # gcloud --quiet iam service-accounts delete $SDEXP_EM &> $DEVNULL
337
-
338
- # NOTE: The k8s SA != GCP SA - the former is created by the helm chart
339
- # that installs the stackdriver-exporter, the latter is handled here in
340
- # order to provide the proper IAM permissions to the exporter.
341
-
342
- # Create GCP SA and bind policies
343
- printf "\n*** Creating GCP SA with $SDEXP_NS/viewer ***\n"
344
- gcloud iam service-accounts create $SDEXP_SA \
345
- --project "$GCP_PROJECT_ID" \
346
- --display-name "Prometheus Stackdriver Exporter" &> $DEVNULL
347
- warnOnError $? "the GCP SA $SDEXP_SA may already exist"
348
-
349
- printf "\n*** Binding IAM role of $SDEXP_NS viewer to $SDEXP_SA in $GCP_PROJECT_ID\n"
350
- gcloud projects add-iam-policy-binding "$GCP_PROJECT_ID" \
351
- --role "roles/monitoring.viewer" \
352
- --member "serviceAccount:$SDEXP_EM" &> $DEVNULL
353
- sleep 2 # give the IAM binding a chance to complete before moving on
354
-
355
- bindWorkloadIdentity $SDEXP_SA $SDEXP_NS
356
-
357
- removeHelmRepo prometheus-community
358
- }
359
-
360
- function installMonitoringEnvironment() {
361
- showInstalling "Monitoring Components"
362
- createNamespaceIfNeeded monitoring
363
-
364
- ## Install Stackdriver Exporter
365
- installStackdriverExporterEnvironment
366
- bootstrapLocalSetup stackdriver-exporter
367
-
368
- # Add necessary helm repositories - note that stable is deprecated
369
- addHelmRepo prometheus-community https://prometheus-community.github.io/helm-charts
370
-
371
- ## Install Prometheus
372
- bootstrapLocalSetup prometheus
373
-
374
- ## Install Grafana
375
- bootstrapLocalSetup grafana
376
-
377
- ## Clean up
378
- removeHelmRepo prometheus-community
379
- }
380
-
381
- function monitoringHelp() {
382
- MONPASS=`kubectl get secret --namespace monitoring grafana -o jsonpath='{.data.admin-password}' | base64 --decode`
383
-
384
- cat<<ACCESS
385
- `color g "Proxy to Prometheus (manage targets, configs, alerts):"`
386
- export POD_NAME=\$(kubectl get pods --namespace monitoring -l 'app=prometheus,component=server' -o jsonpath='{.items[0].metadata.name}')
387
- kubectl --namespace monitoring port-forward \$POD_NAME 9090
388
-
389
- `color g "Proxy to Alertmanager (manage alert notification, silences):"`
390
- export POD_NAME=\$(kubectl get pods --namespace monitoring -l 'app=prometheus,component=alertmanager' -o jsonpath='{.items[0].metadata.name}')
391
- kubectl --namespace monitoring port-forward \$POD_NAME 9093
392
-
393
- `color g "Proxy to Grafana (the charts you're looking for):"`
394
- export GRAFANA_POD=\$(kubectl --namespace monitoring get pods -l 'app.kubernetes.io/instance=grafana' -o jsonpath='{.items[0].metadata.name}')
395
- kubectl --namespace monitoring port-forward \$GRAFANA_POD 3000 &
396
- sleep 2; open http://localhost:3000
397
-
398
- `color toast "Save monitoring login to Keeper"` => `color r "admin / $MONPASS"`
399
-
400
- `color g "Show this helpful message again with"` => `color r "helmup monitoring-wtf"`
401
-
402
- ACCESS
403
- }
404
-
405
296
  # https://github.com/estafette/estafette-gke-preemptible-killer
406
297
  function installPreemptibleKiller() {
407
298
  showInstalling "Preemptible Node Killing Coordinator"
@@ -514,34 +405,6 @@ status: {}
514
405
  END_OF_ZOMBIE
515
406
  }
516
407
 
517
- function installCertManagerSecret() {
518
- showInstalling "Cert Managment"
519
- createNamespaceIfNeeded cert-manager
520
-
521
- local NSPACE="default"
522
- kubectl get secret cloudflare --namespace $NSPACE &> $DEVNULL
523
- if [[ $? -eq 1 ]];
524
- then
525
- cat<<NEED_MANAGED_SECRET
526
- $RED_ERROR missing secret: `color y cloudflare` namespace: `color y $NSPACE`
527
-
528
- This secret will be fetched from the leverege-docker-images cluster and
529
- injected into this cluster.
530
- NEED_MANAGED_SECRET
531
- #yesToContinue "to copy and inject the cloudflare secret"
532
- TOKEN=$(getManagedSecret "CLOUDFLARE_API_TOKEN")
533
- if [ $? -ne 0 ];
534
- then
535
- printf "$RED_ERROR getManagedSecret reponse=>[$TOKEN]"
536
- exitOnError 1 "Failed to fetch the secret from leverege-docker-images"
537
- fi
538
- printf "\nInjecting=[$TOKEN] into cloudflare secret\n"
539
- kubectl create secret generic cloudflare \
540
- --namespace $NSPACE \
541
- --from-literal=dns-token=$TOKEN
542
- fi
543
- }
544
-
545
408
  # See => https://github.com/emberstack/kubernetes-reflector
546
409
  function reflectSecretIntoNamespaces() {
547
410
  local SECRET="$1"
@@ -566,238 +429,8 @@ metadata:
566
429
  REFLECTED_SECRET
567
430
  }
568
431
 
569
- # This function is used to randomly generate the postgresql database passwords
570
- # for the postgres and imagine users in a cnpg operator configuration. Since
571
- # the resultant passwords will live in the cnpg-operands namespace they will
572
- # be mirrored to the default namespace via the reflector service. Lastly, the
573
- # service account will have workload identity bound to it in the cnpg-operands
574
- # namespace.
575
- function initializeCnpgOperand() {
576
- local CNPG_SERVICE="$1"
577
- local CNPG_NAMESPACE="cnpg-operands"
578
- local CNPG_SVC_ACCT="$CNPG_NAMESPACE-sa"
579
- local IMAGINE_PW_NAME="$CNPG_SERVICE-imagine-pw"
580
- local POSTGRES_PW_NAME="$CNPG_SERVICE-postgres-pw"
581
-
582
- # TODO: we use postgres root password for access - that is bad - fix it?
583
- # printf "\nCreating imagine db password for `color g $CNPG_SERVICE`\n"
584
- # kubectl create secret generic -n $CNPG_NAMESPACE "$IMAGINE_PW_NAME" \
585
- # --from-literal=username="imagine" \
586
- # --from-literal=password="$(generatePassword)" &> $DEVNULL
587
- # warnOnError $? "the `color y $IMAGINE_PW_NAME` secret may already exist"
588
-
589
- # # reflect the secret to default namespace
590
- # reflectSecretIntoNamespaces $IMAGINE_PW_NAME $CNPG_NAMESPACE "default"
591
-
592
- printf "\nCreating postgres db password for `color g $CNPG_SERVICE`\n"
593
- kubectl create secret generic -n $CNPG_NAMESPACE "$POSTGRES_PW_NAME" \
594
- --from-literal=username="postgres" \
595
- --from-literal=password="$(generatePassword)" &> $DEVNULL
596
- warnOnError $? "the `color y $POSTGRES_PW_NAME` secret may already exist"
597
-
598
- # reflect the secret to default namespace
599
- reflectSecretIntoNamespaces $POSTGRES_PW_NAME $CNPG_NAMESPACE "default"
600
-
601
- printf "\nBinding `color g $CNPG_SERVICE` to the `color y "$CNPG_SVC_ACCT"` SA\n"
602
- bindWorkloadIdentity $CNPG_SVC_ACCT $CNPG_NAMESPACE $CNPG_SERVICE
603
- }
604
-
605
- function installCnpgOperatorEnvironment() {
606
- # See => https://github.com/cloudnative-pg/charts
607
-
608
- gcloud config set project $GCP_PROJECT_ID
609
-
610
- # create an SA in the cnpg namespace for the operands to bind to
611
- CNPG_NAMESPACE="cnpg-operands"
612
- CNPG_SVC_ACCT="$CNPG_NAMESPACE-sa"
613
- CNPG_SVC_EMAIL="$CNPG_SVC_ACCT@$GCP_PROJECT_ID.iam.gserviceaccount.com"
614
-
615
- # We used to delete the SA when we were doing clean installs but that bit
616
- # me in the ass the time I moved the operator dir out of the way to run
617
- # helmwhat to populate with latest operator version. The result? The SA
618
- # was deleted and recreated and the existing system lost the ability to
619
- # write to GCS which resulted in WAL failures. The deletion / recreation
620
- # logic was only useful in the early days of creating / deleting for
621
- # initial development.
622
- #
623
- # Synopsis: deleting an SA from an actual non-test system is BAD NEWS
624
- # and if it happens then you will need to rebind the SA to
625
- # workload identity by hand.
626
- #
627
- # kubectl delete serviceaccounts -n $CNPG_NAMESPACE $CNPG_SVC_ACCT &> $DEVNULL
628
- # gcloud --quiet iam service-accounts delete $CNPG_SVC_EMAIL --project $GCP_PROJECT_ID&> $DEVNULL
629
- kubectl describe serviceaccounts -n $CNPG_NAMESPACE $CNPG_SVC_ACCT &> $DEVNULL
630
- if [ $? -eq 0 ];
631
- then
632
- cat<<SKIP_CNPG_SA_CREATION
633
-
634
- $YELO_WARN The CNPG SA $CNPG_SVC_ACCT already exists
635
-
636
- Deleting the SA for the purposes of upgrading the operator is going to
637
- wreck someone's day (probably yours) if the desire is to simply upgrade
638
- in place. To force a clean reinstall, delete both the k8s and gcp SA for
639
- CNPG and try again. (see comments in helmup for more info)
640
-
641
- SKIP_CNPG_SA_CREATION
642
- return
643
- fi
644
-
645
- # Create the operands namespace and annotate to allow redis access
646
- createNamespaceIfNeeded $CNPG_NAMESPACE
647
-
648
- # Create GCP SA and bind policies
649
- printf "\nCreating the gcloud `color g $CNPG_SVC_ACCT` service account (SA)\n"
650
- gcloud iam service-accounts create $CNPG_SVC_ACCT \
651
- --project "$GCP_PROJECT_ID" \
652
- --description "CNPG Operands SA" \
653
- --display-name "CNPG Operands SA" &> $DEVNULL
654
- warnOnError $? "the GCP SA `color y $CNPG_SVC_ACCT` may already exist"
655
-
656
- CNPG_OPS_ROLE="cnpg.operands"
657
- printf "\nCreating the `color g $CNPG_OPS_ROLE` IAM role\n"
658
- ## Attach roles
659
- ROLE_PERMISSIONS=(
660
- iam.serviceAccounts.actAs
661
- iam.serviceAccounts.get
662
- iam.serviceAccounts.getAccessToken
663
- iam.serviceAccounts.getOpenIdToken
664
- iam.serviceAccounts.implicitDelegation
665
- iam.serviceAccounts.list
666
- iam.serviceAccounts.signBlob
667
- iam.serviceAccounts.signJwt
668
- resourcemanager.projects.get
669
- storage.buckets.create
670
- storage.buckets.get
671
- storage.buckets.getIamPolicy
672
- storage.buckets.list
673
- storage.buckets.update
674
- storage.objects.create
675
- storage.objects.delete
676
- storage.objects.get
677
- storage.objects.getIamPolicy
678
- storage.objects.list
679
- )
680
- gcloud iam roles create $CNPG_OPS_ROLE \
681
- --project $GCP_PROJECT_ID \
682
- --title "CNPG Operands" \
683
- --description "CNPG Operands" \
684
- --permissions "$(IFS=","; echo "${ROLE_PERMISSIONS[*]}")" &> $DEVNULL
685
- if [ $? -ne 0 ];
686
- then
687
- # assume error is that role exists so try updating instead
688
- printf "\nUpdating the permissions on the `color g $CNPG_OPS_ROLE` IAM role\n"
689
- gcloud iam roles update $CNPG_OPS_ROLE \
690
- --project $GCP_PROJECT_ID \
691
- --title "CNPG Operands" \
692
- --permissions "$(IFS=","; echo "${ROLE_PERMISSIONS[*]}")" &> $DEVNULL
693
- fi
694
- warnOnError $? "Failed to add roles to $CNPG_OPS_ROLE - perhaps they already exist?"
695
-
696
- printf "\nBinding IAM role to the SA `color g $CNPG_SVC_EMAIL`\n"
697
- gcloud projects add-iam-policy-binding $GCP_PROJECT_ID \
698
- --member="serviceAccount:$CNPG_SVC_EMAIL" \
699
- --role "roles/storage.admin" &> $DEVNULL
700
- # --role projects/$GCP_PROJECT_ID/roles/$CNPG_OPS_ROLE &> $DEVNULL
701
- # --role "roles/storage.admin" &> $DEVNULL
702
- warnOnError $? "gcloud problem binding IAM policy"
703
-
704
- printf "\nBinding IAM the Token Creator role to the SA `color g $CNPG_SVC_EMAIL`\n"
705
- gcloud projects add-iam-policy-binding $GCP_PROJECT_ID \
706
- --member="serviceAccount:$CNPG_SVC_EMAIL" \
707
- --role="roles/iam.serviceAccountTokenCreator"
708
-
709
- # workload binding will be performed by each cnpg operand on startup
710
-
711
- BARMAN_BUCKET="gs://$GCP_PROJECT_ID-barman"
712
- gsutil ls -p $GCP_PROJECT_ID -b $BARMAN_BUCKET &> $DEVNULL
713
- if [ "$?" -eq 0 ];
714
- then
715
- printf "\nBarman bucket `color g "$BARMAN_BUCKET"` already exists - skipping recreation\n"
716
- else
717
- printf "\nCreating a bucket for barman backups: `color g $BARMAN_BUCKET`\n"
718
- gsutil mb -l $GCE_REGION $BARMAN_BUCKET &> $DEVNULL
719
- gsutil iam ch serviceAccount:$CNPG_SVC_EMAIL:objectAdmin $BARMAN_BUCKET
720
- gsutil ubla set on $BARMAN_BUCKET # uniform bucket access
721
- fi
722
-
723
- # define the snapshot storage class
724
- printf "\nApplying the CNPG VolumeSnapshotClass `color g cnpg-snapshotclass` definition\n"
725
- cat<<EOSNAPSC | kubectl apply -f -
726
- apiVersion: snapshot.storage.k8s.io/v1
727
- kind: VolumeSnapshotClass
728
- metadata:
729
- name: cnpg-snapshotclass
730
- driver: pd.csi.storage.gke.io
731
- deletionPolicy: Retain
732
- EOSNAPSC
733
-
734
- sleep 2 # hold up processing for a moment to allow IAM mods to propagate
735
- }
736
-
737
- # this function is a little convoluted in the way it attempts to install the
738
- # scripts and yaml necessary for the CNPG cleanup activities - the idea is to
739
- # be able to update the scripts without touching anything else since the target
740
- # directory is the cnpg-operator setup
741
- function installCnpgCleanupCronjob() {
742
- CNPG_OPERATOR_DIR="cnpg-operator"
743
- if [ ! -d "$CNPG_OPERATOR_DIR" ];
744
- then
745
- cat<<CNPG_OPERATOR_MISSING
746
- `color r "The cnpg-operator must be installed before proceeding"`
747
-
748
- CNPG_OPERATOR_MISSING
749
- exit 1
750
- fi
751
-
752
- # create the destination bucket for k8s cronjob scripts
753
- BUCKET_SUFFIX="k8s-cronjobs"
754
- makeUniformBucketWithCors $BUCKET_SUFFIX
755
-
756
- CNPG_CLEANUP_CRONJOB_OVH="cnpg-cleanup-cronjob.yaml.ovh"
757
- CNPG_CLEANUP_CRONJOB="$CNPG_OPERATOR_DIR/$CNPG_CLEANUP_CRONJOB_OVH"
758
- CNPG_CLEANUP_SCRIPT_BASH="cnpg-cleanup-script.sh"
759
- CNPG_CLEANUP_SCRIPT="$CNPG_OPERATOR_DIR/$CNPG_CLEANUP_SCRIPT_BASH"
760
- if [ ! -f "$CNPG_CLEANUP_SCRIPT" ];
761
- then
762
- cat<<CNPG_FETCH_CLEANUP_CRONJOB_YAML
763
- `color y "Missing $CNPG_CLEANUP_SCRIPT_BASH - updating local cron setup scripts"`
764
-
765
- CNPG_FETCH_CLEANUP_CRONJOB_YAML
766
- CNPG_OP_ROOT="$(build-tools --reporoot)/src/helm-charts/cnpg-operator"
767
- cp $CNPG_OP_ROOT/$CNPG_CLEANUP_CRONJOB_OVH $CNPG_CLEANUP_CRONJOB
768
- cp $CNPG_OP_ROOT/$CNPG_CLEANUP_SCRIPT_BASH $CNPG_CLEANUP_SCRIPT
769
- fi
770
-
771
- # copy / update the script in the bucket referenced in the cronjob
772
- printf "\ngsutil cp $CNPG_CLEANUP_SCRIPT gs://$GCP_PROJECT_ID-$BUCKET_SUFFIX\n"
773
- gsutil cp $CNPG_CLEANUP_SCRIPT gs://$GCP_PROJECT_ID-$BUCKET_SUFFIX
774
-
775
- local CNPG_NAMESPACE="cnpg-operands"
776
- local CNPG_CLEANUP_SA="cnpg-cleanup-sa"
777
-
778
- gcloud iam service-accounts create "$CNPG_CLEANUP_SA" \
779
- --project="$GCP_PROJECT_ID" \
780
- --description="Used for cronjob cleanup with Workload Identity" \
781
- --display-name="CNPG Cleanup SA" &> $DEVNULL
782
- warnOnError $? "the GCP SA $CNPG_CLEANUP_SA may already exist"
783
-
784
- gcloud projects add-iam-policy-binding "$GCP_PROJECT_ID" \
785
- --project="$GCP_PROJECT_ID" \
786
- --member="serviceAccount:$CNPG_CLEANUP_SA@$GCP_PROJECT_ID.iam.gserviceaccount.com" \
787
- --role="roles/storage.objectViewer"
788
-
789
- bindWorkloadIdentity "$CNPG_CLEANUP_SA" "$CNPG_NAMESPACE"
790
-
791
- CNPG_CLEANUP_CRONJOB_YAML="$CNPG_OPERATOR_DIR/$(basename $CNPG_CLEANUP_CRONJOB_OVH .ovh)"
792
- overwhelm -g # allow ovh -> yaml to occur
793
- cat<<CNPG_CLEANUP_CRONJOB_APPLY
794
- `color g "Creating cronjob =>"``color y " kubectl apply -f $CNPG_CLEANUP_CRONJOB_YAML"`
795
-
796
- CNPG_CLEANUP_CRONJOB_APPLY
797
- kubectl apply -f $CNPG_CLEANUP_CRONJOB_YAML
798
- }
799
-
800
- function ensureCnpgSecret() {
432
+ # uses service-man to synchronize a secret manager secret with its k8s counterpart
433
+ function synchronizeSecrets() {
801
434
  local mgrSecret=$1
802
435
  local k8sSecret=$2
803
436
 
@@ -814,105 +447,6 @@ BAD_SECRETS
814
447
  fi
815
448
  }
816
449
 
817
- function installVeleroEnvironment() {
818
- # Follows instructions => https://github.com/vmware-tanzu/velero-plugin-for-gcp
819
- showInstalling "Velero Backup Management"
820
- createNamespaceIfNeeded velero
821
-
822
- # Do we need to => gcloud auth application-default
823
- gcloud config set project $GCP_PROJECT_ID
824
-
825
- ## The major chart version will determine the bucket suffix
826
- [ -z "$VELERO_CHART_VERSION" ] && VELERO_CHART_VERSION="10"
827
-
828
- ## Create a bucket
829
- BUCKET="$GCP_PROJECT_ID-velero-$VELERO_CHART_VERSION"
830
- printf "\nCreating storage bucket `color g $BUCKET` in `color g $GCE_REGION`\n"
831
- gsutil mb -l $GCE_REGION gs://$BUCKET/ &> $DEVNULL
832
- warnOnError $? "Bucket failed to create or already exists - go check it\n"
833
- gsutil ubla set on gs://$BUCKET &> $DEVNULL
834
-
835
- ## Create a service account
836
- printf "\nCreating the service account\n"
837
- gcloud iam service-accounts create velero \
838
- --project $GCP_PROJECT_ID \
839
- --display-name "Velero service account" \
840
- --description "Velero service account" &> $DEVNULL
841
- if [ $? -eq 0 ];
842
- then
843
- # no error means a new SA was created - slight delay to let it update
844
- sleep 2
845
- else
846
- printf "$YELO_WARN Failed to create the service account - does it already exist?"
847
- fi
848
-
849
- SERVICE_ACCOUNT_EMAIL="velero@${GCP_PROJECT_ID}.iam.gserviceaccount.com"
850
-
851
- ## Attach roles
852
- ROLE_PERMISSIONS=(
853
- compute.disks.get
854
- compute.disks.create
855
- compute.disks.createSnapshot
856
- compute.projects.get
857
- compute.snapshots.get
858
- compute.snapshots.create
859
- compute.snapshots.useReadOnly
860
- compute.snapshots.delete
861
- compute.zones.get
862
- iam.serviceAccounts.actAs
863
- iam.serviceAccounts.signBlob
864
- storage.objects.create
865
- storage.objects.delete
866
- storage.objects.get
867
- storage.objects.list
868
- )
869
-
870
- printf "\nAssigning roles to the SA\n"
871
- gcloud iam roles create velero.server \
872
- --project $GCP_PROJECT_ID \
873
- --title "Velero Server" \
874
- --permissions "$(IFS=","; echo "${ROLE_PERMISSIONS[*]}")" &> $DEVNULL
875
- if [ $? -ne 0 ];
876
- then
877
- # assume error is that role exists so try updating instead
878
- printf "\nUpdating roles on the SA\n"
879
- gcloud iam roles update velero.server \
880
- --project $GCP_PROJECT_ID \
881
- --title "Velero Server" \
882
- --permissions "$(IFS=","; echo "${ROLE_PERMISSIONS[*]}")" &> $DEVNULL
883
- fi
884
- warnOnError $? "Failed to add roles to velero.server - perhaps they already exist?"
885
-
886
- printf "\nBinding IAM policy to the SA\n"
887
- gcloud projects add-iam-policy-binding $GCP_PROJECT_ID \
888
- --project $GCP_PROJECT_ID \
889
- --member serviceAccount:$SERVICE_ACCOUNT_EMAIL \
890
- --condition 'None' \
891
- --role projects/$GCP_PROJECT_ID/roles/velero.server &> $DEVNULL
892
- warnOnError $? "gcloud problem binding IAM policy"
893
-
894
- printf "\nBinding workload identity IAM policy to the SA\n"
895
- gcloud iam service-accounts add-iam-policy-binding \
896
- --member "serviceAccount:$GCP_PROJECT_ID.svc.id.goog[velero/velero]" \
897
- --role roles/iam.workloadIdentityUser \
898
- $SERVICE_ACCOUNT_EMAIL
899
- warnOnError $? "gcloud workload identity binding may have failed"
900
-
901
- printf "\nCreate and annotate the k8s SA\n"
902
- kubectl create serviceaccount velero --namespace velero
903
- warnOnError $? "Failed to create k8s SA - perhaps it already exists?"
904
-
905
- kubectl annotate serviceaccount velero \
906
- --namespace velero \
907
- "iam.gke.io/gcp-service-account=$SERVICE_ACCOUNT_EMAIL"
908
- warnOnError $? "Failed to annotate k8s SA - things may fail"
909
-
910
- gsutil iam ch serviceAccount:$SERVICE_ACCOUNT_EMAIL:objectAdmin gs://$BUCKET
911
-
912
- ## Clean up from previous failed install
913
- kubectl delete volumesnapshotlocation.velero.io -n velero gcp &> $DEVNULL
914
- }
915
-
916
450
  function getServiceAndChartVersion() {
917
451
  SERVICE=
918
452
  CHARTVER=
@@ -1056,65 +590,31 @@ CATBACKUP
1056
590
  doInstall "${PLATFORM[@]}"
1057
591
  ;;
1058
592
 
1059
- "system-legacy")
1060
- doInstall "${SYSTEM_LEGACY[@]}"
1061
- ;;
1062
-
1063
593
  "system")
1064
594
  doInstall "${SYSTEM[@]}"
1065
595
  ;;
1066
596
 
1067
- "cert-manager")
1068
- installCertManagerSecret
597
+ "argocd")
1069
598
  bootstrapLocalSetup $SERVICE
1070
599
  ;;
1071
600
 
1072
601
  cnpg-db-*)
1073
- if [ ! -d $SERVICE ];
1074
- then
1075
- # this code only executes on the first deployment
1076
- initializeCnpgOperand $SERVICE
1077
- bootstrapLocalSetup $SERVICE
1078
- fi
602
+ bootstrapLocalSetup $SERVICE
1079
603
  ;;
1080
604
 
1081
605
  "cnpg-operator")
1082
- installCnpgOperatorEnvironment
1083
606
  bootstrapLocalSetup $SERVICE
1084
- installCnpgCleanupCronjob
1085
- ;;
1086
-
1087
- "cnpg-cronjob")
1088
- installCnpgCleanupCronjob
1089
607
  ;;
1090
608
 
1091
609
  "cronZombieKiller"|"zombie-killer")
1092
610
  installCronZombieKiller # eradicate the gke 1.20+ zombies
1093
611
  ;;
1094
612
 
1095
- "custom-metrics")
1096
- kubectl create -f https://raw.githubusercontent.com/GoogleCloudPlatform/k8s-stackdriver/master/custom-metrics-stackdriver-adapter/deploy/production/adapter.yaml
1097
- ;;
1098
-
1099
613
  default-configs*)
1100
614
  installDefaultConfigs
1101
615
  ;;
1102
616
 
1103
- "db-curator-dh")
1104
- # db-curator-dh is a variant of db-curator with diff controlled in values-local.yaml
1105
- HELMUP="helm upgrade --install $SERVICE leverege/db-curator --values $SERVICE/values.yaml $CHARTVER $HELM_WHAT"
1106
- doHelmup "$HELMUP"
1107
- ;;
1108
-
1109
- "elasticsearch") # simple 3 master v7.16 cluster
1110
- bootstrapLocalSetup $SERVICE
1111
- ;;
1112
-
1113
- "elasticsearch-cluster") # complex master/data/client ES cluster
1114
- bootstrapLocalSetup $SERVICE
1115
- ;;
1116
-
1117
- "elasticsearch8") # complex master/data/client ES v8 cluster
617
+ "elasticsearch8")
1118
618
  bootstrapLocalSetup $SERVICE
1119
619
  ;;
1120
620
 
@@ -1122,48 +622,15 @@ CATBACKUP
1122
622
  installPreemptibleKiller # the gke preemptible node spreader outer
1123
623
  ;;
1124
624
 
1125
- "firebase")
1126
- installFirebaseDatabases
1127
- bootstrapLocalSetup firebase-rules
1128
- ;;
1129
-
1130
- "grafana")
1131
- bootstrapLocalSetup $SERVICE
1132
- ;;
1133
-
1134
- "kube-prometheus-stack")
1135
- bootstrapLocalSetup $SERVICE
1136
- ;;
1137
-
1138
- "monitoring")
1139
- installMonitoringEnvironment
1140
- monitoringHelp
1141
- ;;
1142
-
1143
- "monitoring-wtf")
1144
- monitoringHelp && exit 0
1145
- ;;
1146
-
1147
625
  "platform-buckets")
1148
626
  setupStackBuckets && exit 0
1149
627
  ;;
1150
628
 
1151
629
  "pgbouncer")
1152
- setupPgbouncerSecret
1153
- bootstrapLocalSetup $SERVICE
1154
- ;;
1155
-
1156
- "postgres")
1157
- bootstrapLocalSetup $SERVICE
1158
- ;;
1159
-
1160
- "prometheus")
1161
- installStackdriverExporterEnvironment
1162
630
  bootstrapLocalSetup $SERVICE
1163
631
  ;;
1164
632
 
1165
633
  "prom-operator")
1166
- installStackdriverExporterEnvironment prometheus
1167
634
  bootstrapLocalSetup $SERVICE
1168
635
  ;;
1169
636
 
@@ -1185,15 +652,6 @@ CATBACKUP
1185
652
  removeHelmRepo stakater
1186
653
  ;;
1187
654
 
1188
- "stackdriver-exporter")
1189
- installStackdriverExporterEnvironment
1190
- bootstrapLocalSetup $SERVICE
1191
- ;;
1192
-
1193
- "timescale-db")
1194
- bootstrapLocalSetup $SERVICE
1195
- ;;
1196
-
1197
655
  transponder-*)
1198
656
  # transponders use the same chart but different deployment name
1199
657
  [ ! -d $SERVICE ] && bootstrapLocalSetup $SERVICE
@@ -1212,11 +670,7 @@ CATBACKUP
1212
670
  ;;
1213
671
 
1214
672
  "velero")
1215
- installVeleroEnvironment
1216
- bootstrapLocalSetup $SERVICE
1217
- ;;
1218
-
1219
- "vernemq")
673
+ # installVeleroEnvironment
1220
674
  bootstrapLocalSetup $SERVICE
1221
675
  ;;
1222
676