@leverege/build-tools 2.8.14 → 2.9.0

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.0",
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,12 +30,12 @@ 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(){
@@ -76,14 +76,34 @@ function createNamespaceIfNeeded(){
76
76
  fi
77
77
  }
78
78
 
79
+ function showInstalling() {
80
+ cat<<INSTALLING
81
+
82
+ $(color y '======================================================================')
83
+
84
+ Installing => $(color g "$1")
85
+
86
+ INSTALLING
87
+ }
88
+
89
+ function addHelmRepo() {
90
+ local chart=$1
91
+ local url=$2
92
+
93
+ cat<<REPOADD
94
+ Adding helm repo => $(color g "$chart") from $(color g "$url")
95
+
96
+ REPOADD
97
+ helm repo add $chart $url &> /dev/null
98
+ helm repo update &> /dev/null
99
+ }
100
+
79
101
  function installMonitoringCharts(){
102
+ showInstalling "Grafana Monitoring"
80
103
  createNamespaceIfNeeded monitoring
81
104
 
82
105
  # 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
106
+ addHelmRepo prometheus-community https://prometheus-community.github.io/helm-charts
87
107
 
88
108
  ## Set the project id by parsing current context
89
109
  currContext=`kubectl config current-context`
@@ -116,7 +136,7 @@ SA_EXISTS
116
136
  prometheus-community/prometheus-stackdriver-exporter \
117
137
  --namespace monitoring \
118
138
  --values stackdriver-exporter/values.yaml \
119
- --version 1.8.0
139
+ --version 1.12.0
120
140
 
121
141
  # Verify the Kubernetes SA
122
142
  kubectl get sa -n monitoring $SDEXP_SA
@@ -165,15 +185,15 @@ SA_EXISTS
165
185
  helm upgrade --install elasticsearch-exporter prometheus-community/prometheus-elasticsearch-exporter \
166
186
  --namespace monitoring \
167
187
  --values elasticsearch-exporter/values-es-exporter.yaml \
168
- --version 4.6
188
+ --version 4.11
169
189
 
170
190
  ## Install Grafana
171
- helm repo add grafana https://grafana.github.io/helm-charts && helm repo update
191
+ addHelmRepo grafana https://grafana.github.io/helm-charts
172
192
  helm upgrade --install grafana grafana/grafana \
173
193
  --namespace monitoring \
174
194
  --values grafana/values-grafana.yaml \
175
- --version 6.11 # 6.11 last of v7 grafana
176
- # --version 6.16 # latest v8 grafana
195
+ # --version 6.11 # 6.11 last of v7 grafana
196
+ --version 6.21 # latest v8 grafana
177
197
  }
178
198
 
179
199
  function monitoringHelp(){
@@ -249,9 +269,10 @@ function getProjectIdFromK8sContext() {
249
269
 
250
270
  # https://github.com/estafette/estafette-gke-preemptible-killer
251
271
  function installPreemptibleKiller() {
272
+ showInstalling "Preemptible Node Killing Adjusticator"
252
273
  PROJECT_ID="$(getProjectIdFromK8sContext)"
253
274
  createNamespaceIfNeeded estafette
254
- helm repo add estafette https://helm.estafette.io &>/dev/null
275
+ addHelmRepo estafette https://helm.estafette.io
255
276
 
256
277
  gcloud iam service-accounts create preemptible-killer \
257
278
  --project=$PROJECT_ID \
@@ -276,11 +297,68 @@ function installPreemptibleKiller() {
276
297
  helm upgrade --install estafette-gke-preemptible-killer \
277
298
  estafette/estafette-gke-preemptible-killer \
278
299
  --namespace estafette \
279
- --set extraEnv.BLACKLIST_HOURS="10:00-02:00"
300
+ --set extraEnv.BLACKLIST_HOURS="10:00-02:00" # No killing from 5AM-9PM EST
280
301
  # --set extraEnv.WHITELIST_HOURS="12:30-13:30"
302
+ [ -f "google_service_account.json" ] && rm google_service_account.json
303
+ }
304
+
305
+ function installCertManager() {
306
+ showInstalling "Cert Managment"
307
+ createNamespaceIfNeeded cert-manager
308
+
309
+ kubectl get secret cloudflare --namespace cert-manager &>/dev/null
310
+ if [[ $? -eq 1 ]]; then
311
+ cat<<NEED_MANAGED_SECRET
312
+ $RED_ERROR missing secret: `color y cloudflare` namespace: `color y cert-manager`
313
+
314
+ This secret may be fetched from the leverege-docker-images cluster and
315
+ properly injected into this cluster.
316
+ NEED_MANAGED_SECRET
317
+ yesToContinue "to copy and inject the cloudflare secret"
318
+ TOKEN=$(getManagedSecret "CLOUDFLARE_API_TOKEN")
319
+ if [ $? -ne 0 ];
320
+ then
321
+ printf "$RED_ERROR getManagedSecret reponse=>[$TOKEN]"
322
+ exitOnError 1 "Failed to fetch the secret from leverege-docker-images"
323
+ fi
324
+ printf "\nInjecting=[$TOKEN] into cloudflare secret\n"
325
+ kubectl create secret generic cloudflare \
326
+ --namespace cert-manager \
327
+ --from-literal=dns-token=$TOKEN
328
+ fi
329
+
330
+ addHelmRepo jetstack https://charts.jetstack.io
331
+ helm upgrade --install cert-manager jetstack/cert-manager \
332
+ --namespace cert-manager --set installCRDs=true \
333
+ --version v1.7.0
334
+
335
+ cat<<DELAY
336
+
337
+ `color y "20 second delay to allow cert-manager to stabilize before proceeding...\n"`
338
+
339
+ DELAY
340
+
341
+ sleep 20
342
+ kubectl -n cert-manager apply -f cert-manager
343
+
344
+ if [[ $? -eq 1 ]]; then
345
+
346
+ `color y "***WARNING: cert-manager components still coming up"`
347
+
348
+ Try rerunning this apply again in 30 seconds:
349
+ `color g "kubectl -n cert-manager apply -f cert-manager"`
350
+ fi
351
+
352
+ cat<<HINTS
353
+
354
+ fetch certs: `color g "kubectl -n cert-manager get certificate"`
355
+ check certs: `color g "kubectl -n cert-manager describe certificate"`
356
+
357
+ HINTS
281
358
  }
282
359
 
283
360
  function installTraefik() {
361
+ showInstalling "Traefik Load Balancer / Router"
284
362
  createNamespaceIfNeeded traefik
285
363
 
286
364
  kubectl get secret cloudflare --namespace traefik &>/dev/null
@@ -329,12 +407,17 @@ deployment:
329
407
  TRAEFIK_CFG
330
408
  fi
331
409
 
410
+ # old chart => traefik https://containous.github.io/traefik-helm-chart
411
+ helm repo remove traefik &> /dev/null
412
+ addHelmRepo traefik https://helm.traefik.io/traefik
413
+
332
414
  helm upgrade --install traefik traefik/traefik \
333
415
  --namespace traefik \
334
416
  --values $TRAEFIK_HA_YAML
335
417
  }
336
418
 
337
419
  function installVelero() {
420
+ showInstalling "Velero Backup Management"
338
421
  open https://velero.io/docs
339
422
  yesToContinue "when you are done checking the docs"
340
423
 
@@ -413,7 +496,7 @@ function installVelero() {
413
496
  kubectl delete volumesnapshotlocation.velero.io -n velero gcp &>/dev/null
414
497
 
415
498
  ## Install velero
416
- helm repo add vmware-tanzu https://vmware-tanzu.github.io/helm-charts
499
+ addHelmRepo vmware-tanzu https://vmware-tanzu.github.io/helm-charts
417
500
  helm upgrade --install velero vmware-tanzu/velero \
418
501
  --namespace velero \
419
502
  --set configuration.provider="gcp" \
@@ -443,46 +526,6 @@ function installVelero() {
443
526
  echo -n "npm run ahoy && velero get backups" | pbcopy
444
527
  }
445
528
 
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
529
  # If a helmup.plugin file exists and is executable helmup assumes it is
487
530
  # an installation specific script that should be executed instead of one
488
531
  # of the standard setup scripts.
@@ -507,6 +550,9 @@ PLUGIN_NOEXEC
507
550
 
508
551
  function doInstall() {
509
552
 
553
+ helm remove repo stable &> /dev/null # stable was deprecated
554
+ helm repo update &> /dev/null
555
+
510
556
  for PARAM in "$@";
511
557
  do
512
558
  # Allows chart version from command line via <deployment>/<x.y.z>
@@ -539,15 +585,20 @@ function doInstall() {
539
585
  doInstall "${SYSTEM[@]}"
540
586
  ;;
541
587
 
588
+ "cert-manager")
589
+ installCertManager
590
+ ;;
591
+
542
592
  "custom-metrics")
543
593
  kubectl create -f https://raw.githubusercontent.com/GoogleCloudPlatform/k8s-stackdriver/master/custom-metrics-stackdriver-adapter/deploy/production/adapter.yaml
544
594
  ;;
545
595
 
546
596
  "elastic"|"elasticsearch")
597
+ showInstalling "Elastic Search"
547
598
  LOCAL_ES_VALUES="elasticsearch/es-values.yaml"
548
599
  [ ! -f "$LOCAL_ES_VALUES" ] && exitOnError 1 "Missing the local ES config file => `color y $LOCAL_ES_VALUES`"
549
600
  checkSSDStorageClass
550
- helm repo add elastic https://helm.elastic.co && helm repo update
601
+ addHelmRepo elastic https://helm.elastic.co
551
602
  helm upgrade --install elasticsearch elastic/elasticsearch \
552
603
  --values $LOCAL_ES_VALUES \
553
604
  --set volumeClaimTemplate.storageClassName="ssd"
@@ -563,7 +614,8 @@ function doInstall() {
563
614
  ;;
564
615
 
565
616
  "postgres"|"postgresql")
566
- helm repo add bitnami https://charts.bitnami.com/bitnami
617
+ showInstalling "PostgreSQL Database"
618
+ addHelmRepo bitnami https://charts.bitnami.com/bitnami
567
619
  helm upgrade --install postgres bitnami/postgresql -f postgres/postgres-values.yaml --version 8.9.6
568
620
  ;;
569
621
 
@@ -572,20 +624,23 @@ function doInstall() {
572
624
  ;;
573
625
 
574
626
  "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"
627
+ showInstalling "Redis Network Cache"
628
+ addHelmRepo bitnami https://charts.bitnami.com/bitnami
629
+ [ -z "$REDIS_HELM_CHART" ] && REDIS_HELM_CHART="13.0.1" # latest breaks us => "v14+"
630
+ helm upgrade --install redis bitnami/redis \
631
+ -f redis/redis-values.yaml \
632
+ --version $REDIS_HELM_CHART
633
+ printf "\n\nTo start a specific version => `color g 'REDIS_HELM_CHART="13.0.1" helmup redis'`\n\n"
581
634
  ;;
582
635
 
583
636
  "reloader")
584
- helm repo add stakater https://stakater.github.io/stakater-charts && helm repo update
637
+ showInstalling "Stakater ConfigMap Reloader"
638
+ addHelmRepo stakater https://stakater.github.io/stakater-charts
585
639
  helm upgrade --install reloader stakater/reloader
586
640
  ;;
587
641
 
588
642
  "timescale-db")
643
+ showInstalling "Timescale Database (Leverege chart)"
589
644
  checkTimescalePassword
590
645
  helm upgrade --install timescale-db leverege/timescale-db
591
646
  ;;
@@ -655,6 +710,44 @@ NOTRUNNING
655
710
  printf "\nCheck helm deployment status by running => `color g helm\ ls`\n\n"
656
711
  }
657
712
 
713
+ # ---------- helmup MAIN ----------
714
+ GITTOP=`git rev-parse --show-toplevel` && cd $GITTOP
715
+ if [ -d "${GITTOP}/k8-utils" ];
716
+ then
717
+ cat<<BADK8
718
+
719
+ $YELO_WARN The k8_utils directory should be renamed to k8s_utils
720
+
721
+ This repository has the old k8_util directory name in place. Please rename
722
+ it to the newer k8s_utils directory that `color c helmup` will be looking for.
723
+
724
+ Run this => `color g "git mv k8-utils k8s-utils; git add k8*utils"`
725
+
726
+ $YELO_WARN Don't forget to commit and push after the renaming.
727
+
728
+ BADK8
729
+ exit 1
730
+ fi
731
+
732
+ K8S_UTILS="${GITTOP}/k8s-utils"
733
+ if [ ! -d "$K8S_UTILS" ];
734
+ then
735
+ cat<<EOK8S
736
+
737
+ $RED_ERROR Missing the k8s utils dir => `color y $K8S_UTILS`
738
+
739
+ This is a relatively new directory setup that should be copied over from one
740
+ of the other configuration branches. The new-baseline branch should have this
741
+ setup in place, so check there.
742
+
743
+ EOK8S
744
+
745
+ exit 1
746
+ fi
747
+
748
+ overwhelm
749
+ [ $? -ne 0 ] && printf "\n\n***Aborting helmup...\n\n" && exit 1
750
+
658
751
  doInstall $@
659
752
  cd - &> /dev/null
660
753