@leverege/build-tools 2.6.3 → 2.6.4

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.
File without changes
Binary file
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leverege/build-tools",
3
- "version": "2.6.3",
3
+ "version": "2.6.4",
4
4
  "description": "A collection of build / support tools for Leverege developers",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -58,7 +58,7 @@
58
58
  "deepmerge": "^4.2.2",
59
59
  "dotenv": "^10.0.0",
60
60
  "execa": "^5.1.1",
61
- "figlet": "^1.5.0",
61
+ "figlet": "^1.5.2",
62
62
  "git-branch": "^2.0.1",
63
63
  "glob": "^7.1.7",
64
64
  "inquirer": "^8.1.2",
@@ -71,14 +71,14 @@
71
71
  "parse-gitignore": "^1.0.1",
72
72
  "readline-sync": "^1.4.10",
73
73
  "semver": "^7.3.5",
74
- "simple-git": "^2.41.2"
74
+ "simple-git": "^2.44.0"
75
75
  },
76
76
  "devDependencies": {
77
77
  "@babel/cli": "^7.14.8",
78
- "@babel/core": "^7.14.8",
79
- "@babel/node": "^7.14.7",
78
+ "@babel/core": "^7.15.0",
79
+ "@babel/node": "^7.14.9",
80
80
  "@leverege/babel-preset-leverege-node": "^1.2.0",
81
81
  "@leverege/eslint-config-leverege": "^3.0.0",
82
- "npm": "^7.20.3"
82
+ "npm": "^7.20.6"
83
83
  }
84
84
  }
package/src/helmdn CHANGED
@@ -70,17 +70,17 @@ cd $GITTOP
70
70
  npm run ahoy
71
71
  [ $? -ne 0 ] && printf "\n\n***Aborting helmup...\n\n" && exit 1
72
72
 
73
- helm repo update # old helm2 => helm search chartmuseum
73
+ # Detect Project ID
74
+ currContext=`kubectl config current-context`
74
75
 
75
- function annihilateMonitoring() {
76
- # Detect Project ID
77
- currContext=`kubectl config current-context`
76
+ IFS='_'
77
+ read -ra ADDR <<< "$currContext"
78
78
 
79
- IFS='_'
80
- read -ra ADDR <<< "$currContext"
79
+ GCP_PROJECT_ID=${ADDR[1]} # project id is the second string split by _
81
80
 
82
- GCP_PROJECT_ID=${ADDR[1]} # project id is the second string split by _
81
+ helm repo update # old helm2 => helm search chartmuseum
83
82
 
83
+ function annihilateMonitoring() {
84
84
  kubectl delete sa -n monitoring stackdriver-exporter
85
85
  gcloud iam service-accounts delete stackdriver-exporter@${GCP_PROJECT_ID}.iam.gserviceaccount.com --quiet
86
86
 
@@ -89,6 +89,22 @@ function annihilateMonitoring() {
89
89
  helm ls -n monitoring
90
90
  }
91
91
 
92
+ function annihilateVelero() {
93
+ velero delete backup --all --confirm
94
+ velero delete schedule --all --confirm
95
+ velero delete backup-location --all --confirm
96
+
97
+ ## Clean up from previous failed install before uninstalling
98
+ kubectl delete volumesnapshotlocation.velero.io gcp \
99
+ --namespace velero &>/dev/null
100
+
101
+ velero uninstall
102
+
103
+ gcloud iam service-accounts delete \
104
+ --project=${GCP_PROJECT_ID} --quiet \
105
+ velero@${GCP_PROJECT_ID}.iam.gserviceaccount.com &>/dev/null
106
+ }
107
+
92
108
  function doNuking() {
93
109
 
94
110
  for PARAM in "$@";
@@ -100,6 +116,11 @@ function doNuking() {
100
116
  annihilateMonitoring && continue
101
117
  fi
102
118
 
119
+ if [ "$SERVICE" == "velero" ];
120
+ then
121
+ annihilateVelero && continue
122
+ fi
123
+
103
124
  if [ "$SERVICE" == "platform" ];
104
125
  then
105
126
  doNuking "${PLATFORM[@]}" && exit $?
package/src/helminit-dp CHANGED
File without changes
File without changes
package/src/helminit-svc CHANGED
File without changes
package/src/helmup CHANGED
@@ -265,6 +265,9 @@ NEED_TRAEFIK_SECRET
265
265
  }
266
266
 
267
267
  function installVelero() {
268
+ open https://velero.io/docs
269
+ yesToContinue "when you are done checking the docs"
270
+
268
271
  ## Set the project id by parsing current context
269
272
  currContext=`kubectl config current-context`
270
273
 
@@ -277,16 +280,23 @@ function installVelero() {
277
280
 
278
281
  ## Create a bucket
279
282
  BUCKET="$PROJECT_ID-velero"
280
-
281
- gsutil mb gs://$BUCKET/
283
+ printf "\nCreating storage bucket...\n"
284
+ gsutil mb gs://$BUCKET/ &> /dev/null
285
+ warnOnError $? "Bucket failed to create or already exists - go check it\n"
282
286
 
283
287
  ## Create a service account
288
+ printf "\nCreating the service account\n"
284
289
  gcloud iam service-accounts create velero \
285
- --display-name "Velero service account"
290
+ --display-name "Velero service account" &>/dev/null
291
+ if [ $? -eq 0 ];
292
+ then
293
+ # no error means a new SA was created - slight delay to let it update
294
+ sleep 2
295
+ else
296
+ printf "$YELO_WARN Failed to create the service account - does it already exist?"
297
+ fi
286
298
 
287
- SERVICE_ACCOUNT_EMAIL=$(gcloud iam service-accounts list \
288
- --filter="displayName:Velero service account" \
289
- --format 'value(email)')
299
+ SERVICE_ACCOUNT_EMAIL="velero@${PROJECT_ID}.iam.gserviceaccount.com"
290
300
 
291
301
  ## Attach roles
292
302
  ROLE_PERMISSIONS=(
@@ -300,52 +310,67 @@ function installVelero() {
300
310
  compute.zones.get
301
311
  )
302
312
 
313
+ printf "\nAssigning roles to the SA\n"
303
314
  gcloud iam roles create velero.server \
304
315
  --project $PROJECT_ID \
305
316
  --title "Velero Server" \
306
- --permissions "$(IFS=","; echo "${ROLE_PERMISSIONS[*]}")"
317
+ --permissions "$(IFS=","; echo "${ROLE_PERMISSIONS[*]}")" &>/dev/null
318
+ warnOnError $? "Failed to add roles to velero.server - perhaps they already exist?"
307
319
 
320
+ printf "\nBinding IAM policy to the SA\n"
308
321
  gcloud projects add-iam-policy-binding $PROJECT_ID \
309
322
  --member serviceAccount:$SERVICE_ACCOUNT_EMAIL \
310
- --role projects/$PROJECT_ID/roles/velero.server
323
+ --role projects/$PROJECT_ID/roles/velero.server &>/dev/null
324
+ warnOnError $? "gcloud problem binding IAM policy"
311
325
 
312
- gsutil iam ch serviceAccount:$SERVICE_ACCOUNT_EMAIL:objectAdmin gs://${BUCKET}
326
+ gsutil iam ch serviceAccount:$SERVICE_ACCOUNT_EMAIL:objectAdmin gs://$BUCKET
313
327
 
314
328
  ## Create keys
315
- gcloud iam service-accounts keys create credentials-velero \
329
+ VELERO_CREDS="velero-credentials"
330
+ gcloud iam service-accounts keys create $VELERO_CREDS \
316
331
  --iam-account $SERVICE_ACCOUNT_EMAIL
317
332
 
318
333
  ## Create velero namespace
319
- kubectl create ns velero
334
+ kubectl get namespaces velero &>/dev/null
335
+ [ $? -eq 1 ] && kubectl create ns velero
320
336
 
321
337
  ## Create kubernetes secret
322
- kubectl create secret generic velero-credentials --namespace velero --from-file cloud=credentials-velero
338
+ printf "\nStoring the credentials in $VELERO_CREDS k8s secret\n"
339
+ kubectl delete secret $VELERO_CREDS --namespace velero &>/dev/null # toss old key if exists
340
+ kubectl create secret generic $VELERO_CREDS --namespace velero --from-file cloud=${VELERO_CREDS}
341
+
342
+ ## Clean up from previous failed install
343
+ kubectl delete volumesnapshotlocation.velero.io -n velero gcp &>/dev/null
323
344
 
324
345
  ## Install velero
325
346
  helm repo add vmware-tanzu https://vmware-tanzu.github.io/helm-charts
326
347
  helm upgrade --install velero vmware-tanzu/velero \
327
348
  --namespace velero \
328
349
  --set configuration.provider="gcp" \
329
- --set configuration.backupStorageLocation.name="gcp" \
330
- --set configuration.volumeSnapshotLocation.name="gcp" \
350
+ --set configuration.backupStorageLocation.name=default \
331
351
  --set configuration.backupStorageLocation.bucket="${BUCKET}" \
332
- --set credentials.existingSecret="velero-credentials" \
352
+ --set snapshotsEnabled="true" \
353
+ --set configuration.volumeSnapshotLocation.name=default \
354
+ --set credentials.existingSecret="${VELERO_CREDS}" \
333
355
  --set "initContainers[0].name"="velero-plugin-for-gcp" \
334
356
  --set "initContainers[0].image"="velero/velero-plugin-for-gcp:v1.0.0" \
335
357
  --set "initContainers[0].volumeMounts[0].mountPath"="/target" \
336
358
  --set "initContainers[0].volumeMounts[0].name"="plugins" \
359
+ --set schedules.postgresql.schedule="0 2 * * *" \
360
+ --set schedules.postgresql.template.ttl="720h" \
361
+ --set schedules.postgresql.template.labelSelector.matchLabels.release="postgres" \
362
+ --set schedules.postgresql.template.labelSelector.matchLabels.app="postgresql" \
363
+ --set schedules.postgresql.template.snapshotVolumes="true" \
337
364
  --set schedules.timescale.schedule="0 3 * * *" \
338
365
  --set schedules.timescale.template.ttl="720h" \
339
366
  --set schedules.timescale.template.labelSelector.matchLabels.release="timescale-db" \
340
367
  --set schedules.timescale.template.labelSelector.matchLabels.app="postgresql" \
341
- --set schedules.timescale.template.snapshotVolumes="true" \
342
- --set schedules.mysql.schedule="0 2 * * *" \
343
- --set schedules.mysql.template.ttl="720h" \
344
- --set schedules.mysql.template.labelSelector.matchLabels.app="mysql" \
345
- --set schedules.mysql.template.snapshotVolumes="true"
346
-
347
- ## Instruct users to move velero keys
348
- printf "\n$YELO_WARN Use the velero-credentials secret for accessing velero\n"
368
+ --set schedules.timescale.template.snapshotVolumes="true"
369
+
370
+ velero get backups
371
+ printf "\n\nVelero keys => kubectl get secret $VELERO_CREDS --namespace velero\n\n"
372
+ /bin/rm -f $VELERO_CREDS
373
+ echo -n "npm run ahoy && velero get backups" | pbcopy
349
374
  }
350
375
 
351
376
  # ---------- helmup MAIN ----------
package/src/k8x CHANGED
@@ -4,6 +4,8 @@ cmd=${@:-"bash"}
4
4
 
5
5
  [ "$cmd" = "redis" ] || [ "$cmd" = "redis-cli" ] && FZFQ="--query=redis" && cmd='redis-cli'
6
6
 
7
+ [ "$cmd" = "pgsql" ] && FZFQ="--query=postgresql" && cmd='psql -U postgres'
8
+
7
9
  [ -f overwhelm.yaml ] && [ -f package.json ] && npm run ahoy
8
10
 
9
11
  [ ! -x "$(command -v fzf)" ] && printf "\n***ERROR: Missing fzf fuzzy matcher => brew install fzf\n\n" && exit 1