@leverege/build-tools 2.22.1 → 2.23.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leverege/build-tools",
3
- "version": "2.22.1",
3
+ "version": "2.23.1",
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
@@ -84,6 +84,15 @@ function getManagedSecret() {
84
84
  echo $SECRET
85
85
  }
86
86
 
87
+ function getProjectIdFromK8sContext() {
88
+ local currContext=`kubectl config current-context`
89
+
90
+ IFS='_'
91
+ read -ra ADDR <<< "$currContext"
92
+
93
+ echo ${ADDR[1]} # project id is the second string split by _
94
+ }
95
+
87
96
  function showInstalling() {
88
97
  cat<<INSTALLING
89
98
 
@@ -94,6 +103,16 @@ $(color y '=====================================================================
94
103
  INSTALLING
95
104
  }
96
105
 
106
+ function skipInstalling() {
107
+ cat<<SKIPPING
108
+
109
+ $(color r '======================================================================')
110
+
111
+ Skipping => $(color y "$1")
112
+
113
+ SKIPPING
114
+ }
115
+
97
116
  function addHelmRepo() {
98
117
  local chart=$1
99
118
  local url=$2
package/src/helmup CHANGED
@@ -7,6 +7,9 @@
7
7
 
8
8
  SHELMUP_ARGS=("$*")
9
9
 
10
+ # The project id is used in a lot of places so just set it here
11
+ GCP_PROJECT_ID="$(getProjectIdFromK8sContext)"
12
+
10
13
  # removed geotile-server from standard platform 3/20/22 - low usage
11
14
  PLATFORM=(
12
15
  authz-server
@@ -21,7 +24,7 @@ PLATFORM=(
21
24
  scheduler
22
25
  transponder-bq
23
26
  transponder-rt
24
- transponder-postgres
27
+ transponder-postgres # deprecated
25
28
  transponder-tsdb
26
29
  )
27
30
 
@@ -33,7 +36,7 @@ SYSTEM=(
33
36
  preemptible-killer
34
37
  zombie-killer
35
38
  reloader
36
- cert-manager
39
+ cert-manager # deprecated
37
40
  traefik
38
41
  velero
39
42
  monitoring # do monitoring last to show password
@@ -57,33 +60,23 @@ CATNAMI
57
60
  addHelmRepo bitnami $BITNAMI_URL
58
61
  }
59
62
 
60
- function getProjectIdFromK8sContext() {
61
- local currContext=`kubectl config current-context`
62
-
63
- IFS='_'
64
- read -ra ADDR <<< "$currContext"
65
-
66
- echo ${ADDR[1]} # project id is the second string split by _
67
- }
68
-
69
63
  function bindWorkloadIdentity(){
70
- PROJECT_ID=$(getProjectIdFromK8sContext)
71
64
  SVC_ACCT=$1
72
65
  NAMESPACE=$2
73
- SVC_ACCT_EMAIL="${SVC_ACCT}@${PROJECT_ID}.iam.gserviceaccount.com"
66
+ SVC_ACCT_EMAIL="${SVC_ACCT}@${GCP_PROJECT_ID}.iam.gserviceaccount.com"
74
67
 
75
68
  cat<<WORKLOAD_ID
76
69
  Binding workload identity IAM policy
77
70
  Service Account : `color g $SVC_ACCT`
78
- Project : `color g $PROJECT_ID`
71
+ Project : `color g $GCP_PROJECT_ID`
79
72
  Namespace : `color g $NAMESPACE`
80
73
  Service Email : `color g $SVC_ACCT_EMAIL`
81
74
 
82
75
  WORKLOAD_ID
83
76
 
84
77
  gcloud iam service-accounts add-iam-policy-binding \
85
- --project $PROJECT_ID \
86
- --member "serviceAccount:$PROJECT_ID.svc.id.goog[${NAMESPACE}/${SVC_ACCT}]" \
78
+ --project $GCP_PROJECT_ID \
79
+ --member "serviceAccount:$GCP_PROJECT_ID.svc.id.goog[${NAMESPACE}/${SVC_ACCT}]" \
87
80
  --role roles/iam.workloadIdentityUser $SVC_ACCT_EMAIL
88
81
  warnOnError $? "gcloud workload identity binding may have failed"
89
82
 
@@ -111,7 +104,8 @@ function generatePassword(){
111
104
  function createNamespaceIfNeeded(){
112
105
  # Check the namespace exists in kubernetes
113
106
  kubectl get namespace $1 &> /dev/null
114
- if [[ $? -eq 1 ]]; then
107
+ if [[ $? -eq 1 ]];
108
+ then
115
109
  printf "\n*** Creating $1 namespace ***\n\n"
116
110
  kubectl create namespace $1
117
111
  fi
@@ -157,20 +151,12 @@ function installGrafana() {
157
151
  removeHelmRepo grafana
158
152
  }
159
153
 
160
- function checkTimescalePassword() {
161
- kubectl get secret postgresql-password
162
- if [[ $? -eq 1 ]]; then
163
- printf "\n*** Autogenerating Timescale password ***\n\n"
164
- local psql_pw="$(generatePassword)"
165
- local psql_rep_pw="$(generatePassword)"
166
-
167
- kubectl create secret generic postgresql-password \
168
- --from-literal=postgresql-password=${psql_pw} \
169
- --from-literal=postgresql-replication-password=${psql_rep_pw}
170
-
171
- printf "\n\n`color y '*** Save Timescale creds to Keeper ***'`\n\n"
172
- printf "`color g "postgresql-password / ${psql_pw}"`\n"
173
- printf "`color g "postgresql-replication-password / ${psql_rep_pw}"`\n\n"
154
+ function errorIfMissingSecret() {
155
+ SECRET="$1"
156
+ kubectl get secret $SECRET &> /dev/null
157
+ if [[ $? = 1 || SECRET = "" ]];
158
+ then
159
+ errorExit "missing secret `color y $SECRET` - did you `color g 'service-man --new-k8s'` ?"
174
160
  fi
175
161
  }
176
162
 
@@ -181,82 +167,57 @@ function installMonitoringCharts(){
181
167
  # Add necessary helm repositories - note that stable is deprecated
182
168
  addHelmRepo prometheus-community https://prometheus-community.github.io/helm-charts
183
169
 
184
- ## Set the project id by parsing current context
185
- currContext=`kubectl config current-context`
186
-
187
- IFS='_'
188
- read -ra ADDR <<< "$currContext"
189
- KUBERNETES_ENV=${ADDR[0]} # should be either gke or eks
190
- GCP_PROJECT_ID=${ADDR[1]} # project id is the second string split by _
170
+ local SDEXP_SA='stackdriver-exporter'
191
171
 
192
- ## Installing stackdriver exporter in GKE
193
- if [[ "$KUBERNETES_ENV" = "gke" ]];
194
- then
195
- kubectl get sa -n monitoring stackdriver-exporter &> /dev/null
196
- if [[ $? -eq 0 ]];
197
- then
198
- cat<<SA_EXISTS
199
-
200
- The stackdriver-exporter SA already exists which means installing the
201
- helm chart is going to fail because it wants to manage that aspect of the
202
- system. This most likely because the stackdriver exporter is already
203
- installed and running. Run the following helm command to uninstall first:
204
-
205
- `color y "overwhelm && helm uninstall -n monitoring stackdriver-exporter"`
172
+ # Uninstall the exporter if it is already on the cluster
173
+ helm uninstall -n monitoring $SDEXP_SA &>/dev/null
206
174
 
207
- SA_EXISTS
208
- exitOnError 1 "uninstall the existing deployment in order to proceed"
209
- fi
210
-
211
- SDEXP_SA='stackdriver-exporter'
175
+ # NOTE: The k8s SA != GCP SA - the former is created by the helm chart
176
+ # that installs the stackdriver-exporter, the latter is handled here in
177
+ # order to provide the proper IAM permissions to the exporter.
212
178
 
213
- # NOTE: The k8s SA != GCP SA - the former is created by the helm chart
214
- # that installs the stackdriver-exporter, the latter is handled here in
215
- # order to provide the proper IAM permissions to the exporter.
179
+ # Create GCP SA and bind policies
180
+ printf "\n*** Creating GCP SA with monitoring/viewer ***\n"
181
+ gcloud iam service-accounts create $SDEXP_SA \
182
+ --project "$GCP_PROJECT_ID" \
183
+ --display-name "Prometheus Stackdriver Exporter" &>/dev/null
184
+ warnOnError $? "the GCP SA $SDEXP_SA may already exist"
216
185
 
217
- # Create GCP SA and bind policies
218
- printf "\n*** Creating GCP SA with monitoring/viewer ***\n"
219
- gcloud iam service-accounts create $SDEXP_SA \
220
- --project "$GCP_PROJECT_ID" \
221
- --display-name "Prometheus Stackdriver Exporter"
222
- warnOnError $? "the GCP SA $SDEXP_SA may already exist"
186
+ printf "\n*** Binding IAM role of monitoring viewer to stackdriver-exporter in $GCP_PROJECT_ID\n"
187
+ gcloud projects add-iam-policy-binding "$GCP_PROJECT_ID" \
188
+ --role "roles/monitoring.viewer" \
189
+ --member "serviceAccount:$SDEXP_SA@$GCP_PROJECT_ID.iam.gserviceaccount.com" &>/dev/null
223
190
 
224
- printf "\n*** Binding IAM role of monitoring viewer to stackdriver-exporter in $GCP_PROJECT_ID\n"
225
- gcloud projects add-iam-policy-binding "$GCP_PROJECT_ID" \
226
- --role "roles/monitoring.viewer" \
227
- --member "serviceAccount:$SDEXP_SA@$GCP_PROJECT_ID.iam.gserviceaccount.com" &>/dev/null
191
+ printf "\n*** Binding IAM role of workloadIdentityUser to stackdriver-exporter\n"
192
+ gcloud iam service-accounts add-iam-policy-binding \
193
+ --project "$GCP_PROJECT_ID" \
194
+ --role "roles/iam.workloadIdentityUser" \
195
+ --member "serviceAccount:$GCP_PROJECT_ID.svc.id.goog[monitoring/$SDEXP_SA]" \
196
+ "$SDEXP_SA@$GCP_PROJECT_ID.iam.gserviceaccount.com"
228
197
 
229
- printf "\n*** Binding IAM role of workloadIdentityUser to stackdriver-exporter\n"
230
- gcloud iam service-accounts add-iam-policy-binding \
231
- --project "$GCP_PROJECT_ID" \
232
- --role "roles/iam.workloadIdentityUser" \
233
- --member "serviceAccount:$GCP_PROJECT_ID.svc.id.goog[monitoring/$SDEXP_SA]" \
234
- "$SDEXP_SA@$GCP_PROJECT_ID.iam.gserviceaccount.com"
198
+ # The GCP SA is now up but slight delay before launch helm to let the IAM update occur
199
+ sleep 2
200
+ helm upgrade --install stackdriver-exporter \
201
+ prometheus-community/prometheus-stackdriver-exporter \
202
+ --namespace monitoring \
203
+ --values stackdriver-exporter/values.yaml \
204
+ --version 3
235
205
 
236
- # The GCP SA is now up but slight delay before launch helm to let the IAM update occur
237
- sleep 2
238
- helm upgrade --install stackdriver-exporter \
239
- prometheus-community/prometheus-stackdriver-exporter \
240
- --namespace monitoring \
241
- --values stackdriver-exporter/values.yaml \
242
- --version 3
243
-
244
- # Verify the Kubernetes SA
245
- kubectl get sa -n monitoring $SDEXP_SA
246
- if [[ $? -eq 1 ]];
247
- then
248
- printf "The $SDEXP_SA SA seems to be missing - did startup fail?\n"
249
- else
250
- # Annotate Kubernetes SA
251
- printf "\n*** Annotating the stackdriver-exporter SA\n"
252
- kubectl annotate serviceaccount $SDEXP_SA \
253
- "iam.gke.io/gcp-service-account=$SDEXP_SA@$GCP_PROJECT_ID.iam.gserviceaccount.com" \
254
- --namespace monitoring
255
- fi
206
+ # Verify the Kubernetes SA
207
+ kubectl get sa -n monitoring $SDEXP_SA
208
+ if [[ $? -eq 1 ]];
209
+ then
210
+ printf "The $SDEXP_SA SA seems to be missing - did startup fail?\n"
211
+ else
212
+ # Annotate Kubernetes SA
213
+ printf "\n*** Annotating the stackdriver-exporter SA\n"
214
+ kubectl annotate serviceaccount $SDEXP_SA \
215
+ "iam.gke.io/gcp-service-account=$SDEXP_SA@$GCP_PROJECT_ID.iam.gserviceaccount.com" \
216
+ --namespace monitoring
256
217
  fi
257
218
 
258
219
  ## Install Prometheus
259
- installPrometheus
220
+ bootstrapLocalSetup prometheus set-values-local
260
221
 
261
222
  ## Installing ES exporter
262
223
  helm upgrade --install elasticsearch-exporter prometheus-community/prometheus-elasticsearch-exporter \
@@ -272,7 +233,7 @@ es:
272
233
  ELASTIC_EXPORTER_CHART_MOD
273
234
 
274
235
  ## Install Grafana
275
- installGrafana
236
+ bootstrapLocalSetup grafana
276
237
 
277
238
  ## Clean up
278
239
  removeHelmRepo prometheus-community
@@ -295,38 +256,13 @@ function monitoringHelp(){
295
256
  kubectl --namespace monitoring port-forward \$GRAFANA_POD 3000 &
296
257
  sleep 2; open http://localhost:3000
297
258
 
298
- `color toast "Save monitoring login to Keeweb"` => `color r "admin / $MONPASS"`
259
+ `color toast "Save monitoring login to Keeper"` => `color r "admin / $MONPASS"`
299
260
 
300
261
  `color g "Show this helpful message again with"` => `color r "helmup monitoring-wtf"`
301
262
 
302
263
  ACCESS
303
264
  }
304
265
 
305
- function createSSDYAML(){
306
- cat<<EOSSD > ${K8S_UTILS}/ssd-storageclass.yaml
307
- apiVersion: storage.k8s.io/v1
308
- kind: StorageClass
309
- metadata:
310
- name: ssd
311
- provisioner: kubernetes.io/gce-pd
312
- parameters:
313
- type: pd-ssd
314
- EOSSD
315
- }
316
-
317
- function checkSSDStorageClass(){
318
- kubectl get storageclass ssd
319
- if [[ $? -eq 1 ]]; then
320
- printf "\n*** SSD Storage Class not defined ***\n\n"
321
- if [ ! -f ${K8S_UTILS}/ssd-storageclass.yaml ]; then
322
- createSSDYAML
323
- fi
324
- kubectl apply -f ${K8S_UTILS}/ssd-storageclass.yaml
325
- fi
326
-
327
- printf "\n*** Attaching PVC to SSD Class ***\n\n"
328
- }
329
-
330
266
  function getManagedSecret() {
331
267
  local SECNAME=$1
332
268
  local PROJECT="${2:-leverege-docker-images}"
@@ -344,7 +280,6 @@ function getManagedSecret() {
344
280
  function installPreemptibleKiller() {
345
281
  showInstalling "Preemptible Node Killing Coordinator"
346
282
  NAMESPACE="estafette"
347
- PROJECT_ID="$(getProjectIdFromK8sContext)"
348
283
  SVC_ACCT="preemptible-killer"
349
284
 
350
285
  createNamespaceIfNeeded $NAMESPACE
@@ -352,24 +287,24 @@ function installPreemptibleKiller() {
352
287
 
353
288
  printf "\nCreating the gcloud $SVC_ACCT service account (SA)\n"
354
289
  gcloud iam service-accounts create $SVC_ACCT \
355
- --project $PROJECT_ID \
290
+ --project $GCP_PROJECT_ID \
356
291
  --description "Estafette Node Killer SA" \
357
292
  --display-name "Estafette Node Killer SA"
358
293
  warnOnError $? "SA creation may have failed or it already exists"
359
294
 
360
295
  printf "\nCreate the $SVC_ACCT IAM role\n"
361
296
  gcloud iam roles create preemptibleKiller \
362
- --project $PROJECT_ID \
297
+ --project $GCP_PROJECT_ID \
363
298
  --title "Estafette Node Killer" \
364
299
  --description "Delete compute instances" \
365
300
  --permissions compute.instances.delete
366
301
  warnOnError $? "Role creation may have failed or it already exists"
367
302
 
368
- local service_account_email=$(gcloud iam --project=$PROJECT_ID service-accounts list --filter $SVC_ACCT --format 'value([email])')
303
+ local service_account_email=$(gcloud iam --project=$GCP_PROJECT_ID service-accounts list --filter $SVC_ACCT --format 'value([email])')
369
304
  printf "\nBinding the IAM role to the $SVC_ACCT SA\n"
370
- gcloud projects add-iam-policy-binding $PROJECT_ID \
305
+ gcloud projects add-iam-policy-binding $GCP_PROJECT_ID \
371
306
  --member=serviceAccount:${service_account_email} \
372
- --role=projects/${PROJECT_ID}/roles/preemptibleKiller &> /dev/null
307
+ --role=projects/${GCP_PROJECT_ID}/roles/preemptibleKiller &> /dev/null
373
308
  warnOnError $? "Binding may have failed or it already exists"
374
309
 
375
310
  bindWorkloadIdentity $SVC_ACCT $NAMESPACE
@@ -377,7 +312,7 @@ function installPreemptibleKiller() {
377
312
  helm upgrade --install estafette-gke-preemptible-killer \
378
313
  estafette/estafette-gke-preemptible-killer \
379
314
  --namespace ${NAMESPACE} \
380
- --set secret.workloadIdentityServiceAccount="$SVC_ACCT@$PROJECT_ID.iam.gserviceaccount.com" \
315
+ --set secret.workloadIdentityServiceAccount="$SVC_ACCT@$GCP_PROJECT_ID.iam.gserviceaccount.com" \
381
316
  --set extraEnv.BLACKLIST_HOURS="10:00-02:00" # No killing from 5AM-9PM EST
382
317
  # --set extraEnv.WHITELIST_HOURS="12:30-13:30"
383
318
  [ -f "google_service_account.json" ] && rm google_service_account.json
@@ -466,14 +401,15 @@ function installCertManager() {
466
401
  createNamespaceIfNeeded cert-manager
467
402
 
468
403
  kubectl get secret cloudflare --namespace cert-manager &>/dev/null
469
- if [[ $? -eq 1 ]]; then
404
+ if [[ $? -eq 1 ]];
405
+ then
470
406
  cat<<NEED_MANAGED_SECRET
471
407
  $RED_ERROR missing secret: `color y cloudflare` namespace: `color y cert-manager`
472
408
 
473
- This secret may be fetched from the leverege-docker-images cluster and
474
- properly injected into this cluster.
409
+ This secret will be fetched from the leverege-docker-images cluster and
410
+ injected into this cluster.
475
411
  NEED_MANAGED_SECRET
476
- yesToContinue "to copy and inject the cloudflare secret"
412
+ #yesToContinue "to copy and inject the cloudflare secret"
477
413
  TOKEN=$(getManagedSecret "CLOUDFLARE_API_TOKEN")
478
414
  if [ $? -ne 0 ];
479
415
  then
@@ -501,7 +437,8 @@ DELAY
501
437
  sleep 20
502
438
  kubectl -n cert-manager apply -f cert-manager
503
439
 
504
- if [[ $? -eq 1 ]]; then
440
+ if [[ $? -eq 1 ]];
441
+ then
505
442
 
506
443
  `color y "***WARNING: cert-manager components still coming up"`
507
444
 
@@ -523,14 +460,14 @@ function installTraefikEnvironment() {
523
460
  createNamespaceIfNeeded traefik
524
461
 
525
462
  kubectl get secret cloudflare --namespace traefik &>/dev/null
526
- if [[ $? -eq 1 ]]; then
463
+ if [[ $? -eq 1 ]];
464
+ then
527
465
  cat<<NEED_TRAEFIK_SECRET
528
466
  $RED_ERROR missing secret: `color y cloudflare` namespace: `color y traefik`
529
467
 
530
- This secret may be fetched from the leverege-docker-images cluster and
531
- properly injected into this cluster.
468
+ Injecting the `color y cloudflare` secret from the `color g leverege-docker-images` cluster.
469
+
532
470
  NEED_TRAEFIK_SECRET
533
- yesToContinue "to copy and inject the cloudflare secret"
534
471
  TOKEN=$(getManagedSecret "CLOUDFLARE_API_TOKEN")
535
472
  if [ $? -ne 0 ];
536
473
  then
@@ -548,27 +485,19 @@ function installVelero() {
548
485
  # Follows instructions => https://github.com/vmware-tanzu/velero-plugin-for-gcp
549
486
  showInstalling "Velero Backup Management"
550
487
 
551
- ## Set the project id by parsing current context
552
- currContext=`kubectl config current-context`
553
-
554
- IFS='_'
555
- read -ra ADDR <<< "$currContext"
556
-
557
- PROJECT_ID=${ADDR[1]} # project id is the second string split by _
558
-
559
- gcloud config set project $PROJECT_ID
488
+ gcloud config set project $GCP_PROJECT_ID
560
489
 
561
490
  ## Create a bucket
562
- BUCKET="$PROJECT_ID-velero"
491
+ BUCKET="$GCP_PROJECT_ID-velero"
563
492
  GCE_REGION=`overwhelm -k GCE_REGION`
564
- printf "\nCreating storage bucket in $GCE_REGION...\n"
493
+ printf "\nCreating storage bucket `color g $BUCKET` in `color g $GCE_REGION`\n"
565
494
  gsutil mb -l $GCE_REGION gs://$BUCKET/ &> /dev/null
566
495
  warnOnError $? "Bucket failed to create or already exists - go check it\n"
567
496
 
568
497
  ## Create a service account
569
498
  printf "\nCreating the service account\n"
570
499
  gcloud iam service-accounts create velero \
571
- --project $PROJECT_ID \
500
+ --project $GCP_PROJECT_ID \
572
501
  --display-name "Velero service account" \
573
502
  --description "Velero service account" &>/dev/null
574
503
  if [ $? -eq 0 ];
@@ -579,7 +508,7 @@ function installVelero() {
579
508
  printf "$YELO_WARN Failed to create the service account - does it already exist?"
580
509
  fi
581
510
 
582
- SERVICE_ACCOUNT_EMAIL="velero@${PROJECT_ID}.iam.gserviceaccount.com"
511
+ SERVICE_ACCOUNT_EMAIL="velero@${GCP_PROJECT_ID}.iam.gserviceaccount.com"
583
512
 
584
513
  ## Attach roles
585
514
  ROLE_PERMISSIONS=(
@@ -592,6 +521,7 @@ function installVelero() {
592
521
  compute.snapshots.delete
593
522
  compute.zones.get
594
523
  iam.serviceAccounts.actAs
524
+ iam.serviceAccounts.signBlob
595
525
  storage.objects.create
596
526
  storage.objects.delete
597
527
  storage.objects.get
@@ -600,7 +530,7 @@ function installVelero() {
600
530
 
601
531
  printf "\nAssigning roles to the SA\n"
602
532
  gcloud iam roles create velero.server \
603
- --project $PROJECT_ID \
533
+ --project $GCP_PROJECT_ID \
604
534
  --title "Velero Server" \
605
535
  --permissions "$(IFS=","; echo "${ROLE_PERMISSIONS[*]}")" &>/dev/null
606
536
  if [ $? -ne 0 ];
@@ -608,23 +538,23 @@ function installVelero() {
608
538
  # assume error is that role exists so try updating instead
609
539
  printf "\nUpdating roles on the SA\n"
610
540
  gcloud iam roles update velero.server \
611
- --project $PROJECT_ID \
541
+ --project $GCP_PROJECT_ID \
612
542
  --title "Velero Server" \
613
543
  --permissions "$(IFS=","; echo "${ROLE_PERMISSIONS[*]}")" &>/dev/null
614
544
  fi
615
545
  warnOnError $? "Failed to add roles to velero.server - perhaps they already exist?"
616
546
 
617
547
  printf "\nBinding IAM policy to the SA\n"
618
- gcloud projects add-iam-policy-binding $PROJECT_ID \
619
- --project $PROJECT_ID \
548
+ gcloud projects add-iam-policy-binding $GCP_PROJECT_ID \
549
+ --project $GCP_PROJECT_ID \
620
550
  --member serviceAccount:$SERVICE_ACCOUNT_EMAIL \
621
551
  --condition 'None' \
622
- --role projects/$PROJECT_ID/roles/velero.server &>/dev/null
552
+ --role projects/$GCP_PROJECT_ID/roles/velero.server &>/dev/null
623
553
  warnOnError $? "gcloud problem binding IAM policy"
624
554
 
625
555
  printf "\nBinding workload identity IAM policy to the SA\n"
626
556
  gcloud iam service-accounts add-iam-policy-binding \
627
- --member "serviceAccount:$PROJECT_ID.svc.id.goog[velero/velero]" \
557
+ --member "serviceAccount:$GCP_PROJECT_ID.svc.id.goog[velero/velero]" \
628
558
  --role roles/iam.workloadIdentityUser \
629
559
  $SERVICE_ACCOUNT_EMAIL
630
560
  warnOnError $? "gcloud workload identity binding may have failed"
@@ -645,26 +575,29 @@ function installVelero() {
645
575
  gsutil iam ch serviceAccount:$SERVICE_ACCOUNT_EMAIL:objectAdmin gs://$BUCKET
646
576
 
647
577
  ## Clean up from previous failed install
648
- kubectl delete volumesnapshotlocation.velero.io -n velero gcp &>/dev/null
578
+ kubectl delete volumesnapshotlocation.velero.io -n velero gcp &>/dev/null
649
579
 
650
- ## Install velero chart => https://github.com/vmware-tanzu/helm-charts/blob/main/charts/velero/values.yaml
651
- ## Helpful debugging link => https://github.com/vmware-tanzu/helm-charts/issues/351
580
+ ## Install velero chart => https://github.com/vmware-tanzu/helm-charts/blob/main/charts/velero/values.yaml
581
+ ## The velero plugin for GCP => https://github.com/vmware-tanzu/velero-plugin-for-gcp
582
+ ## Helpful debugging link => https://github.com/vmware-tanzu/helm-charts/issues/351
652
583
  addHelmRepo vmware-tanzu https://vmware-tanzu.github.io/helm-charts
584
+ ## Build velero command
653
585
  [ -z "$VELERO_HELM_CHART" ] && VELERO_HELM_CHART="3"
654
586
  helm upgrade --install velero vmware-tanzu/velero \
655
- --version $VELERO_HELM_CHART \
656
- --namespace velero \
587
+ --version "$VELERO_HELM_CHART" \
588
+ --namespace "velero" \
657
589
  --set credentials.useSecret="false" \
658
590
  --set configuration.provider="gcp" \
659
- --set configuration.backupStorageLocation.name=default \
591
+ --set configuration.backupStorageLocation.name="default" \
660
592
  --set configuration.backupStorageLocation.bucket="${BUCKET}" \
661
- --set configuration.backupStorageLocation.config.serviceAccount=$SERVICE_ACCOUNT_EMAIL \
593
+ --set configuration.backupStorageLocation.config.serviceAccount="$SERVICE_ACCOUNT_EMAIL" \
662
594
  --set serviceAccount.server.create="false" \
663
595
  --set serviceAccount.server.name="velero" \
664
596
  --set snapshotsEnabled="true" \
665
- --set configuration.volumeSnapshotLocation.name=default \
597
+ --set configuration.volumeSnapshotLocation.name="default" \
598
+ --set configuration.volumeSnapshotLocation.config.snapshotLocation="$GCE_REGION" \
666
599
  --set "initContainers[0].name"="velero-plugin-for-gcp" \
667
- --set "initContainers[0].image"="velero/velero-plugin-for-gcp:v1.6.0" \
600
+ --set "initContainers[0].image"="velero/velero-plugin-for-gcp:v1.5.0" \
668
601
  --set "initContainers[0].volumeMounts[0].mountPath"="/target" \
669
602
  --set "initContainers[0].volumeMounts[0].name"="plugins" \
670
603
  --set schedules.postgresql.schedule="0 2 * * *" \
@@ -687,13 +620,20 @@ function installVelero() {
687
620
 
688
621
  Velero docs => `color g 'open https://velero.io/docs'`
689
622
 
690
- Creating initial backups from `color g 'velero-postgres'` and `color g 'velero-timescale'` schedules...
623
+ Wait at least 1 minute before kicking off the following backups:
624
+
625
+ `color g 'velero backup create --from-schedule velero-postgresql'`
626
+ `color g 'velero backup create --from-schedule velero-timescale'`
627
+
628
+ This will create initial backups from the defined schedules which should
629
+ avoid alerts from prometheus about backups failing on new installations.
630
+
631
+ The status of the backups may be checked by running:
632
+
633
+ `color g 'overwhelm && velero get backups'`
634
+
691
635
  DONE_VELERO
692
- sleep 2
693
- velero backup create --from-schedule velero-postgresql
694
- velero backup create --from-schedule velero-timescale
695
636
  removeHelmRepo vmware-tanzu
696
- echo -n "npm run ahoy && velero get backups" | pbcopy
697
637
  }
698
638
 
699
639
  # If a helmup.plugin file exists and is executable helmup assumes it is
@@ -720,7 +660,6 @@ PLUGIN_NOEXEC
720
660
  }
721
661
 
722
662
  function getServiceAndChartVersion() {
723
-
724
663
  SERVICE=
725
664
  CHARTVER=
726
665
  FROM_VERSIONS=
@@ -799,7 +738,8 @@ function doInstall() {
799
738
  ;;
800
739
 
801
740
  "cert-manager")
802
- installCertManager
741
+ #installCertManager
742
+ bootstrapLocalSetup cert-manager
803
743
  ;;
804
744
 
805
745
  "cronZombieKiller"|"zombie-killer")
@@ -936,177 +876,8 @@ NOTRUNNING
936
876
  GITTOP=`git rev-parse --show-toplevel` # `&& cd $GITTOP
937
877
  K8S_UTILS="${GITTOP}/k8s-utils"
938
878
 
939
- overwhelm # overwhelm.js # use overwhelm.js for local
879
+ overwhelm
940
880
  [ $? -ne 0 ] && printf "\n\n***Aborting helmup...\n\n" && exit 1
941
881
 
942
882
  doInstall $@
943
883
  cd - &> /dev/null
944
-
945
- # *** DEPRECATED *** DEPRECATED *** DEPRECATED *** DEPRECATED *** DEPRECATED *** DEPRECATED ***
946
- function installPrometheusXXX() {
947
- # Add the community helm repositories
948
- addHelmRepo prometheus-community https://prometheus-community.github.io/helm-charts
949
- [ -z "$PROMETHEUS_HELM_CHART" ] && PROMETHEUS_HELM_CHART="15"
950
- helm upgrade --install prometheus prometheus-community/prometheus \
951
- --namespace monitoring \
952
- --values prometheus/values.yaml \
953
- --version $PROMETHEUS_HELM_CHART
954
- removeHelmRepo prometheus-community
955
- }
956
-
957
- function installRedisXXX() {
958
- showInstalling "Redis Network Cache"
959
- addBitnamiRepo latest
960
- [ -z "$REDIS_HELM_CHART" ] && REDIS_HELM_CHART="17" # latest chart 17 is redis v7
961
- helm upgrade --install redis bitnami/redis \
962
- --version $REDIS_HELM_CHART \
963
- -f - <<REDIS_CHART_MODS
964
- global:
965
- storageClass: ssd
966
-
967
- auth:
968
- enabled: false
969
- sentinel: false
970
-
971
- master:
972
- affinity:
973
- nodeAffinity:
974
- requiredDuringSchedulingIgnoredDuringExecution:
975
- nodeSelectorTerms:
976
- - matchExpressions:
977
- - key: target-env
978
- operator: In
979
- values:
980
- - database
981
-
982
- tolerations:
983
- - key: "database"
984
- operator: "Equal"
985
- value: "true"
986
- effect: "NoSchedule"
987
-
988
- persistence:
989
- size: 1Gi # 8Gi is default
990
-
991
- replica:
992
- affinity:
993
- nodeAffinity:
994
- requiredDuringSchedulingIgnoredDuringExecution:
995
- nodeSelectorTerms:
996
- - matchExpressions:
997
- - key: target-env
998
- operator: In
999
- values:
1000
- - database
1001
-
1002
- tolerations:
1003
- - key: "database"
1004
- operator: "Equal"
1005
- value: "true"
1006
- effect: "NoSchedule"
1007
-
1008
- persistence:
1009
- size: 8Gi # 8Gi is default
1010
-
1011
- architecture: replication
1012
-
1013
- sentinel:
1014
- enabled: false
1015
-
1016
- networkPolicy:
1017
- enabled: true
1018
- allowExternal: false
1019
- ingressNSMatchLabels:
1020
- redis: external
1021
- ingressNSPodMatchLabels:
1022
- redis-client: true
1023
-
1024
- metrics:
1025
- enabled: true
1026
-
1027
- REDIS_CHART_MODS
1028
- if [[ $? -ne 0 ]];
1029
- then
1030
- clearlyWarn noclear
1031
- cat<<OLDER_REDIS
1032
- The redis upgrade failed which may mean that the versions are different
1033
- enough that k8s cannot gracefully upgrade from one version to the next.
1034
- Try removing the existing deployment and redeploying redis:
1035
-
1036
- $ `color r "helmdn redis && sleep 5 && helmup redis"`
1037
- OLDER_REDIS
1038
- fi
1039
- printf "\n\nTo start a specific version => `color g 'REDIS_HELM_CHART="13.0.1" helmup redis'`\n\n"
1040
- removeHelmRepo bitnami
1041
- }
1042
-
1043
- function installPostgreSQLXXX() {
1044
- showInstalling "PostgreSQL Database"
1045
- addBitnamiRepo
1046
- helm upgrade --install postgres bitnami/postgresql -f postgres/postgres-values.yaml --version 10.16.2
1047
- removeHelmRepo bitnami
1048
- }
1049
-
1050
- function checkTimescaleLocalValuesXXX() {
1051
- local TSDIR="$GITTOP/timescale-db"
1052
- local TSLCL="$TSDIR/tsdb-values.yaml"
1053
- [ ! -d "$TSDIR" ] && mkdir "$TSDIR" && touch "$TSDIR/.nohelm"
1054
- [ ! -f "$TSLCL" ] && cat > $TSLCL <<TIMESCALE_LOCAL_CHART
1055
- postgresql:
1056
- postgresqlExtendedConf:
1057
- maxWorkerProcesses: 8
1058
- maxParallelWorkers: 8
1059
- maxConnections: 500
1060
- sharedBuffers: 2GB
1061
- effectiveCacheSize: 6GB
1062
- maintenanceWorkMem: 1GB
1063
- workMem: 20MB
1064
- idle_in_transaction_session_timeout: 30000 # 30ms timeout
1065
- maxWalSize: 2GB
1066
- walKeepSegments: 64
1067
-
1068
- resources:
1069
- requests:
1070
- memory: 4Gi
1071
- cpu: 1000m
1072
-
1073
- persistence:
1074
- size: 200Gi
1075
-
1076
- livenessProbe:
1077
- enabled: true # false for repairs
1078
- initialDelaySeconds: 30
1079
- periodSeconds: 10
1080
- timeoutSeconds: 5
1081
- failureThreshold: 6
1082
- successThreshold: 1
1083
-
1084
- readinessProbe:
1085
- enabled: true
1086
- successThreshold: 1
1087
- initialDelaySeconds: 5
1088
- timeoutSeconds: 5
1089
- periodSeconds: 10
1090
- failureThreshold: 6
1091
- # These values should be used when attempting to rebuild the slave VPCs
1092
- # following a failure, typically caused by WAL problems. The failure
1093
- # threshold of 240 with a period of 30 seconds should allow the recovery
1094
- # process 2 hours of time for each slave VPC - lengthen as necessary.
1095
- # initialDelaySeconds: 60
1096
- # timeoutSeconds: 15
1097
- # periodSeconds: 30
1098
- # failureThreshold: 240
1099
- TIMESCALE_LOCAL_CHART
1100
- echo "$TSLCL"
1101
- }
1102
-
1103
- function installTimescaleDbXXX() {
1104
- showInstalling "Timescale Database (Leverege chart)"
1105
- checkTimescalePassword
1106
- TSDB_VAL="$(checkTimescaleLocalValues)"
1107
- [ -z "$TIMESCALE_HELM_CHART" ] && TIMESCALE_HELM_CHART="2"
1108
- helm upgrade --install timescale-db leverege/timescale-db \
1109
- --version $TIMESCALE_HELM_CHART \
1110
- -f $GITTOP/timescale-db/tsdb-values.yaml
1111
- }
1112
-
@@ -0,0 +1,43 @@
1
+ # cert-manager is disabled
2
+ #
3
+ # cluster-issuer.yaml.ovh
4
+ #
5
+ apiVersion: cert-manager.io/v1
6
+ kind: ClusterIssuer
7
+ metadata:
8
+ name: letsencrypt-prd
9
+ spec:
10
+ acme:
11
+ # You must replace this email address with your own.
12
+ # Let's Encrypt will use this to contact you about expiring
13
+ # certificates, and issues related to your account.
14
+ email: devops@leverege.com
15
+ server: https://acme-v02.api.letsencrypt.org/directory
16
+ privateKeySecretRef:
17
+ # Secret resource used to store the account's private key.
18
+ name: issuer-account-key
19
+ # Add a single challenge solver, HTTP01 using nginx
20
+ solvers:
21
+ - dns01:
22
+ cloudflare:
23
+ email: devops@leverege.com
24
+ apiTokenSecretRef:
25
+ name: cloudflare
26
+ key: dns-token
27
+ selector:
28
+ dnsZones:
29
+ - 'OVH:<HOST>.com'
30
+ ---
31
+ #
32
+ # this-service.yaml.ovh
33
+ #
34
+ kind: Certificate
35
+ metadata:
36
+ name: OVH:<PROJECT_ID>
37
+ spec:
38
+ secretName: OVH:<PROJECT_ID>-cert
39
+ dnsNames:
40
+ - '*.OVH:<HOST>.com'
41
+ issuerRef:
42
+ name: letsencrypt-prd
43
+ kind: ClusterIssuer
@@ -0,0 +1,5 @@
1
+ #!/bin/bash
2
+ #
3
+ # cert-manager is skipped for now - we may not really need it
4
+ #
5
+ skipInstalling cert-manager
@@ -4,8 +4,6 @@
4
4
  #
5
5
  showInstalling "Elastic Search"
6
6
 
7
- checkSSDStorageClass
8
-
9
7
  LOCAL_ES_VALUES="elasticsearch/elasticsearch-local.yaml"
10
8
  [ ! -f "$LOCAL_ES_VALUES" ] && exitOnError 1 "Missing the local ES config file => `color y $LOCAL_ES_VALUES`"
11
9
 
@@ -12,6 +12,4 @@ helm upgrade --install grafana grafana/grafana \
12
12
  --values grafana/grafana-local.yaml \
13
13
  --version $GRAFANA_HELM_CHART $HELM_WHAT
14
14
 
15
- helmup monitoring-wtf
16
-
17
15
  removeHelmRepo grafana
@@ -2,6 +2,8 @@
2
2
  #
3
3
  showInstalling "PostgreSQL Database"
4
4
 
5
+ errorIfMissingSecret authz-postgres
6
+
5
7
  addBitnamiRepo
6
8
 
7
9
  helm upgrade --install postgres bitnami/postgresql \
@@ -2,7 +2,7 @@
2
2
  #
3
3
  showInstalling "Timescale Database (Leverege chart)"
4
4
 
5
- checkTimescalePassword
5
+ errorIfMissingSecret postgresql-password
6
6
 
7
7
  [ -z "$TIMESCALE_HELM_CHART" ] && TIMESCALE_HELM_CHART="2"
8
8
  helm upgrade --install timescale-db leverege/timescale-db \
@@ -2,11 +2,15 @@
2
2
 
3
3
  showInstalling "Traefik Load Balancer / Router"
4
4
 
5
+ #TRAEFIK_NAMESPACE="traefik-canary"
6
+ TRAEFIK_NAMESPACE="traefik"
7
+ createNamespaceIfNeeded $TRAEFIK_NAMESPACE
8
+
5
9
  addHelmRepo traefik https://helm.traefik.io/traefik
6
10
 
7
11
  [ -z "$TRAEFIK_HELM_CHART" ] && TRAEFIK_HELM_CHART="16"
8
12
  helm upgrade --install traefik traefik/traefik \
9
- --namespace traefik \
13
+ --namespace $TRAEFIK_NAMESPACE \
10
14
  --values traefik/traefik-local.yaml \
11
15
  --version $TRAEFIK_HELM_CHART $HELM_WHAT
12
16