@leverege/build-tools 2.90.0-quinn.4 → 2.90.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.
- package/README.md +38 -18
- package/package.json +7 -9
- package/src/Utils.mjs +45 -0
- package/src/bash-funcs +18 -0
- package/src/chart-compass.mjs +12 -1
- package/src/chart-to-registry.mjs +29 -19
- package/src/clone-cnpg-from-snapshot.mjs +1 -1
- package/src/helm-charts/prom-operator/helmup.plugin +1 -1
- package/src/helmup.sh +21 -11
- package/src/k8scale.sh +11 -5
- package/src/k8x.sh +12 -7
- package/leverege-build-tools-2.21.13.tgz +0 -0
- package/lib/server/build-tools.js +0 -138
- package/lib/server/firebaseDeploy.js +0 -195
- package/lib/server/firebaseServe.js +0 -116
- package/lib/server/getfbcfg.js +0 -25
- package/lib/server/getjson.js +0 -70
- package/lib/server/overwhelm.js +0 -447
- package/lib/server/push-my-chart.js +0 -18
- package/lib/server/refresh-npm-token.js +0 -135
- package/lib/server/tag-release.js +0 -681
- package/lib/server/unleash.js +0 -50
- package/lib/web/build-tools.js +0 -138
- package/lib/web/firebaseDeploy.js +0 -195
- package/lib/web/firebaseServe.js +0 -116
- package/lib/web/getfbcfg.js +0 -25
- package/lib/web/getjson.js +0 -70
- package/lib/web/overwhelm.js +0 -447
- package/lib/web/push-my-chart.js +0 -18
- package/lib/web/refresh-npm-token.js +0 -135
- package/lib/web/tag-release.js +0 -681
- package/lib/web/unleash.js +0 -50
- package/src/prepack.mjs +0 -92
package/README.md
CHANGED
|
@@ -13,30 +13,50 @@ npm install -g @leverege/build-tools
|
|
|
13
13
|
## Tool Descriptions
|
|
14
14
|
|
|
15
15
|
### General Tools:
|
|
16
|
-
* **build-tools**:
|
|
17
|
-
* **
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
* **build-tools**: a command to get the root of this repo, a latest version check, or bash functions to source
|
|
17
|
+
* **bash-funcs**: handy set of commonly used bash function that can be sourced by adding this to a script:
|
|
18
|
+
```bash
|
|
19
|
+
. `build-tools --bashfun`
|
|
20
|
+
```
|
|
21
|
+
* **docker-to-registry**: used to build and deploy docker images to the GCP image area
|
|
21
22
|
|
|
22
23
|
### Helm Helpers:
|
|
23
|
-
* **overwhelm**:
|
|
24
|
-
* **
|
|
25
|
-
* **
|
|
26
|
-
* **
|
|
27
|
-
* **helm-repos-reload** : Reloads the commonly used helm repositories
|
|
24
|
+
* **overwhelm**: a k8s context helper and yaml replacer *${REPLACE_ME}*
|
|
25
|
+
* **helmup**: a context safe helm deployment tool
|
|
26
|
+
* **helmdn**: a destroyer of helm deployments (danger zone)
|
|
27
|
+
* **helm-audit** : fetch and display deployed service chart and application versions
|
|
28
28
|
|
|
29
29
|
### Kubernetes Helpers:
|
|
30
|
-
* **k8x**:
|
|
30
|
+
* **k8x**: a script to help run commands on active pods in a k8s cluster
|
|
31
|
+
```bash
|
|
32
|
+
Usage: k8x [target] where target can be one of the following or omitted for bash
|
|
33
|
+
cnpg - run bash on a cloudnative-pg cluster node
|
|
34
|
+
es8 - run bash on an elasticsearch8 node
|
|
35
|
+
grafana - run bash on grafana in prometheus operator namespace
|
|
36
|
+
grafold - run bash on grafana in legacy monitor namespace
|
|
37
|
+
prometheus - run bash on prometheus operator server
|
|
38
|
+
psql - run psql on a legacy database node
|
|
39
|
+
redis - run redis-cli on a redis master/replica
|
|
40
|
+
valkey - run valkey-cli on a valkeymaster/replica
|
|
41
|
+
|
|
42
|
+
help - this right here
|
|
43
|
+
```
|
|
44
|
+
* **k8scale**: a script for scaling deployed services
|
|
45
|
+
```bash
|
|
46
|
+
Usage: k8scale <up|dn|down|roll> [services]
|
|
47
|
+
dn|down - scales a service to zero pods
|
|
48
|
+
up - allows service to scale up to minReplicas
|
|
49
|
+
roll - performs a rolling restart of pods in a service
|
|
50
|
+
```
|
|
51
|
+
* **klog**: tails the logs of the specified service
|
|
52
|
+
|
|
31
53
|
|
|
32
54
|
### Git Helpers:
|
|
33
|
-
* **git-tar**:
|
|
34
|
-
* **dirty-git**:
|
|
35
|
-
* **prune-git**:
|
|
36
|
-
* **pull-git**:
|
|
55
|
+
* **git-tar**: a git safety net which is described [here on github](https://github.com/jphelps413/git-tar)
|
|
56
|
+
* **dirty-git**: feed it a list of directories and it will show which are locally modified or stashed.
|
|
57
|
+
* **prune-git**: performs maintenance on a list of git repositories.
|
|
58
|
+
* **pull-git**: walks a list of git repos, pulling each if they are clean.
|
|
37
59
|
|
|
38
60
|
## Authors
|
|
39
61
|
|
|
40
|
-
* **
|
|
41
|
-
* **Yitaek Hwang**
|
|
42
|
-
* **Michael Quinn**
|
|
62
|
+
* **DevOps and Friends**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leverege/build-tools",
|
|
3
|
-
"version": "2.90.0
|
|
3
|
+
"version": "2.90.0",
|
|
4
4
|
"description": "A collection of build / support tools for Leverege developers",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -11,25 +11,23 @@
|
|
|
11
11
|
"clean": "rm -rf lib",
|
|
12
12
|
"lint": "find ./src -name \\*.\\*js | xargs npx eslint --report-unused-disable-directives",
|
|
13
13
|
"prepare": "[ $SKIP_PREPARE ] && exit 0 || ./src/hook-and-release.mjs",
|
|
14
|
-
"test": "echo \"no tests specified\" && exit 0"
|
|
15
|
-
"prepack": "npm exec prepack"
|
|
14
|
+
"test": "echo \"no tests specified\" && exit 0"
|
|
16
15
|
},
|
|
17
16
|
"bin": {
|
|
17
|
+
"build-tools": "src/build-tools.mjs",
|
|
18
18
|
"build-and-push": "src/build-and-push.sh",
|
|
19
19
|
"build-cnpg-image": "src/build-cnpg-image.mjs",
|
|
20
|
-
"build-tools": "src/build-tools.mjs",
|
|
21
20
|
"chart-to-museum": "src/chart-to-museum.mjs",
|
|
22
21
|
"chart-to-registry": "src/chart-to-registry.mjs",
|
|
23
|
-
"prepack": "src/prepack.mjs",
|
|
24
22
|
"circleate": "src/circleate.sh",
|
|
25
23
|
"clone-cnpg-from-snapshot": "src/clone-cnpg-from-snapshot.mjs",
|
|
26
24
|
"count-lines-of-code": "src/count-lines-of-code.mjs",
|
|
27
25
|
"decrypt-secrets": "src/decrypt-secrets.sh",
|
|
28
26
|
"dirty-git": "src/dirty-git.sh",
|
|
27
|
+
"dockreate": "src/dockreate.sh",
|
|
28
|
+
"docker-to-registry": "src/docker-to-registry.mjs",
|
|
29
29
|
"docker-to-registry-py": "src/docker-to-registry-py.mjs",
|
|
30
30
|
"docker-to-registry.sh": "src/docker-to-registry.sh",
|
|
31
|
-
"docker-to-registry": "src/docker-to-registry.mjs",
|
|
32
|
-
"dockreate": "src/dockreate.sh",
|
|
33
31
|
"encrypt-secrets": "src/encrypt-secrets.sh",
|
|
34
32
|
"firebaseDeploy": "src/firebaseDeploy.mjs",
|
|
35
33
|
"firebaseServe": "src/firebaseServe.mjs",
|
|
@@ -40,8 +38,8 @@
|
|
|
40
38
|
"helm-audit": "src/helm-audit.mjs",
|
|
41
39
|
"helmcycle": "src/helmup.sh",
|
|
42
40
|
"helmdn": "src/helmdn.sh",
|
|
43
|
-
"helminit": "src/helmup.sh",
|
|
44
41
|
"helmup": "src/helmup.sh",
|
|
42
|
+
"helminit": "src/helmup.sh",
|
|
45
43
|
"helmwhat": "src/helmup.sh",
|
|
46
44
|
"hook-and-release": "src/hook-and-release.mjs",
|
|
47
45
|
"init-my-chart": "src/init-my-chart.mjs",
|
|
@@ -82,7 +80,7 @@
|
|
|
82
80
|
"js-yaml": "^4.1.1",
|
|
83
81
|
"jsdoc": "^4.0.5",
|
|
84
82
|
"ms": "^2.1.3",
|
|
85
|
-
"npm-registry-fetch": "^19.1.
|
|
83
|
+
"npm-registry-fetch": "^19.1.1",
|
|
86
84
|
"ora": "^9.0.0",
|
|
87
85
|
"p-limit": "^7.2.0",
|
|
88
86
|
"package-up": "^5.0.0",
|
package/src/Utils.mjs
CHANGED
|
@@ -98,6 +98,27 @@ export const shellCmd = async ( cmd, opts = {} ) => {
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
+
export const establishOauthAccess = async ( registryLocation = 'us-docker.pkg.dev' ) => {
|
|
102
|
+
// gcloud auth print-access-token | helm registry login -u oauth2accesstoken \
|
|
103
|
+
// -p ${password} https://us-docker.pkg.dev
|
|
104
|
+
//
|
|
105
|
+
// Get the current access token and use it to login to the registry with helm.
|
|
106
|
+
try {
|
|
107
|
+
const accessToken = await shellCmd( 'gcloud auth print-access-token' )
|
|
108
|
+
// -p is frowned upon but using a pipe | is problematic with shellCmd (execa)
|
|
109
|
+
const registryLoginCommand = `helm registry login -u oauth2accesstoken -p ${accessToken}`
|
|
110
|
+
|
|
111
|
+
const loginResult = await shellCmd( `${registryLoginCommand} https://${registryLocation}` )
|
|
112
|
+
debug( { loginResult }, '<==registryLogin' )
|
|
113
|
+
} catch ( error ) {
|
|
114
|
+
// on exception we probably need to reestablish gcloud auth login
|
|
115
|
+
if ( /gcloud auth login|obtain new credentials/i.test( error.stderr || err.message ) ) {
|
|
116
|
+
errorExit( '⚠️ GCP credentials expired. Please run: gcloud auth login' )
|
|
117
|
+
}
|
|
118
|
+
errorExit( error )
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
101
122
|
export const mkdirSafe = ( dir ) => {
|
|
102
123
|
try {
|
|
103
124
|
fs.mkdirSync( dir, { recursive : true } ) // eslint-disable-line security/detect-non-literal-fs-filename
|
|
@@ -450,6 +471,7 @@ export const parseHelmChart = async ( helmroot = './helm' ) => {
|
|
|
450
471
|
const chartFiles = fs.readdirSync( helmroot, { encoding : 'utf8', recursive : true } )
|
|
451
472
|
const chartYaml = YAML.load( fs.readFileSync( `${helmroot}/Chart.yaml`, 'utf8' ) )
|
|
452
473
|
const chartName = chartYaml.name
|
|
474
|
+
const chartLibrary = chartYaml?.type === 'library'
|
|
453
475
|
const chartVersion = chartYaml.version
|
|
454
476
|
const chartPackage = `${chartName}-${chartVersion}.tgz`
|
|
455
477
|
const valuesYaml = YAML.load( fs.readFileSync( `${helmroot}/values.yaml`, 'utf8' ) )
|
|
@@ -459,11 +481,34 @@ export const parseHelmChart = async ( helmroot = './helm' ) => {
|
|
|
459
481
|
}
|
|
460
482
|
const imageRegistry = valuesYaml.image?.registry
|
|
461
483
|
const registryComponents = imageRegistry.split( '/' )
|
|
484
|
+
|
|
485
|
+
// See if this is a leaf chart and whether or not dependencies need updating
|
|
486
|
+
const hasDependencies = chartYaml.dependencies !== undefined
|
|
487
|
+
let depsOutOfSync
|
|
488
|
+
if ( chartFiles.includes( 'Chart.lock' ) ) {
|
|
489
|
+
const chartLock = YAML.load( fs.readFileSync( `${helmroot}/Chart.lock`, 'utf8' ) )
|
|
490
|
+
// Using Object.fromEntries will be able to handle multiple dependencies if ever needed
|
|
491
|
+
const chartDeps = Object.fromEntries(
|
|
492
|
+
chartYaml.dependencies.map( d => [ d.name, d.version ] )
|
|
493
|
+
)
|
|
494
|
+
const lockDeps = Object.fromEntries(
|
|
495
|
+
chartLock.dependencies.map( d => [ d.name, d.version ] )
|
|
496
|
+
)
|
|
497
|
+
const mismatches = Object.entries( chartDeps ).filter( ( [ name, version ] ) => {
|
|
498
|
+
return lockDeps[name] !== version
|
|
499
|
+
} )
|
|
500
|
+
|
|
501
|
+
depsOutOfSync = mismatches.length > 0
|
|
502
|
+
}
|
|
462
503
|
/* eslint-enable security/detect-non-literal-fs-filename */
|
|
504
|
+
|
|
463
505
|
return ( {
|
|
464
506
|
chartName,
|
|
507
|
+
chartLibrary,
|
|
465
508
|
chartPackage,
|
|
466
509
|
chartVersion,
|
|
510
|
+
hasDependencies,
|
|
511
|
+
depsOutOfSync,
|
|
467
512
|
imageRegistry,
|
|
468
513
|
registryLocation : registryComponents[0],
|
|
469
514
|
registryProject : registryComponents[1],
|
package/src/bash-funcs
CHANGED
|
@@ -138,6 +138,24 @@ SKIPPING
|
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
function addHelmRepo() {
|
|
141
|
+
# This is a typical list that can build up over time.
|
|
142
|
+
#
|
|
143
|
+
# helm repo list
|
|
144
|
+
# NAME URL
|
|
145
|
+
#
|
|
146
|
+
# traefik https://helm.traefik.io/traefik
|
|
147
|
+
# leverege https://chartmuseum.leverege.com/
|
|
148
|
+
# estafette https://helm.estafette.io
|
|
149
|
+
# emberstack https://emberstack.github.io/helm-charts
|
|
150
|
+
# stakater https://stakater.github.io/stakater-charts
|
|
151
|
+
# vmware-tanzu https://vmware-tanzu.github.io/helm-charts
|
|
152
|
+
# cnpg https://cloudnative-pg.github.io/charts
|
|
153
|
+
# prometheus-community https://prometheus-community.github.io/helm-charts
|
|
154
|
+
# grafana https://grafana.github.io/helm-charts
|
|
155
|
+
# elastic https://helm.elastic.co
|
|
156
|
+
# bitnami-old https://raw.githubusercontent.com/bitnami/charts/eb5f9a9513d987b519f0ecd732e7031241c50328/bitnami
|
|
157
|
+
# bitnami https://charts.bitnami.com/bitnami
|
|
158
|
+
#
|
|
141
159
|
[ ! -z "$SKIP_ADD_HELM_REPO" ] && return
|
|
142
160
|
local chart=$1
|
|
143
161
|
local url=$2
|
package/src/chart-compass.mjs
CHANGED
|
@@ -107,15 +107,24 @@ if ( args.init ) {
|
|
|
107
107
|
|
|
108
108
|
// simply wraps the YAML read/sync
|
|
109
109
|
const buildCompassMap = ( yamlFile ) => {
|
|
110
|
+
if ( !fs.existsSync( yamlFile ) ) {
|
|
111
|
+
debug( `chart-compass file ${yamlFile} does not exist` )
|
|
112
|
+
process.exit( 1 )
|
|
113
|
+
}
|
|
114
|
+
|
|
110
115
|
const chartCompass = YAML.load( fs.readFileSync( yamlFile, 'utf8' ) )
|
|
111
116
|
return chartCompass
|
|
112
117
|
}
|
|
113
118
|
|
|
114
119
|
const findChartUrl = ( config, chartName ) => {
|
|
120
|
+
if ( !chartName ) {
|
|
121
|
+
errorExit( 'no chart name speficied' )
|
|
122
|
+
}
|
|
123
|
+
|
|
115
124
|
for ( const entry of config ) {
|
|
116
125
|
const chartsPath = entry.charts_path || 'charts'
|
|
117
126
|
for ( const [ repo, charts ] of Object.entries( entry.repositories ) ) {
|
|
118
|
-
debug( {
|
|
127
|
+
debug( { repo, charts }, `<==findChartUrl in repo ${chalk.bold.yellow( repo )}` )
|
|
119
128
|
if ( charts.includes( chartName ) ) {
|
|
120
129
|
return `${entry.registry}/${repo}/${chartsPath}/${chartName}`
|
|
121
130
|
}
|
|
@@ -129,6 +138,8 @@ const compassMap = buildCompassMap( compassYaml )
|
|
|
129
138
|
|
|
130
139
|
const chartRegistry = findChartUrl( compassMap, args.service )
|
|
131
140
|
|
|
141
|
+
debug( { compassYaml, compassMap, chartRegistry }, '<==Chart Compass Details' )
|
|
142
|
+
|
|
132
143
|
if ( chartRegistry ) {
|
|
133
144
|
log( chartRegistry )
|
|
134
145
|
} else {
|
|
@@ -12,6 +12,7 @@ import { lt as semverLt } from 'semver'
|
|
|
12
12
|
import {
|
|
13
13
|
debug,
|
|
14
14
|
errorExit,
|
|
15
|
+
establishOauthAccess,
|
|
15
16
|
log,
|
|
16
17
|
warning,
|
|
17
18
|
parseHelmChart,
|
|
@@ -97,7 +98,13 @@ const helmChart = await parseHelmChart( args.chart )
|
|
|
97
98
|
const registryLocation = args.location || helmChart.registryLocation
|
|
98
99
|
const registryProject = args.project || helmChart.registryProject
|
|
99
100
|
const registryRepository = args.repository || helmChart.registryRepository
|
|
100
|
-
|
|
101
|
+
|
|
102
|
+
let ociPushEndpoint = `oci://${registryLocation}/${registryProject}/${registryRepository}`
|
|
103
|
+
// charts that are type "library" are base charts used via chart dependencies, however if
|
|
104
|
+
// the chart is a downstream chart then add the "/charts" suffix for backwards compatibility
|
|
105
|
+
if ( !helmChart.chartLibrary ) {
|
|
106
|
+
ociPushEndpoint += '/charts'
|
|
107
|
+
}
|
|
101
108
|
|
|
102
109
|
debug( {
|
|
103
110
|
helmChart,
|
|
@@ -106,38 +113,41 @@ debug( {
|
|
|
106
113
|
registryRepository,
|
|
107
114
|
ociPushEndpoint }, '<==Parsed package and chart' )
|
|
108
115
|
|
|
109
|
-
//
|
|
110
|
-
|
|
111
|
-
//
|
|
112
|
-
// Get the current access token and use it to login to the registry with helm.
|
|
113
|
-
try {
|
|
114
|
-
const accessToken = await shellCmd( 'gcloud auth application-default print-access-token' )
|
|
115
|
-
// -p is frowned upon but using a pipe | is problematic with shellCmd (execa)
|
|
116
|
-
const registryLoginCommand = `helm registry login -u oauth2accesstoken -p ${accessToken}`
|
|
116
|
+
// deal with oauth token shenanigans
|
|
117
|
+
await establishOauthAccess( registryLocation )
|
|
117
118
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
119
|
+
const {
|
|
120
|
+
chartName,
|
|
121
|
+
chartPackage,
|
|
122
|
+
chartVersion,
|
|
123
|
+
depsOutOfSync,
|
|
124
|
+
} = helmChart
|
|
123
125
|
|
|
124
|
-
const { chartName, chartPackage, chartVersion } = helmChart
|
|
125
126
|
try {
|
|
126
127
|
await shellCmd( `helm pull ${ociPushEndpoint}/${chartName} --version ${chartVersion}` )
|
|
127
128
|
rmSync( chartPackage )
|
|
128
129
|
if ( args.force ) {
|
|
129
130
|
warning( `chart ${chartName} version ${chartVersion} exists - force pushing` )
|
|
130
131
|
} else {
|
|
131
|
-
errorExit(
|
|
132
|
+
errorExit( `\n***ERROR: chart ${chartName} version ${chartVersion} already exists` )
|
|
132
133
|
}
|
|
133
134
|
} catch ( error ) {
|
|
134
135
|
debug( `Chart ${chartName} version ${chartVersion} does not exist - proceeding` )
|
|
135
136
|
}
|
|
136
137
|
|
|
138
|
+
if ( depsOutOfSync ) {
|
|
139
|
+
try {
|
|
140
|
+
log( chalk.yellow.bold( '\nChart dependedencies are out of sync - updating...\n' ) )
|
|
141
|
+
await shellCmd( 'helm dependency update ./helm', { stdio : 'inherit' } )
|
|
142
|
+
} catch ( error ) {
|
|
143
|
+
errorExit( error )
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
137
147
|
try {
|
|
138
148
|
await shellCmd( `helm package ${args.chart}` )
|
|
139
149
|
if ( !existsSync( chartPackage ) ) { // eslint-disable-line security/detect-non-literal-fs-filename
|
|
140
|
-
errorExit(
|
|
150
|
+
errorExit( `\n***ERROR: expected helm package to produce ${chartPackage}` )
|
|
141
151
|
}
|
|
142
152
|
|
|
143
153
|
log( `\nPushing ${chalk.green.bold( chartPackage )} => ${chalk.green.bold( ociPushEndpoint )}` )
|
|
@@ -148,6 +158,6 @@ try {
|
|
|
148
158
|
log( `\nDry run => ${chalk.green.bold( pushItRealGood )}` )
|
|
149
159
|
}
|
|
150
160
|
rmSync( chartPackage )
|
|
151
|
-
} catch (
|
|
152
|
-
errorExit(
|
|
161
|
+
} catch ( error ) {
|
|
162
|
+
errorExit( error )
|
|
153
163
|
}
|
|
@@ -118,7 +118,7 @@ To deploy the volume snapshots to your Kubernetes cluster:
|
|
|
118
118
|
|
|
119
119
|
Once applied, reference the following VolumeSnapshot in your CNPG cluster bootstrap config:
|
|
120
120
|
|
|
121
|
-
spec.bootstrap.recovery.
|
|
121
|
+
spec.bootstrap.recovery.volumeSnapshots.storage.name: ${k8sSnapshotName}
|
|
122
122
|
|
|
123
123
|
Then deploy your CNPG cluster normally. Validate the cluster startup:
|
|
124
124
|
|
|
@@ -6,7 +6,7 @@ addHelmRepo prometheus-community https://prometheus-community.github.io/helm-cha
|
|
|
6
6
|
NS="--namespace prometheus"
|
|
7
7
|
|
|
8
8
|
showInstalling "The Prometheus Operator (kube-prometheus-stack)"
|
|
9
|
-
[ -z "$PROMETHEUS_STACK_CHART_VERSION" ] && PROMETHEUS_STACK_CHART_VERSION="
|
|
9
|
+
[ -z "$PROMETHEUS_STACK_CHART_VERSION" ] && PROMETHEUS_STACK_CHART_VERSION="79"
|
|
10
10
|
|
|
11
11
|
# https://artifacthub.io/packages/helm/prometheus-community/kube-prometheus-stack
|
|
12
12
|
helm upgrade $NS --install prometheus-stack prometheus-community/kube-prometheus-stack \
|
package/src/helmup.sh
CHANGED
|
@@ -513,6 +513,23 @@ $BANNER_TXT
|
|
|
513
513
|
HELMUP_BANNER
|
|
514
514
|
}
|
|
515
515
|
|
|
516
|
+
findChartLocation() {
|
|
517
|
+
local service_name="$1"
|
|
518
|
+
local output
|
|
519
|
+
|
|
520
|
+
# check the compass for a chart location
|
|
521
|
+
if output="$(chart-compass --service "$service_name")";
|
|
522
|
+
then
|
|
523
|
+
# chart exists in local chart-compass.yaml
|
|
524
|
+
local chart_location="oci://$output"
|
|
525
|
+
else
|
|
526
|
+
# nope - fallback to using the legacy museum location
|
|
527
|
+
local chart_location="leverege/$service_name"
|
|
528
|
+
fi
|
|
529
|
+
|
|
530
|
+
echo "$chart_location"
|
|
531
|
+
}
|
|
532
|
+
|
|
516
533
|
function doHelmup() {
|
|
517
534
|
local culprit="--set helmup.culprit=\"$(gcloud config get account)\""
|
|
518
535
|
local deployT="--set helmup.deployT=\"$(date -u +'%Y-%m-%dT%H:%M:%SZ')\""
|
|
@@ -582,6 +599,8 @@ CATBACKUP
|
|
|
582
599
|
# during initial install then do so here
|
|
583
600
|
ifPluggedInOrBootstrapped $SERVICE && continue
|
|
584
601
|
|
|
602
|
+
local CHART_LOCATION="$(findChartLocation $SERVICE)"
|
|
603
|
+
|
|
585
604
|
case "$SERVICE" in
|
|
586
605
|
"platform")
|
|
587
606
|
doPlatormPreInstallChecks
|
|
@@ -670,17 +689,8 @@ NO_SERVICE_MAN
|
|
|
670
689
|
|
|
671
690
|
checkUpgradeNotes $SERVICE
|
|
672
691
|
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
# reference by the downstream repositories via the .helmup-charmuseum file.
|
|
676
|
-
OVERRIDE="$SERVICE/.helmup-chartmuseum"
|
|
677
|
-
MUSEUM=$SERVICE
|
|
678
|
-
if [ -f $OVERRIDE ];
|
|
679
|
-
then
|
|
680
|
-
MUSEUM=$(<${OVERRIDE})
|
|
681
|
-
printf "\n$YELO_WARN Local chartmuseum name override from ${SERVICE} to ${MUSEUM}\n"
|
|
682
|
-
fi
|
|
683
|
-
HELMUP="helm upgrade --install $SERVICE leverege/$MUSEUM -f $SERVICE/values.yaml $CHARTVER $HELM_WHAT"
|
|
692
|
+
HELMUP="helm upgrade --install $SERVICE $CHART_LOCATION -f $SERVICE/values.yaml $CHARTVER $HELM_WHAT"
|
|
693
|
+
|
|
684
694
|
doHelmup $HELMUP
|
|
685
695
|
SAVERR=$?
|
|
686
696
|
if [ $SAVERR -ne 0 ];
|
package/src/k8scale.sh
CHANGED
|
@@ -5,10 +5,6 @@
|
|
|
5
5
|
|
|
6
6
|
GITTOP=`git rev-parse --show-toplevel` && cd $GITTOP
|
|
7
7
|
|
|
8
|
-
overwhelm
|
|
9
|
-
[ $? -ne 0 ] && printf "\n\n***Aborting helmup...\n\n" && exit 1
|
|
10
|
-
GCP_PROJECT_ID="$(getProjectIdFromK8sContext)"
|
|
11
|
-
|
|
12
8
|
REPLICAS=
|
|
13
9
|
DIRECTION=$1 && shift
|
|
14
10
|
case $DIRECTION in
|
|
@@ -23,9 +19,19 @@ case $DIRECTION in
|
|
|
23
19
|
DIRECTION=roll
|
|
24
20
|
;;
|
|
25
21
|
*)
|
|
26
|
-
|
|
22
|
+
cat<<K8SCALE_HELP
|
|
23
|
+
|
|
24
|
+
Usage: `color g 'k8scale <up|dn|down|roll> [services]'`
|
|
25
|
+
dn|down - scales a service to zero pods
|
|
26
|
+
up - allows service to scale up to minReplicas
|
|
27
|
+
roll - performs a rolling restart of pods in a service
|
|
28
|
+
K8SCALE_HELP
|
|
29
|
+
exit 1
|
|
27
30
|
esac
|
|
28
31
|
|
|
32
|
+
overwhelm
|
|
33
|
+
[ $? -ne 0 ] && printf "\n\n***Aborting helmup...\n\n" && exit 1
|
|
34
|
+
|
|
29
35
|
printf " scaled => `color g $DIRECTION`\n\n"
|
|
30
36
|
for DEPLOYMENT in "$@";
|
|
31
37
|
do
|
package/src/k8x.sh
CHANGED
|
@@ -19,13 +19,18 @@ case "$cmd" in
|
|
|
19
19
|
"help")
|
|
20
20
|
cat<<K8X_HELP
|
|
21
21
|
|
|
22
|
-
Usage: `color g 'k8x
|
|
23
|
-
|
|
24
|
-
`color g cnpg`
|
|
25
|
-
`color g es8`
|
|
26
|
-
`color g
|
|
27
|
-
`color g
|
|
28
|
-
`color g
|
|
22
|
+
Usage: `color g 'k8x [target]'` where target can be one of the following or omitted for bash
|
|
23
|
+
|
|
24
|
+
`color g cnpg` - run bash on a cloudnative-pg cluster node
|
|
25
|
+
`color g es8` - run bash on an elasticsearch8 node
|
|
26
|
+
`color g grafana` - run bash on grafana in prometheus operator namespace
|
|
27
|
+
`color g grafold` - run bash on grafana in legacy monitor namespace
|
|
28
|
+
`color g prometheus` - run bash on prometheus operator server
|
|
29
|
+
`color g psql` - run psql on a legacy database node
|
|
30
|
+
`color g redis` - run redis-cli on a redis master/replica
|
|
31
|
+
`color g valkey` - run valkey-cli on a valkeymaster/replica
|
|
32
|
+
|
|
33
|
+
`color g help` - this right here
|
|
29
34
|
|
|
30
35
|
K8X_HELP
|
|
31
36
|
exit 0
|
|
Binary file
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
|
|
4
|
-
const fs = require('node:fs');
|
|
5
|
-
const path = require('node:path');
|
|
6
|
-
const chalk = require('chalk');
|
|
7
|
-
const cliArgs = require('command-line-args');
|
|
8
|
-
const cliHelp = require('command-line-usage');
|
|
9
|
-
const npmRegistryFetch = require('npm-registry-fetch');
|
|
10
|
-
const semverLt = require('semver/functions/lt');
|
|
11
|
-
|
|
12
|
-
/* eslint-disable no-console */
|
|
13
|
-
|
|
14
|
-
const optionList = [
|
|
15
|
-
// Use optionList to tie into the Usage statements
|
|
16
|
-
{
|
|
17
|
-
name: 'root',
|
|
18
|
-
type: Boolean,
|
|
19
|
-
default: false,
|
|
20
|
-
description: 'returns the root of the build-tools installation'
|
|
21
|
-
}, {
|
|
22
|
-
name: 'latest',
|
|
23
|
-
type: Boolean,
|
|
24
|
-
default: false,
|
|
25
|
-
description: 'verifies the latest build-tools are installed'
|
|
26
|
-
}, {
|
|
27
|
-
name: 'bashfun',
|
|
28
|
-
type: Boolean,
|
|
29
|
-
default: false,
|
|
30
|
-
description: 'source the output to define common bash helper functions'
|
|
31
|
-
}, {
|
|
32
|
-
name: 'reporoot',
|
|
33
|
-
type: Boolean,
|
|
34
|
-
default: false,
|
|
35
|
-
description: 'the root of the build-tools repo - for finding other config files'
|
|
36
|
-
}, {
|
|
37
|
-
name: 'help',
|
|
38
|
-
type: Boolean,
|
|
39
|
-
default: false,
|
|
40
|
-
description: 'display this help screen'
|
|
41
|
-
}, {
|
|
42
|
-
name: 'version',
|
|
43
|
-
type: Boolean,
|
|
44
|
-
default: false,
|
|
45
|
-
description: 'returns the build-tools repo version'
|
|
46
|
-
}, {
|
|
47
|
-
name: 'verbose',
|
|
48
|
-
alias: 'v',
|
|
49
|
-
type: Boolean,
|
|
50
|
-
default: false,
|
|
51
|
-
description: 'emit additional info at run time'
|
|
52
|
-
}];
|
|
53
|
-
const sections = [{
|
|
54
|
-
header: 'A collection of build / support tools for all Leverege code',
|
|
55
|
-
content: `README: {green https://bitbucket.org/leverege/build-tools/src/development}
|
|
56
|
-
`
|
|
57
|
-
}, {
|
|
58
|
-
header: 'Options',
|
|
59
|
-
optionList
|
|
60
|
-
}];
|
|
61
|
-
const args = cliArgs(optionList, {
|
|
62
|
-
partial: true
|
|
63
|
-
});
|
|
64
|
-
const help = cliHelp(sections);
|
|
65
|
-
const repoRoot = path.dirname(__dirname);
|
|
66
|
-
const thisPackage = require(`${repoRoot}/package.json`);
|
|
67
|
-
const thisVersion = thisPackage.version;
|
|
68
|
-
if (args.root) {
|
|
69
|
-
console.log(repoRoot);
|
|
70
|
-
process.exit(0);
|
|
71
|
-
}
|
|
72
|
-
if (args.bashfun) {
|
|
73
|
-
console.log(`${repoRoot}/src/bash-funcs`);
|
|
74
|
-
process.exit(0);
|
|
75
|
-
}
|
|
76
|
-
if (args.reporoot) {
|
|
77
|
-
console.log(`${repoRoot}`);
|
|
78
|
-
process.exit(0);
|
|
79
|
-
}
|
|
80
|
-
const checkForLatest = async (pkg = '@leverege/build-tools') => {
|
|
81
|
-
const getToken = () => {
|
|
82
|
-
const tokenFile = `${process.env.HOME}/.npmrc`;
|
|
83
|
-
if (!fs.existsSync(tokenFile)) {
|
|
84
|
-
console.error(`Cannot find token file ${tokenFile}`);
|
|
85
|
-
process.exit(1);
|
|
86
|
-
}
|
|
87
|
-
try {
|
|
88
|
-
const tokenLine = fs.readFileSync(tokenFile).toString();
|
|
89
|
-
const tokenRegX = new RegExp('.*registry.npmjs.org\\/:\\w+=+(.*)');
|
|
90
|
-
const tokenStr = tokenLine.match(tokenRegX);
|
|
91
|
-
if (!tokenStr) {
|
|
92
|
-
console.error(`\n***ERROR: malformed npm token in ${tokenFile}\n`);
|
|
93
|
-
process.exit(1);
|
|
94
|
-
}
|
|
95
|
-
return tokenLine.match(tokenRegX)[1];
|
|
96
|
-
} catch (err) {
|
|
97
|
-
console.error(err);
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
try {
|
|
101
|
-
const list = await npmRegistryFetch.json(pkg, {
|
|
102
|
-
'//registry.npmjs.org/:_authToken': getToken()
|
|
103
|
-
});
|
|
104
|
-
return list['dist-tags'].latest;
|
|
105
|
-
} catch (err) {
|
|
106
|
-
console.log(err);
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
const checkAndAnnounce = () => {
|
|
110
|
-
checkForLatest().then(latestVersion => {
|
|
111
|
-
if (semverLt(thisVersion, latestVersion)) {
|
|
112
|
-
console.log(chalk.white`
|
|
113
|
-
Update available ${chalk.grey(thisVersion)} \u2b62 ${chalk.green(latestVersion)}
|
|
114
|
-
Run ${chalk.cyan('npm i -g @leverege/build-tools')} to update
|
|
115
|
-
`);
|
|
116
|
-
process.exit(1);
|
|
117
|
-
} else {
|
|
118
|
-
process.exit(0);
|
|
119
|
-
}
|
|
120
|
-
}).catch(err => {});
|
|
121
|
-
};
|
|
122
|
-
if (args.latest) {
|
|
123
|
-
checkAndAnnounce();
|
|
124
|
-
}
|
|
125
|
-
if (args.version) {
|
|
126
|
-
console.log(`build-tools version ${thisVersion}`);
|
|
127
|
-
checkAndAnnounce();
|
|
128
|
-
}
|
|
129
|
-
if (args.help) {
|
|
130
|
-
console.log(help);
|
|
131
|
-
process.exit(0);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/* eslint-disable no-underscore-dangle */
|
|
135
|
-
if (args._unknown) {
|
|
136
|
-
console.log(`\nUnrecognized argument [${args._unknown}] try --help\n`);
|
|
137
|
-
process.exit(1);
|
|
138
|
-
}
|