@leverege/build-tools 2.0.15 → 2.1.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.
@@ -5,6 +5,8 @@ require("core-js/modules/es.symbol");
5
5
 
6
6
  require("core-js/modules/es.array.filter");
7
7
 
8
+ require("core-js/modules/es.array.for-each");
9
+
8
10
  require("core-js/modules/es.object.get-own-property-descriptor");
9
11
 
10
12
  require("core-js/modules/es.object.get-own-property-descriptors");
@@ -21,7 +23,7 @@ require("regenerator-runtime/runtime");
21
23
 
22
24
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
23
25
 
24
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
26
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
25
27
 
26
28
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
27
29
 
@@ -6,6 +6,8 @@ require("core-js/modules/es.array.concat");
6
6
 
7
7
  require("core-js/modules/es.array.filter");
8
8
 
9
+ require("core-js/modules/es.array.for-each");
10
+
9
11
  require("core-js/modules/es.array.index-of");
10
12
 
11
13
  require("core-js/modules/es.array.iterator");
@@ -46,7 +48,7 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
46
48
 
47
49
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
48
50
 
49
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
51
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
50
52
 
51
53
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
52
54
 
@@ -5,6 +5,8 @@ require("core-js/modules/es.symbol");
5
5
 
6
6
  require("core-js/modules/es.array.filter");
7
7
 
8
+ require("core-js/modules/es.array.for-each");
9
+
8
10
  require("core-js/modules/es.object.get-own-property-descriptor");
9
11
 
10
12
  require("core-js/modules/es.object.get-own-property-descriptors");
@@ -21,7 +23,7 @@ require("regenerator-runtime/runtime");
21
23
 
22
24
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
23
25
 
24
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
26
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
25
27
 
26
28
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
27
29
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leverege/build-tools",
3
- "version": "2.0.15",
3
+ "version": "2.1.1",
4
4
  "description": "A package for development build tools.",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/dockreate CHANGED
@@ -122,6 +122,11 @@ alias inf='wget -q -O- localhost:5111/logLevel/info'
122
122
  alias err='wget -q -O- localhost:5111/logLevel/error'
123
123
  alias wrn='wget -q -O- localhost:5111/logLevel/warn'
124
124
 
125
+ cmetrics()
126
+ {
127
+ wget -qO- localhost:5111/metrics
128
+ }
129
+
125
130
  cmstat()
126
131
  {
127
132
  wget -qO- localhost:5111\${1}
package/src/helmup CHANGED
@@ -60,7 +60,57 @@ function checkMonitoringNS(){
60
60
  fi
61
61
  }
62
62
 
63
+ function upgradeMonitoringCharts(){
64
+ if [[ `git status --porcelain` ]];
65
+ then
66
+ cat<<DIRTYGIT
67
+
68
+ $RED_ERROR This git repo must be clean before we can do the monitoring
69
+ upgrade so either commit or stash and rerun.
70
+
71
+ `git status`
72
+
73
+ DIRTYGIT
74
+ exit 1
75
+ fi
76
+
77
+ if [ -f values-monitoring.yaml ] || [ -d monitoring ];
78
+ then
79
+ rm -rf values-monitoring.yaml monitoring
80
+ git add -A
81
+ fi
82
+
83
+ # blow away the existing deployment
84
+ helm delete --purge monitoring
85
+
86
+ # Make certain the baseline branch is up to date
87
+ git fetch origin new-baseline:new-baseline
88
+
89
+ NEWMON="elasticsearch-exporter grafana prometheus stackdriver-exporter"
90
+ for SOURCE in $NEWMON;
91
+ do
92
+ printf "Grabbing $SOURCE from new-baseline\n"
93
+ git checkout --quiet new-baseline $SOURCE
94
+ done
95
+
96
+ cat<<RERUN
97
+
98
+ `git status`
99
+
100
+ $GREEN_INFO Make certain the staged mods to this git repo are committed and
101
+ pushed so things don't get twisted up and sad.
102
+
103
+ $GREEN_INFO Preparing to rerun overwhelm before continuing with the upgrade.
104
+
105
+ Hit return to coninue...
106
+ RERUN
107
+
108
+ read ANS && overwhelm
109
+ }
110
+
63
111
  function installMonitoringCharts(){
112
+ upgradeMonitoringCharts
113
+
64
114
  ## Set the project id by parsing current context
65
115
  currContext=`kubectl config current-context`
66
116
 
@@ -95,19 +145,26 @@ function installMonitoringCharts(){
95
145
  --namespace monitoring \
96
146
  -f grafana/values-grafana.yaml \
97
147
  --version 5.0.3
148
+ }
149
+
150
+ function monitoringHelp(){
151
+ MONPASS=`kubectl get secret --namespace monitoring grafana -o jsonpath='{.data.admin-password}' | base64 --decode`
98
152
 
99
- ## Print out instructions
100
- printf "\n$GREEN_INFO To access prometheus =>\n\n"
101
- printf "Prometheus Server (manage targets, configs, alerts): \n
153
+ cat<<ACCESS
154
+ `color g "Proxy to Prometheus (manage targets, configs, alerts):"`
102
155
  export POD_NAME=\$(kubectl get pods --namespace monitoring -l 'app=prometheus,component=server' -o jsonpath='{.items[0].metadata.name}')
103
- kubectl --namespace monitoring port-forward \$POD_NAME 9090\n\n"
156
+ kubectl --namespace monitoring port-forward \$POD_NAME 9090
104
157
 
105
- printf "Alertmanager (manage alert notification, silences): \n
158
+ `color g "Proxy to Alertmanager (manage alert notification, silences):"`
106
159
  export POD_NAME=\$(kubectl get pods --namespace monitoring -l 'app=prometheus,component=alertmanager' -o jsonpath='{.items[0].metadata.name}')
107
- kubectl --namespace monitoring port-forward \$POD_NAME 9093\n\n"
160
+ kubectl --namespace monitoring port-forward \$POD_NAME 9093
108
161
 
109
- printf "$YELO_WARN Save Grafana password to Keeweb if you haven't already & create ingress\n\n"
110
- printf " kubectl get secret --namespace monitoring grafana -o jsonpath='{.data.admin-password}' | base64 --decode ; echo\n\n"
162
+ `color toast "Save monitoring password to Keeweb"` => `color r $MONPASS`
163
+
164
+ `color g "Show this helpful message again with"` => `color r "helmup monitoring-wtf"`
165
+
166
+ ACCESS
167
+ exit 0
111
168
  }
112
169
 
113
170
  function createSSDYAML(){
@@ -249,28 +306,6 @@ EOK8S
249
306
  exit 1
250
307
  fi
251
308
 
252
- OLD_MONITORING="${GITTOP}/values-monitoring.yaml"
253
- if [ -f "$OLD_MONITORING" ];
254
- then
255
- cat<<OLDMON
256
-
257
- $RED_ERROR Old monitoring setup detected
258
-
259
- Monitoring now runs in the monitoring namespace, centrally managed via helmup.
260
-
261
- To migrate to the new setup:
262
- 1) Delete values-monitoring.yaml
263
- 2) Grab prometheus/values-local.yaml from master branch (modify as needed for opsgenie config)
264
- 3) Grab stackdriver-exporter/values-local.yaml from master branch
265
- 4) Create grafana dir => add .nohelm and values-grafana.yaml
266
- 5) Create elasticsearch-exporter dir => add .nohelm and values-es-exporter.yaml
267
-
268
- Now run helmup monitoring and follow directions.
269
-
270
- OLDMON
271
- exit 1
272
- fi
273
-
274
309
  npm run ahoy
275
310
  [ $? -ne 0 ] && printf "\n\n***Aborting helmup...\n\n" && exit 1
276
311
 
@@ -311,6 +346,11 @@ function doInstall() {
311
346
  "monitoring")
312
347
  checkMonitoringNS
313
348
  installMonitoringCharts
349
+ monitoringHelp
350
+ ;;
351
+
352
+ "monitoring-wtf")
353
+ monitoringHelp
314
354
  ;;
315
355
 
316
356
  "mysql")
@@ -399,9 +439,21 @@ NOTRUNNING
399
439
  esac
400
440
  done
401
441
 
402
- printf "\nRunning => helm ls\n\n"
403
- helm ls
442
+ printf "\nCheck helm deployment status by running => `color g helm\ ls`\n\n"
404
443
  }
405
444
 
406
445
  doInstall $@
407
446
  cd - &> /dev/null
447
+
448
+ OLD_MONITORING="${GITTOP}/values-monitoring.yaml"
449
+ if [ -f "$OLD_MONITORING" ];
450
+ then
451
+ cat<<OLDMON
452
+
453
+ $YELO_WARN The old monitoring setup has been detected.
454
+ Upgrade by running => `color g "helmup monitoring"`
455
+
456
+ OLDMON
457
+ exit 1
458
+ fi
459
+
package/src/overwhelm CHANGED
@@ -200,26 +200,6 @@ const opt = {
200
200
 
201
201
  const ahoy = glob.sync( '*/', opt )
202
202
 
203
- // Keel supports a "never" policy which will cause it to skip over a release
204
- // if it is properly set. Adding a .nokeel file to a release directoy will
205
- // cause the creation of the file if it does not already exist.
206
- const generateKeelNeverPolicy = ( fileName ) => {
207
- if ( fs.existsSync( fileName ) ) return
208
- const neverPolicy = `
209
- keel:
210
- # keel policy (all/major/minor/patch/force)
211
- policy: "never"
212
- # approvals
213
- # approvals: 1
214
- # approvalDeadline: 24
215
- # # images to track and update
216
- # images:
217
- # - repository: never.IMAGE # [1]
218
- # tag: never.VERSION # [2]
219
- `
220
- fs.writeFileSync( fileName, neverPolicy )
221
- }
222
-
223
203
  // Generate the values.yaml files in directories not marked with .nohelm.
224
204
  ahoy.forEach( ( dir ) => {
225
205
  if ( !fs.existsSync( `${dir}/.nohelm` ) ) {
@@ -230,10 +210,6 @@ ahoy.forEach( ( dir ) => {
230
210
  // Add support for localized values for things like keel (or whatever)
231
211
  const valuesLocal = `${dir}values-local.yaml`
232
212
 
233
- if ( fs.existsSync( `${dir}.nokeel` ) ) {
234
- generateKeelNeverPolicy( valuesLocal )
235
- }
236
-
237
213
  if ( fs.existsSync( valuesLocal ) ) {
238
214
  console.log( ` Local values in ${valuesLocal}` )
239
215
  valuesOut += `\n# AHOY => values-local.yaml\n\n`
@@ -246,10 +222,11 @@ ahoy.forEach( ( dir ) => {
246
222
  }
247
223
  } )
248
224
 
225
+
249
226
  // Set the GCP context for safety!
250
- const clusterName = over['CLUSTER_NAME']
251
- const projectId = over['PROJECT_ID']
252
- const zone = over['GCE_REGION'] + ( over['GCE_ZONE'] ? `-${over['GCE_ZONE']}` : '' )
227
+ let clusterName = over['CLUSTER_NAME']
228
+ let projectId = over['PROJECT_ID']
229
+ let zone = over['GCE_REGION'] + ( over['GCE_ZONE'] ? `-${over['GCE_ZONE']}` : '' )
253
230
 
254
231
  if ( !clusterName ) {
255
232
  console.log( chalk.yellow(
@@ -278,9 +255,20 @@ ahoy.forEach( ( dir ) => {
278
255
  } catch (err) { }
279
256
 
280
257
  const currentCtx = kubeout.toString().trim()
281
- const desiredCtx = `gke_${projectId}_${zone}_${clusterName}`
258
+ let desiredCtx = `gke_${projectId}_${zone}_${clusterName}`
259
+ let cmd = `gcloud container clusters get-credentials ${clusterName} --zone ${zone} --project ${projectId}`
260
+
261
+ // Check if we are using AWS
262
+ if(cfgs['CLOUD'] === 'aws'){
263
+ const awsAcctId = cfgs['AWS_ACCT_ID']
264
+ zone = over['AWS_REGION']
265
+ desiredCtx = `arn:aws:eks:${zone}:${awsAcctId}:cluster/${clusterName}`
266
+ cmd = `aws eks --region ${zone} update-kubeconfig --name ${clusterName}`
267
+ }
268
+
269
+ // TODO - FETCH AWS CLUSTER CREDENTIALS
270
+
282
271
  const matchedCtx = ( currentCtx === desiredCtx )
283
- const cmd = `gcloud container clusters get-credentials ${clusterName} --zone ${zone} --project ${projectId}`
284
272
 
285
273
  if ( matchedCtx ) {
286
274
  console.log( `
@@ -293,21 +281,21 @@ ahoy.forEach( ( dir ) => {
293
281
  else {
294
282
  console.log( `
295
283
 
296
- You are about to change your GCP context to:
284
+ You are about to change your Kubernetes context to:
297
285
  CLUSTER_NAME => ${chalk.bold.green(clusterName)}
298
286
  PROJECT_ID => ${chalk.bold.green(projectId)}
299
- GCE_REGION => ${chalk.bold.green(zone)}
287
+ REGION => ${chalk.bold.green(zone)}
300
288
 
301
289
  ` )
302
290
  }
303
291
  const ans = ask.question( `Enter "${chalk.bold.green( 'yes' )}" if you wish to fetch the credentials => ` )
304
292
  if ( ans !== 'yes' ) {
305
293
  if ( matchedCtx ) {
306
- console.log( chalk.bold.yellow( `\n\nSkipping a refetch of your GCP context and credentials\n\n` ) )
294
+ console.log( chalk.bold.yellow( `\n\nSkipping a refetch of your Kubernetes context and credentials\n\n` ) )
307
295
  process.exit( 0 )
308
296
  }
309
297
 
310
- console.log( chalk.bold.red( `\n\nYour GCP context and credentials do NOT match - this could be bad!\n\n` ) )
298
+ console.log( chalk.bold.red( `\n\nYour Kubernetes context and credentials do NOT match - this could be bad!\n\n` ) )
311
299
  process.exit( 1 )
312
300
  }
313
301