@leverege/build-tools 2.8.14 → 2.9.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.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leverege/build-tools",
3
- "version": "2.8.14",
3
+ "version": "2.9.1",
4
4
  "description": "A collection of build / support tools for Leverege developers",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -20,6 +20,7 @@
20
20
  "test": "echo \"Error: no test specified\" && exit 1"
21
21
  },
22
22
  "bin": {
23
+ "anchor": "src/anchor",
23
24
  "build-tools": "src/build-tools.js",
24
25
  "circleate": "src/circleate",
25
26
  "decrypt-secrets": "src/decrypt-secrets",
@@ -31,7 +32,7 @@
31
32
  "git-tar": "src/git-tar",
32
33
  "helm-repos-reload": "src/helm-repos-reload",
33
34
  "helmdn": "src/helmdn",
34
- "helmify": "lib/server/helmify/index.js",
35
+ "xhelmify": "lib/server/helmify/index.js",
35
36
  "helminit-dp": "src/helminit-dp",
36
37
  "helminit-scaler": "src/helminit-scaler",
37
38
  "helminit-svc": "src/helminit-svc",
@@ -56,10 +57,10 @@
56
57
  "chalk": "^4.1.2",
57
58
  "clear": "^0.1.0",
58
59
  "clipboardy": "^2.3.0",
59
- "command-line-args": "^5.2.0",
60
+ "command-line-args": "^5.2.1",
60
61
  "command-line-usage": "^6.1.1",
61
62
  "deepmerge": "^4.2.2",
62
- "dotenv": "^10.0.0",
63
+ "dotenv": "^14.3.2",
63
64
  "execa": "^5.1.1",
64
65
  "figlet": "^1.5.2",
65
66
  "glob": "^7.2.0",
@@ -76,10 +77,10 @@
76
77
  },
77
78
  "devDependencies": {
78
79
  "@babel/cli": "^7.16.8",
79
- "@babel/core": "^7.16.7",
80
+ "@babel/core": "^7.16.12",
80
81
  "@babel/node": "^7.16.8",
81
82
  "@leverege/babel-preset-leverege-node": "^2.0.0",
82
83
  "@leverege/eslint-config-leverege": "^3.0.1",
83
- "npm": "^8.3.1"
84
+ "npm": "^8.4.0"
84
85
  }
85
86
  }
package/src/helmdn CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/bin/bash
2
+ # TODO: maybe update this?
2
3
 
3
4
  # Simple ANSI color coded string generator.
4
5
  color() {
@@ -55,7 +56,9 @@ PLATFORM=(
55
56
  )
56
57
 
57
58
  SYSTEM=(
59
+ cert-manager
58
60
  elastic
61
+ estafette-gke-preemptible-killer
59
62
  redis
60
63
  postgres
61
64
  timescale-db
@@ -79,15 +82,15 @@ read -ra ADDR <<< "$currContext"
79
82
 
80
83
  GCP_PROJECT_ID=${ADDR[1]} # project id is the second string split by _
81
84
 
82
- helm repo update # old helm2 => helm search chartmuseum
85
+ helm repo update &> /dev/null
83
86
 
84
87
  function annihilateMonitoring() {
85
88
  kubectl delete sa -n monitoring stackdriver-exporter
86
89
  gcloud iam service-accounts delete stackdriver-exporter@${GCP_PROJECT_ID}.iam.gserviceaccount.com --quiet
87
90
 
88
- helm repo remove prometheus-community kube-state-metrics && helm repo update
91
+ # kube-state-metrics?
89
92
  helm uninstall -n monitoring grafana prometheus stackdriver-exporter elasticsearch-exporter
90
- helm ls -n monitoring
93
+ # helm ls --all-namespaces
91
94
  }
92
95
 
93
96
  function annihilateVelero() {
@@ -112,30 +115,46 @@ function doNuking() {
112
115
  do
113
116
  SERVICE=${PARAM%/} # strip trailing / if it's there
114
117
 
115
- if [ "$SERVICE" == "monitoring" ];
116
- then
117
- annihilateMonitoring && continue
118
- fi
118
+ case "$SERVICE" in
119
+ "cert-manager")
120
+ helm uninstall -n cert-manager cert-manager
121
+ ;;
119
122
 
120
- if [ "$SERVICE" == "velero-nuke" ];
121
- then
122
- annihilateVelero && continue
123
- fi
123
+ "elastic"|"elasticsearch")
124
+ helm uninstall elasticsearch
125
+ ;;
124
126
 
125
- if [ "$SERVICE" == "platform" ];
126
- then
127
- doNuking "${PLATFORM[@]}" && exit $?
128
- fi
127
+ "estafette"|"estafette-gke-preemptible-killer")
128
+ helm uninstall -n estafette estafette-gke-preemptible-killer
129
+ ;;
129
130
 
130
- if [ "$SERVICE" == "system" ];
131
- then
132
- doNuking "${SYSTEM[@]}" && exit $?
133
- fi
131
+ "traefik")
132
+ helm uninstall -n traefik traefik
133
+ ;;
134
134
 
135
- if [ "$SERVICE" == "ingress" ];
136
- then
137
- clearlyWarn
138
- cat<<NOGRESS
135
+ "monitoring")
136
+ annihilateMonitoring && continue
137
+ ;;
138
+
139
+ "velero-nuke")
140
+ annihilateVelero
141
+ ;;
142
+
143
+ "velero")
144
+ printf "\nUnstalling velero requires => $(color toast 'helmdn velero-nuke')\n\n"
145
+ ;;
146
+
147
+ "platform")
148
+ doNuking "${PLATFORM[@]}" && exit $?
149
+ ;;
150
+
151
+ "system")
152
+ doNuking "${SYSTEM[@]}" && exit $?
153
+ ;;
154
+
155
+ "ingress")
156
+ clearlyWarn
157
+ cat<<NOGRESS
139
158
 
140
159
  Deleting the ingress is probably the most costly deployment to nuke since
141
160
  it takes so long to rebuild and stabilize. Therefore, if you REALLY want
@@ -145,12 +164,11 @@ function doNuking() {
145
164
  npm run ahoy; helm delete --purge $SERVICE
146
165
 
147
166
  NOGRESS
148
- continue
149
- fi
150
-
151
- [ "$SERVICE" == "elastic" ] && doNuking elasticsearch && continue
167
+ ;;
152
168
 
153
- helm uninstall $SERVICE
169
+ *)
170
+ helm -n default uninstall $SERVICE
171
+ esac
154
172
  done
155
173
  }
156
174
 
package/src/helmup CHANGED
@@ -30,22 +30,15 @@ SYSTEM=(
30
30
  redis
31
31
  postgres
32
32
  timescale-db
33
- monitoring
34
33
  preemptible-killer
35
34
  reloader
36
35
  cert-manager
37
36
  traefik
38
37
  velero
38
+ monitoring # do monitoring last to show password
39
39
  )
40
40
 
41
41
  function checkTimescalePassword(){
42
- if [ -f values-databases.yaml ] || [ -d timescale-db ];
43
- then
44
- printf "\n\n`color r '*** Deleting old timescale files ***'`\n\n"
45
- rm -rf values-databases.yaml timescale-db
46
- git add -A
47
- fi
48
-
49
42
  kubectl get secret postgresql-password
50
43
  if [[ $? -eq 1 ]]; then
51
44
  printf "\n*** Autogenerating Timescale password ***\n\n"
@@ -76,14 +69,34 @@ function createNamespaceIfNeeded(){
76
69
  fi
77
70
  }
78
71
 
72
+ function showInstalling() {
73
+ cat<<INSTALLING
74
+
75
+ $(color y '======================================================================')
76
+
77
+ Installing => $(color g "$1")
78
+
79
+ INSTALLING
80
+ }
81
+
82
+ function addHelmRepo() {
83
+ local chart=$1
84
+ local url=$2
85
+
86
+ cat<<REPOADD
87
+ Adding helm repo => $(color g "$chart") from $(color g "$url")
88
+
89
+ REPOADD
90
+ helm repo add $chart $url &> /dev/null
91
+ helm repo update &> /dev/null
92
+ }
93
+
79
94
  function installMonitoringCharts(){
95
+ showInstalling "Grafana Monitoring"
80
96
  createNamespaceIfNeeded monitoring
81
97
 
82
98
  # Add necessary helm repositories - note that stable is deprecated
83
- printf "\nAdding and updating helm repositories...\n"
84
- helm repo add stable https://charts.helm.sh/stable &> /dev/null # deprecated REMOVE ME
85
- helm repo add prometheus-community https://prometheus-community.github.io/helm-charts &> /dev/null
86
- helm repo update
99
+ addHelmRepo prometheus-community https://prometheus-community.github.io/helm-charts
87
100
 
88
101
  ## Set the project id by parsing current context
89
102
  currContext=`kubectl config current-context`
@@ -116,7 +129,7 @@ SA_EXISTS
116
129
  prometheus-community/prometheus-stackdriver-exporter \
117
130
  --namespace monitoring \
118
131
  --values stackdriver-exporter/values.yaml \
119
- --version 1.8.0
132
+ --version 1.12.0
120
133
 
121
134
  # Verify the Kubernetes SA
122
135
  kubectl get sa -n monitoring $SDEXP_SA
@@ -165,15 +178,15 @@ SA_EXISTS
165
178
  helm upgrade --install elasticsearch-exporter prometheus-community/prometheus-elasticsearch-exporter \
166
179
  --namespace monitoring \
167
180
  --values elasticsearch-exporter/values-es-exporter.yaml \
168
- --version 4.6
181
+ --version 4.11
169
182
 
170
183
  ## Install Grafana
171
- helm repo add grafana https://grafana.github.io/helm-charts && helm repo update
184
+ addHelmRepo grafana https://grafana.github.io/helm-charts
172
185
  helm upgrade --install grafana grafana/grafana \
173
186
  --namespace monitoring \
174
187
  --values grafana/values-grafana.yaml \
175
- --version 6.11 # 6.11 last of v7 grafana
176
- # --version 6.16 # latest v8 grafana
188
+ # --version 6.11 # 6.11 last of v7 grafana
189
+ --version 6.21 # latest v8 grafana
177
190
  }
178
191
 
179
192
  function monitoringHelp(){
@@ -249,9 +262,10 @@ function getProjectIdFromK8sContext() {
249
262
 
250
263
  # https://github.com/estafette/estafette-gke-preemptible-killer
251
264
  function installPreemptibleKiller() {
265
+ showInstalling "Preemptible Node Killing Adjusticator"
252
266
  PROJECT_ID="$(getProjectIdFromK8sContext)"
253
267
  createNamespaceIfNeeded estafette
254
- helm repo add estafette https://helm.estafette.io &>/dev/null
268
+ addHelmRepo estafette https://helm.estafette.io
255
269
 
256
270
  gcloud iam service-accounts create preemptible-killer \
257
271
  --project=$PROJECT_ID \
@@ -276,11 +290,68 @@ function installPreemptibleKiller() {
276
290
  helm upgrade --install estafette-gke-preemptible-killer \
277
291
  estafette/estafette-gke-preemptible-killer \
278
292
  --namespace estafette \
279
- --set extraEnv.BLACKLIST_HOURS="10:00-02:00"
293
+ --set extraEnv.BLACKLIST_HOURS="10:00-02:00" # No killing from 5AM-9PM EST
280
294
  # --set extraEnv.WHITELIST_HOURS="12:30-13:30"
295
+ [ -f "google_service_account.json" ] && rm google_service_account.json
296
+ }
297
+
298
+ function installCertManager() {
299
+ showInstalling "Cert Managment"
300
+ createNamespaceIfNeeded cert-manager
301
+
302
+ kubectl get secret cloudflare --namespace cert-manager &>/dev/null
303
+ if [[ $? -eq 1 ]]; then
304
+ cat<<NEED_MANAGED_SECRET
305
+ $RED_ERROR missing secret: `color y cloudflare` namespace: `color y cert-manager`
306
+
307
+ This secret may be fetched from the leverege-docker-images cluster and
308
+ properly injected into this cluster.
309
+ NEED_MANAGED_SECRET
310
+ yesToContinue "to copy and inject the cloudflare secret"
311
+ TOKEN=$(getManagedSecret "CLOUDFLARE_API_TOKEN")
312
+ if [ $? -ne 0 ];
313
+ then
314
+ printf "$RED_ERROR getManagedSecret reponse=>[$TOKEN]"
315
+ exitOnError 1 "Failed to fetch the secret from leverege-docker-images"
316
+ fi
317
+ printf "\nInjecting=[$TOKEN] into cloudflare secret\n"
318
+ kubectl create secret generic cloudflare \
319
+ --namespace cert-manager \
320
+ --from-literal=dns-token=$TOKEN
321
+ fi
322
+
323
+ addHelmRepo jetstack https://charts.jetstack.io
324
+ helm upgrade --install cert-manager jetstack/cert-manager \
325
+ --namespace cert-manager --set installCRDs=true \
326
+ --version v1.7.0
327
+
328
+ cat<<DELAY
329
+
330
+ `color y "20 second delay to allow cert-manager to stabilize before proceeding...\n"`
331
+
332
+ DELAY
333
+
334
+ sleep 20
335
+ kubectl -n cert-manager apply -f cert-manager
336
+
337
+ if [[ $? -eq 1 ]]; then
338
+
339
+ `color y "***WARNING: cert-manager components still coming up"`
340
+
341
+ Try rerunning this apply again in 30 seconds:
342
+ `color g "kubectl -n cert-manager apply -f cert-manager"`
343
+ fi
344
+
345
+ cat<<HINTS
346
+
347
+ fetch certs: `color g "kubectl -n cert-manager get certificate"`
348
+ check certs: `color g "kubectl -n cert-manager describe certificate"`
349
+
350
+ HINTS
281
351
  }
282
352
 
283
353
  function installTraefik() {
354
+ showInstalling "Traefik Load Balancer / Router"
284
355
  createNamespaceIfNeeded traefik
285
356
 
286
357
  kubectl get secret cloudflare --namespace traefik &>/dev/null
@@ -313,15 +384,10 @@ additionalArguments:
313
384
  - "--accesslog.format=json"
314
385
  - "--log.level=WARN"
315
386
  - "--metrics.prometheus=true"
316
- - "--metrics.prometheus.entryPoint=metrics"
317
- - "--entryPoints.metrics.address=:8082"
318
387
  - "--api.dashboard=true"
319
388
 
320
389
  deployment:
321
390
  replicas: 3
322
- podAnnotations:
323
- prometheus.io/port: '8082'
324
- prometheus.io/scrape: 'true'
325
391
 
326
392
  #service:
327
393
  # spec:
@@ -329,12 +395,17 @@ deployment:
329
395
  TRAEFIK_CFG
330
396
  fi
331
397
 
398
+ # old chart => traefik https://containous.github.io/traefik-helm-chart
399
+ helm repo remove traefik &> /dev/null
400
+ addHelmRepo traefik https://helm.traefik.io/traefik
401
+
332
402
  helm upgrade --install traefik traefik/traefik \
333
403
  --namespace traefik \
334
404
  --values $TRAEFIK_HA_YAML
335
405
  }
336
406
 
337
407
  function installVelero() {
408
+ showInstalling "Velero Backup Management"
338
409
  open https://velero.io/docs
339
410
  yesToContinue "when you are done checking the docs"
340
411
 
@@ -413,7 +484,7 @@ function installVelero() {
413
484
  kubectl delete volumesnapshotlocation.velero.io -n velero gcp &>/dev/null
414
485
 
415
486
  ## Install velero
416
- helm repo add vmware-tanzu https://vmware-tanzu.github.io/helm-charts
487
+ addHelmRepo vmware-tanzu https://vmware-tanzu.github.io/helm-charts
417
488
  helm upgrade --install velero vmware-tanzu/velero \
418
489
  --namespace velero \
419
490
  --set configuration.provider="gcp" \
@@ -443,46 +514,6 @@ function installVelero() {
443
514
  echo -n "npm run ahoy && velero get backups" | pbcopy
444
515
  }
445
516
 
446
- # ---------- helmup MAIN ----------
447
- GITTOP=`git rev-parse --show-toplevel` && cd $GITTOP
448
- if [ -d "${GITTOP}/k8-utils" ];
449
- then
450
- cat<<BADK8
451
-
452
- $YELO_WARN The k8_utils directory should be renamed to k8s_utils
453
-
454
- This repository has the old k8_util directory name in place. Please rename
455
- it to the newer k8s_utils directory that `color c helmup` will be looking for.
456
-
457
- Run this => `color g "git mv k8-utils k8s-utils; git add k8*utils"`
458
-
459
- $YELO_WARN Don't forget to commit and push after the renaming.
460
-
461
- BADK8
462
- exit 1
463
- fi
464
-
465
- K8S_UTILS="${GITTOP}/k8s-utils"
466
- if [ ! -d "$K8S_UTILS" ];
467
- then
468
- cat<<EOK8S
469
-
470
- $RED_ERROR Missing the k8s utils dir => `color y $K8S_UTILS`
471
-
472
- This is a relatively new directory setup that should be copied over from one
473
- of the other configuration branches. The new-baseline branch should have this
474
- setup in place, so check there.
475
-
476
- EOK8S
477
-
478
- exit 1
479
- fi
480
-
481
- overwhelm
482
- [ $? -ne 0 ] && printf "\n\n***Aborting helmup...\n\n" && exit 1
483
-
484
- helm repo update &> /dev/null # && helm search leverege
485
-
486
517
  # If a helmup.plugin file exists and is executable helmup assumes it is
487
518
  # an installation specific script that should be executed instead of one
488
519
  # of the standard setup scripts.
@@ -507,6 +538,9 @@ PLUGIN_NOEXEC
507
538
 
508
539
  function doInstall() {
509
540
 
541
+ helm remove repo stable &> /dev/null # stable was deprecated
542
+ helm repo update &> /dev/null
543
+
510
544
  for PARAM in "$@";
511
545
  do
512
546
  # Allows chart version from command line via <deployment>/<x.y.z>
@@ -539,15 +573,20 @@ function doInstall() {
539
573
  doInstall "${SYSTEM[@]}"
540
574
  ;;
541
575
 
576
+ "cert-manager")
577
+ installCertManager
578
+ ;;
579
+
542
580
  "custom-metrics")
543
581
  kubectl create -f https://raw.githubusercontent.com/GoogleCloudPlatform/k8s-stackdriver/master/custom-metrics-stackdriver-adapter/deploy/production/adapter.yaml
544
582
  ;;
545
583
 
546
584
  "elastic"|"elasticsearch")
585
+ showInstalling "Elastic Search"
547
586
  LOCAL_ES_VALUES="elasticsearch/es-values.yaml"
548
587
  [ ! -f "$LOCAL_ES_VALUES" ] && exitOnError 1 "Missing the local ES config file => `color y $LOCAL_ES_VALUES`"
549
588
  checkSSDStorageClass
550
- helm repo add elastic https://helm.elastic.co && helm repo update
589
+ addHelmRepo elastic https://helm.elastic.co
551
590
  helm upgrade --install elasticsearch elastic/elasticsearch \
552
591
  --values $LOCAL_ES_VALUES \
553
592
  --set volumeClaimTemplate.storageClassName="ssd"
@@ -563,7 +602,8 @@ function doInstall() {
563
602
  ;;
564
603
 
565
604
  "postgres"|"postgresql")
566
- helm repo add bitnami https://charts.bitnami.com/bitnami
605
+ showInstalling "PostgreSQL Database"
606
+ addHelmRepo bitnami https://charts.bitnami.com/bitnami
567
607
  helm upgrade --install postgres bitnami/postgresql -f postgres/postgres-values.yaml --version 8.9.6
568
608
  ;;
569
609
 
@@ -572,20 +612,23 @@ function doInstall() {
572
612
  ;;
573
613
 
574
614
  "redis")
575
- # https://github.com/helm/charts/tree/master/stable/redis
576
- [ -z "$REDIS_HELM_CHART" ] && REDIS_HELM_CHART="v9.1.5"
577
- helm upgrade --install redis stable/redis \
578
- --version $REDIS_HELM_CHART \
579
- --set usePassword=false,cluster.slaveCount=3,networkPolicy.enabled=true,metrics.enabled=true
580
- printf "To start a specific version => `color c 'REDIS_HELM_CHART="v9.1.5" helmup redis'`\n\n"
615
+ showInstalling "Redis Network Cache"
616
+ addHelmRepo bitnami https://charts.bitnami.com/bitnami
617
+ [ -z "$REDIS_HELM_CHART" ] && REDIS_HELM_CHART="13.0.1" # latest breaks us => "v14+"
618
+ helm upgrade --install redis bitnami/redis \
619
+ -f redis/redis-values.yaml \
620
+ --version $REDIS_HELM_CHART
621
+ printf "\n\nTo start a specific version => `color g 'REDIS_HELM_CHART="13.0.1" helmup redis'`\n\n"
581
622
  ;;
582
623
 
583
624
  "reloader")
584
- helm repo add stakater https://stakater.github.io/stakater-charts && helm repo update
625
+ showInstalling "Stakater ConfigMap Reloader"
626
+ addHelmRepo stakater https://stakater.github.io/stakater-charts
585
627
  helm upgrade --install reloader stakater/reloader
586
628
  ;;
587
629
 
588
630
  "timescale-db")
631
+ showInstalling "Timescale Database (Leverege chart)"
589
632
  checkTimescalePassword
590
633
  helm upgrade --install timescale-db leverege/timescale-db
591
634
  ;;
@@ -655,6 +698,44 @@ NOTRUNNING
655
698
  printf "\nCheck helm deployment status by running => `color g helm\ ls`\n\n"
656
699
  }
657
700
 
701
+ # ---------- helmup MAIN ----------
702
+ GITTOP=`git rev-parse --show-toplevel` && cd $GITTOP
703
+ if [ -d "${GITTOP}/k8-utils" ];
704
+ then
705
+ cat<<BADK8
706
+
707
+ $YELO_WARN The k8_utils directory should be renamed to k8s_utils
708
+
709
+ This repository has the old k8_util directory name in place. Please rename
710
+ it to the newer k8s_utils directory that `color c helmup` will be looking for.
711
+
712
+ Run this => `color g "git mv k8-utils k8s-utils; git add k8*utils"`
713
+
714
+ $YELO_WARN Don't forget to commit and push after the renaming.
715
+
716
+ BADK8
717
+ exit 1
718
+ fi
719
+
720
+ K8S_UTILS="${GITTOP}/k8s-utils"
721
+ if [ ! -d "$K8S_UTILS" ];
722
+ then
723
+ cat<<EOK8S
724
+
725
+ $RED_ERROR Missing the k8s utils dir => `color y $K8S_UTILS`
726
+
727
+ This is a relatively new directory setup that should be copied over from one
728
+ of the other configuration branches. The new-baseline branch should have this
729
+ setup in place, so check there.
730
+
731
+ EOK8S
732
+
733
+ exit 1
734
+ fi
735
+
736
+ overwhelm
737
+ [ $? -ne 0 ] && printf "\n\n***Aborting helmup...\n\n" && exit 1
738
+
658
739
  doInstall $@
659
740
  cd - &> /dev/null
660
741