@leverege/build-tools 2.63.0-pedro.1 → 2.63.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/package.json +4 -3
- package/src/build-cnpg-image.mjs +10 -5
- package/src/chart-compass.mjs +59 -20
- package/src/chart-compass.yaml +22 -0
- package/src/chart-to-museum.mjs +53 -0
- package/src/chart-to-registry.mjs +11 -30
- package/src/helm-charts/cnpg-operator/cnpg-cleanup-snapshot-cronjob.yaml +73 -0
- package/src/helm-charts/elasticsearch8/helmup.plugin +1 -1
- package/src/helm-charts/prom-operator/helmup.plugin +1 -1
- package/src/helm-charts/redis/helmup.plugin +1 -1
- package/src/helm-charts/traefik/helmup.plugin +2 -2
- package/src/helm-charts/traefik/{traefik-local.yaml → values-local.yaml} +7 -1
- package/src/helmup.sh +35 -0
- package/src/hook-and-release/Config.mjs +2 -2
- package/src/pkgck.sh +3 -3
- package/src/push-my-chart.mjs +48 -2
- package/src/refresh-py-idx.sh +5 -2
- package/.har/config.json +0 -11
- package/.har/pre-commit +0 -1
- package/.har/pre-push +0 -1
- package/.publishrc +0 -15
- package/src/docker-to-registry.sh +0 -611
- package/src/helm-charts/traefik/.nohelm +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leverege/build-tools",
|
|
3
|
-
"version": "2.63.0
|
|
3
|
+
"version": "2.63.0",
|
|
4
4
|
"description": "A collection of build / support tools for Leverege developers",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -17,6 +17,7 @@
|
|
|
17
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
|
+
"chart-to-museum": "src/chart-to-museum.mjs",
|
|
20
21
|
"chart-to-registry": "src/chart-to-registry.mjs",
|
|
21
22
|
"circleate": "src/circleate.sh",
|
|
22
23
|
"decrypt-secrets": "src/decrypt-secrets.sh",
|
|
@@ -69,7 +70,7 @@
|
|
|
69
70
|
"execa": "^9.5.2",
|
|
70
71
|
"glob": "^11.0.1",
|
|
71
72
|
"handlebars": "^4.7.8",
|
|
72
|
-
"inquirer": "^12.4.
|
|
73
|
+
"inquirer": "^12.4.2",
|
|
73
74
|
"js-yaml": "^4.1.0",
|
|
74
75
|
"jsdoc": "^4.0.4",
|
|
75
76
|
"ms": "^2.1.3",
|
|
@@ -86,4 +87,4 @@
|
|
|
86
87
|
"@leverege/eslint-config-leverege": "^5.0.1",
|
|
87
88
|
"npm": "^11.1.0"
|
|
88
89
|
}
|
|
89
|
-
}
|
|
90
|
+
}
|
package/src/build-cnpg-image.mjs
CHANGED
|
@@ -123,19 +123,24 @@ const buildAndPushImage = async () => {
|
|
|
123
123
|
debug( { renderedDockerfile }, '<==Dockerfile' )
|
|
124
124
|
|
|
125
125
|
// Write the Dockerfile to a temporary location
|
|
126
|
-
const
|
|
126
|
+
const buildDir = './build-tmp'
|
|
127
|
+
fs.mkdirSync( buildDir )
|
|
128
|
+
const dockerfilePath = path.resolve( `${buildDir}/Dockerfile` )
|
|
127
129
|
fs.writeFileSync( dockerfilePath, renderedDockerfile )
|
|
128
130
|
|
|
129
131
|
// Build the image
|
|
130
132
|
log( chalk.yellow( '\nBuilding Docker image...' ) )
|
|
131
|
-
|
|
133
|
+
const cloudBuildSubmit = 'gcloud builds submit --project leverege-registry'
|
|
134
|
+
const cloudBuildLog = '--gcs-log-dir gs://leverege-registry_cloudbuild/log'
|
|
135
|
+
const imageTag = `--tag ${LEVEREGE_IMAGE_NAME_WITH_TAG}`
|
|
136
|
+
await shellCmd( `${cloudBuildSubmit} ${cloudBuildLog} ${imageTag} ${buildDir}`, { stdio : 'inherit' } )
|
|
132
137
|
|
|
133
138
|
// Push the image
|
|
134
|
-
log( chalk.green( '\nPushing Docker image...' ) )
|
|
135
|
-
await shellCmd( `docker push ${LEVEREGE_IMAGE_NAME_WITH_TAG}`, { stdio : 'inherit' } )
|
|
139
|
+
//log( chalk.green( '\nPushing Docker image...' ) )
|
|
140
|
+
//await shellCmd( `docker push ${LEVEREGE_IMAGE_NAME_WITH_TAG}`, { stdio : 'inherit' } )
|
|
136
141
|
|
|
137
142
|
// Clean up the temporary Dockerfile
|
|
138
|
-
fs.
|
|
143
|
+
fs.rmdirSync( buildDir, { recursive : true } )
|
|
139
144
|
}
|
|
140
145
|
|
|
141
146
|
// Main execution flow
|
package/src/chart-compass.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
/* eslint-disable */
|
|
3
2
|
/*
|
|
4
|
-
* chart-to-registry will
|
|
3
|
+
* chart-to-registry will use a chart
|
|
5
4
|
*/
|
|
6
5
|
import fs from 'node:fs'
|
|
7
6
|
|
|
@@ -12,32 +11,32 @@ import { lt as semverLt } from 'semver'
|
|
|
12
11
|
import YAML from 'js-yaml'
|
|
13
12
|
|
|
14
13
|
import {
|
|
15
|
-
|
|
14
|
+
BUILD_TOOLS_ROOT,
|
|
16
15
|
debug,
|
|
17
16
|
errorExit,
|
|
18
17
|
log,
|
|
19
|
-
warning,
|
|
20
18
|
getGitRootDirectory,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
shellCmd,
|
|
20
|
+
warning,
|
|
21
|
+
} from './Utils.mjs'
|
|
24
22
|
|
|
25
23
|
const commandLineOptions = [ // Use commandLineOptions to tie into the Usage statements
|
|
26
|
-
|
|
27
24
|
{
|
|
28
|
-
name : '
|
|
25
|
+
name : 'service',
|
|
29
26
|
type : String,
|
|
30
|
-
description : '{green
|
|
27
|
+
description : '{green chart name to navigate to}',
|
|
31
28
|
},
|
|
32
29
|
{
|
|
33
|
-
name : '
|
|
30
|
+
name : 'compass',
|
|
34
31
|
type : String,
|
|
35
|
-
|
|
32
|
+
defaultValue : 'chart-compass.yaml',
|
|
33
|
+
description : '{green chart compass definition file for describing chart locations}',
|
|
36
34
|
},
|
|
37
35
|
{
|
|
38
|
-
name : '
|
|
39
|
-
type :
|
|
40
|
-
|
|
36
|
+
name : 'init',
|
|
37
|
+
type : Boolean,
|
|
38
|
+
defaultValue : false,
|
|
39
|
+
description : '{green generate a chart-compass.yaml file if none present}',
|
|
41
40
|
},
|
|
42
41
|
{
|
|
43
42
|
name : 'dry-run',
|
|
@@ -49,7 +48,6 @@ const commandLineOptions = [ // Use commandLineOptions to tie into the Usage sta
|
|
|
49
48
|
type : Boolean,
|
|
50
49
|
description : '{green display this help screen}',
|
|
51
50
|
},
|
|
52
|
-
|
|
53
51
|
]
|
|
54
52
|
|
|
55
53
|
const sections = [
|
|
@@ -79,9 +77,9 @@ if ( args._unknown ) {
|
|
|
79
77
|
}
|
|
80
78
|
/* eslint-enable no-underscore-dangle */
|
|
81
79
|
|
|
82
|
-
const minNodejsVersion = '
|
|
80
|
+
const minNodejsVersion = '22.13.0'
|
|
83
81
|
if ( semverLt( process.version, minNodejsVersion ) ) {
|
|
84
|
-
|
|
82
|
+
warning( `suggest upgrading to at least node ${minNodejsVersion} - xxx\n` )
|
|
85
83
|
}
|
|
86
84
|
|
|
87
85
|
// First of all, fail if we are not in a git repository
|
|
@@ -92,6 +90,47 @@ try {
|
|
|
92
90
|
errorExit( chalk.red.bold( error ), { errorCode : 5 } )
|
|
93
91
|
}
|
|
94
92
|
|
|
95
|
-
|
|
93
|
+
// we can initialize a new compass from the template in build-tools
|
|
94
|
+
if ( args.init ) {
|
|
95
|
+
if ( !fs.existsSync( './overwhelm.yaml' ) ) {
|
|
96
|
+
errorExit( '\n***ERROR: expected to run in the root of a platform-k8s branch - no overwhelm.yaml present' )
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if ( fs.existsSync( args.compass ) ) {
|
|
100
|
+
errorExit( `\n***ERROR: ${args.compass} compass file already exists - not overwriting` )
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const copyOut = await shellCmd( `cp ${BUILD_TOOLS_ROOT}/chart-compass.yaml ${args.compass}` )
|
|
104
|
+
log( '\nBootstrapped a new chart compass defition => ', chalk.green.bold( args.compass ) )
|
|
105
|
+
process.exit( 0 )
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// simply wraps the YAML read/sync
|
|
109
|
+
const buildCompassMap = ( yamlFile ) => {
|
|
110
|
+
const chartCompass = YAML.load( fs.readFileSync( yamlFile, 'utf8' ) )
|
|
111
|
+
return chartCompass
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const findChartUrl = ( config, chartName ) => {
|
|
115
|
+
for ( const entry of config ) {
|
|
116
|
+
const chartsPath = entry.charts_path || 'charts'
|
|
117
|
+
for ( const [ repo, charts ] of Object.entries( entry.repositories ) ) {
|
|
118
|
+
debug( { entry, repo, charts }, '<==for Object.entries' )
|
|
119
|
+
if ( charts.includes( chartName ) ) {
|
|
120
|
+
return `${entry.registry}/${repo}/${chartsPath}/${chartName}`
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return undefined
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const compassYaml = `${gitRoot}/${args.compass}`
|
|
128
|
+
const compassMap = buildCompassMap( compassYaml )
|
|
129
|
+
|
|
130
|
+
const chartRegistry = findChartUrl( compassMap, args.service )
|
|
96
131
|
|
|
97
|
-
|
|
132
|
+
if ( chartRegistry ) {
|
|
133
|
+
log( chartRegistry )
|
|
134
|
+
} else {
|
|
135
|
+
process.exit( 1 )
|
|
136
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
- registry: us-docker.pkg.dev/leverege-registry
|
|
2
|
+
repositories:
|
|
3
|
+
stack:
|
|
4
|
+
- api-server
|
|
5
|
+
- authz-server
|
|
6
|
+
- db-curator
|
|
7
|
+
- emailer
|
|
8
|
+
- imagine
|
|
9
|
+
- message-processor
|
|
10
|
+
- messenger
|
|
11
|
+
- reason
|
|
12
|
+
- resource-server
|
|
13
|
+
- rule-enginer
|
|
14
|
+
- scheduler
|
|
15
|
+
- transponder-bq
|
|
16
|
+
- transponder-dh
|
|
17
|
+
- transponder-rt
|
|
18
|
+
- transponder-tsdb
|
|
19
|
+
leverege:
|
|
20
|
+
- pubsub-pulse
|
|
21
|
+
- pusher
|
|
22
|
+
- overdose
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import chalk from 'chalk'
|
|
4
|
+
import commandLineArgs from 'command-line-args'
|
|
5
|
+
import commandLineUsage from 'command-line-usage'
|
|
6
|
+
import { lt as semverLt } from 'semver'
|
|
7
|
+
|
|
8
|
+
import { log, shellCmd } from './Utils.mjs'
|
|
9
|
+
|
|
10
|
+
const commandLineOptions = [
|
|
11
|
+
{
|
|
12
|
+
name : 'help',
|
|
13
|
+
type : Boolean,
|
|
14
|
+
description : '{green display this help screen}',
|
|
15
|
+
},
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
const sections = [
|
|
19
|
+
{
|
|
20
|
+
header : 'Leverege Helm Chart Museum Pusher',
|
|
21
|
+
content : `{green This legacy tool acts as a simple method for assembling and storing a local
|
|
22
|
+
helm chart structure on the Leverege Chart Museum using Google Cloud Storage.
|
|
23
|
+
This approach is considered legacy since we have transitioned to using the
|
|
24
|
+
Google Artifact Registry for distributing helm charts.
|
|
25
|
+
}`
|
|
26
|
+
},
|
|
27
|
+
{ header : 'Options',
|
|
28
|
+
optionList : commandLineOptions,
|
|
29
|
+
},
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
const args = commandLineArgs( commandLineOptions, { camelCase : true, partial : true } )
|
|
33
|
+
const usage = commandLineUsage( sections )
|
|
34
|
+
|
|
35
|
+
if ( args.help ) {
|
|
36
|
+
log( usage )
|
|
37
|
+
process.exit( 0 )
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const pushItGood = async () => {
|
|
41
|
+
const version = await shellCmd( 'helm version --short' )
|
|
42
|
+
const pusher = ( semverLt( version, '3.7.0' ) ? 'push' : 'cm-push' )
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
const museum = await shellCmd( `helm ${pusher} helm leverege` )
|
|
46
|
+
log( chalk.green( museum ) )
|
|
47
|
+
} catch ( ex ) {
|
|
48
|
+
log( chalk.red( ex.stderr ) )
|
|
49
|
+
process.exit( 1 )
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
pushItGood()
|
|
@@ -14,10 +14,9 @@ import {
|
|
|
14
14
|
errorExit,
|
|
15
15
|
log,
|
|
16
16
|
warning,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
shellCmd } from './Utils.mjs'
|
|
17
|
+
analyzeRepository,
|
|
18
|
+
shellCmd,
|
|
19
|
+
} from './Utils.mjs'
|
|
21
20
|
|
|
22
21
|
const commandLineOptions = [ // Use commandLineOptions to tie into the Usage statements
|
|
23
22
|
{
|
|
@@ -55,8 +54,8 @@ const commandLineOptions = [ // Use commandLineOptions to tie into the Usage sta
|
|
|
55
54
|
const sections = [
|
|
56
55
|
{
|
|
57
56
|
header : 'Leverege Helm Chart to Artifact Registry',
|
|
58
|
-
content : `{green This tool
|
|
59
|
-
|
|
57
|
+
content : `{green This tool is responsible for pushing a helm chart to its designated GCP
|
|
58
|
+
Artifact Registry repository.}`
|
|
60
59
|
},
|
|
61
60
|
{ header : 'Options',
|
|
62
61
|
optionList : commandLineOptions,
|
|
@@ -79,34 +78,17 @@ if ( args._unknown ) {
|
|
|
79
78
|
}
|
|
80
79
|
/* eslint-enable no-underscore-dangle */
|
|
81
80
|
|
|
82
|
-
const minNodejsVersion = '
|
|
81
|
+
const minNodejsVersion = '22.0.0'
|
|
83
82
|
if ( semverLt( process.version, minNodejsVersion ) ) {
|
|
84
83
|
errorExit( `\n***ERROR: must be running at least node ${minNodejsVersion}\n` )
|
|
85
84
|
}
|
|
86
85
|
|
|
87
|
-
//
|
|
88
|
-
|
|
89
|
-
try {
|
|
90
|
-
gitRoot = await getGitRootDirectory()
|
|
91
|
-
} catch ( error ) {
|
|
92
|
-
errorExit( chalk.red.bold( error ), { errorCode : 5 } )
|
|
93
|
-
}
|
|
86
|
+
// load up all we need to know about the repo
|
|
87
|
+
const repoDescr = await analyzeRepository()
|
|
94
88
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
packageJson = await parsePackageJson( './package.json' )
|
|
99
|
-
} catch ( error ) {
|
|
100
|
-
errorExit( error )
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// And then load up the helm chart too
|
|
104
|
-
let helmChart
|
|
105
|
-
try {
|
|
106
|
-
helmChart = await parseHelmChart( `${gitRoot}/helm` )
|
|
107
|
-
} catch ( error ) {
|
|
108
|
-
errorExit( error )
|
|
109
|
-
}
|
|
89
|
+
const {
|
|
90
|
+
helmChart,
|
|
91
|
+
} = repoDescr
|
|
110
92
|
|
|
111
93
|
// helm push helm-package.tgz oci://REGISTRY_LOCATION/REGISTRY_PROJECT/REGISTRY_REPOSITORY/charts
|
|
112
94
|
//
|
|
@@ -116,7 +98,6 @@ const registryRepository = args.repository || helmChart.registryRepository
|
|
|
116
98
|
const ociPushEndpoint = `oci://${registryLocation}/${registryProject}/${registryRepository}/charts`
|
|
117
99
|
|
|
118
100
|
debug( {
|
|
119
|
-
packageJson,
|
|
120
101
|
helmChart,
|
|
121
102
|
registryLocation,
|
|
122
103
|
registryProject,
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
apiVersion: v1
|
|
2
|
+
kind: ServiceAccount
|
|
3
|
+
metadata:
|
|
4
|
+
name: cnpg-cleanup-sa
|
|
5
|
+
namespace: cnpg-operands
|
|
6
|
+
---
|
|
7
|
+
apiVersion: rbac.authorization.k8s.io/v1
|
|
8
|
+
kind: Role
|
|
9
|
+
metadata:
|
|
10
|
+
name: cnpg-cleanup-role
|
|
11
|
+
namespace: cnpg-operands
|
|
12
|
+
rules:
|
|
13
|
+
- apiGroups: ["postgresql.cnpg.io"]
|
|
14
|
+
resources: ["backups"]
|
|
15
|
+
verbs: ["get", "list", "delete"]
|
|
16
|
+
---
|
|
17
|
+
apiVersion: rbac.authorization.k8s.io/v1
|
|
18
|
+
kind: RoleBinding
|
|
19
|
+
metadata:
|
|
20
|
+
name: cnpg-cleanup-rolebinding
|
|
21
|
+
namespace: cnpg-operands
|
|
22
|
+
subjects:
|
|
23
|
+
- kind: ServiceAccount
|
|
24
|
+
name: cnpg-cleanup-sa
|
|
25
|
+
namespace: cnpg-operands
|
|
26
|
+
roleRef:
|
|
27
|
+
kind: Role
|
|
28
|
+
name: cnpg-cleanup-role
|
|
29
|
+
apiGroup: rbac.authorization.k8s.io
|
|
30
|
+
---
|
|
31
|
+
apiVersion: batch/v1
|
|
32
|
+
kind: CronJob
|
|
33
|
+
metadata:
|
|
34
|
+
name: cnpg-cleanup-snapshot
|
|
35
|
+
namespace: cnpg-operands
|
|
36
|
+
spec:
|
|
37
|
+
schedule: "0 13 * * *" # 13 UTC is ~8AM EST
|
|
38
|
+
successfulJobsHistoryLimit: 2
|
|
39
|
+
jobTemplate:
|
|
40
|
+
spec:
|
|
41
|
+
template:
|
|
42
|
+
spec:
|
|
43
|
+
serviceAccountName: cnpg-cleanup-sa
|
|
44
|
+
restartPolicy: Never
|
|
45
|
+
containers:
|
|
46
|
+
- name: cnpg-cleanup-snapshots
|
|
47
|
+
image: bitnami/kubectl:latest
|
|
48
|
+
command:
|
|
49
|
+
- "/bin/bash"
|
|
50
|
+
- "-c"
|
|
51
|
+
- |
|
|
52
|
+
echo "Starting CNPG Cleanup"
|
|
53
|
+
CURRENT_DATE=$(date +%s)
|
|
54
|
+
RETENTION_DAYS=21
|
|
55
|
+
SNAPSHOTS_JSON=$(kubectl get backups.postgresql.cnpg.io -n cnpg-operands -o json)
|
|
56
|
+
echo "$SNAPSHOTS_JSON" | jq -c '.items[]' | while read -r snapshot
|
|
57
|
+
do
|
|
58
|
+
NAME=$(echo "$snapshot" | jq -r '.metadata.name')
|
|
59
|
+
CREATION_TIMESTAMP=$(echo "$snapshot" | jq -r '.metadata.creationTimestamp')
|
|
60
|
+
if [[ "$NAME" != *"-backup-"* ]];
|
|
61
|
+
then
|
|
62
|
+
echo "Skipping manual snapshot: $NAME"
|
|
63
|
+
continue
|
|
64
|
+
fi
|
|
65
|
+
SNAPSHOT_DATE=$(date -d "$CREATION_TIMESTAMP" +%s)
|
|
66
|
+
AGE=$(( (CURRENT_DATE - SNAPSHOT_DATE) / 86400 ))
|
|
67
|
+
if [ "$AGE" -gt "$RETENTION_DAYS" ];
|
|
68
|
+
then
|
|
69
|
+
echo "Deleting snapshot: $NAME (Age: $AGE days)"
|
|
70
|
+
kubectl delete backups.postgresql.cnpg.io "$NAME" -n cnpg-operands 2> /dev/null
|
|
71
|
+
fi
|
|
72
|
+
done
|
|
73
|
+
echo "Cleanup complete."
|
|
@@ -4,7 +4,7 @@ showInstalling "The Prometheus Operator and Components"
|
|
|
4
4
|
addHelmRepo prometheus-community https://prometheus-community.github.io/helm-charts
|
|
5
5
|
|
|
6
6
|
showInstalling "The Prometheus Operator (kube-prometheus-stack)"
|
|
7
|
-
[ -z "$PROMETHEUS_STACK_CHART_VERSION" ] && PROMETHEUS_STACK_CHART_VERSION="
|
|
7
|
+
[ -z "$PROMETHEUS_STACK_CHART_VERSION" ] && PROMETHEUS_STACK_CHART_VERSION="69"
|
|
8
8
|
|
|
9
9
|
NS="--namespace prometheus"
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@ showInstalling "Redis"
|
|
|
4
4
|
|
|
5
5
|
OCI_CHART="oci://registry-1.docker.io/bitnamicharts/redis"
|
|
6
6
|
|
|
7
|
-
[ -z "$REDIS_CHART_VERSION" ] && REDIS_CHART_VERSION="20.
|
|
7
|
+
[ -z "$REDIS_CHART_VERSION" ] && REDIS_CHART_VERSION="20.7.1"
|
|
8
8
|
|
|
9
9
|
helm upgrade --install redis $OCI_CHART \
|
|
10
10
|
--values redis/redis-local.yaml \
|
|
@@ -17,10 +17,10 @@ TRAEFIK_NAMESPACE="traefik"
|
|
|
17
17
|
|
|
18
18
|
addHelmRepo traefik https://helm.traefik.io/traefik
|
|
19
19
|
|
|
20
|
-
[ -z "$TRAEFIK_CHART_VERSION" ] && TRAEFIK_CHART_VERSION="
|
|
20
|
+
[ -z "$TRAEFIK_CHART_VERSION" ] && TRAEFIK_CHART_VERSION="34"
|
|
21
21
|
helm upgrade --install traefik traefik/traefik \
|
|
22
22
|
--namespace $TRAEFIK_NAMESPACE --create-namespace \
|
|
23
|
-
--values traefik/
|
|
23
|
+
--values traefik/values.yaml \
|
|
24
24
|
--version $TRAEFIK_CHART_VERSION $HELM_WHAT
|
|
25
25
|
|
|
26
26
|
removeHelmRepo traefik
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
#
|
|
5
5
|
#service:
|
|
6
6
|
# spec:
|
|
7
|
-
# loadBalancerIP:
|
|
7
|
+
# loadBalancerIP: ${TRAEFIK_IP} # set in overwhelm.yaml
|
|
8
8
|
# single: true # true by default, set to false for UDP support
|
|
9
9
|
|
|
10
10
|
deployment:
|
|
@@ -24,6 +24,7 @@ resources:
|
|
|
24
24
|
cpu: "100m"
|
|
25
25
|
memory: "50Mi"
|
|
26
26
|
|
|
27
|
+
# enable this for prometheus operator scraping
|
|
27
28
|
metrics:
|
|
28
29
|
prometheus:
|
|
29
30
|
serviceMonitor:
|
|
@@ -31,6 +32,11 @@ metrics:
|
|
|
31
32
|
interval: 30s
|
|
32
33
|
namespace: prometheus
|
|
33
34
|
|
|
35
|
+
additionalArguments:
|
|
36
|
+
# this will enable the dashboard on port 8080 in v3 - https://doc.traefik.io/traefik/operations/api/
|
|
37
|
+
- "--api.insecure=true"
|
|
38
|
+
# - "--entrypoints.web.transport.respondingTimeouts.readTimeout=300"
|
|
39
|
+
|
|
34
40
|
# Custom entry points may be added here - the first two are port definitions
|
|
35
41
|
# for both unsecured and secured MQTT ports used by connect. Note that the
|
|
36
42
|
# mqtts port has TLS termination performed by traefik and both ports are then
|
package/src/helmup.sh
CHANGED
|
@@ -700,6 +700,36 @@ EOSNAPSC
|
|
|
700
700
|
sleep 2 # hold up processing for a moment to allow IAM mods to propagate
|
|
701
701
|
}
|
|
702
702
|
|
|
703
|
+
function installCronCnpgCleanupSnapshot() {
|
|
704
|
+
CNPG_OPERATOR_DIR="cnpg-operator"
|
|
705
|
+
if [ ! -d "$CNPG_OPERATOR_DIR" ];
|
|
706
|
+
then
|
|
707
|
+
cat<<CNPG_OPERATOR_MISSING
|
|
708
|
+
`color r "The cnpg-operator must be installed before proceeding"`
|
|
709
|
+
|
|
710
|
+
CNPG_OPERATOR_MISSING
|
|
711
|
+
exit 1
|
|
712
|
+
fi
|
|
713
|
+
|
|
714
|
+
CNPG_CLEANUP_CRONJOB_YAML="cnpg-cleanup-snapshot-cronjob.yaml"
|
|
715
|
+
CNPG_CLEANUP_CRONJOB="$CNPG_OPERATOR_DIR/$CNPG_CLEANUP_CRONJOB_YAML"
|
|
716
|
+
if [ ! -f "$CNPG_CLEANUP_CRONJOB" ];
|
|
717
|
+
then
|
|
718
|
+
cat<<CNPG_FETCH_CLEANUP_CRONJOB_YAML
|
|
719
|
+
`color y "Missing $CNPG_CLEANUP_CRONJOB_YAML - grabbing a copy from build-tools"`
|
|
720
|
+
|
|
721
|
+
CNPG_FETCH_CLEANUP_CRONJOB_YAML
|
|
722
|
+
CNPG_OP_ROOT="$(build-tools --reporoot)/src/helm-charts/cnpg-operator"
|
|
723
|
+
cp $CNPG_OP_ROOT/$CNPG_CLEANUP_CRONJOB_YAML $CNPG_CLEANUP_CRONJOB
|
|
724
|
+
fi
|
|
725
|
+
|
|
726
|
+
cat<<CNPG_CLEANUP_CRONJOB_APPLY
|
|
727
|
+
`color g "Creating cronjob =>"``color y " kubectl apply -f $CNPG_CLEANUP_CRONJOB"`
|
|
728
|
+
|
|
729
|
+
CNPG_CLEANUP_CRONJOB_APPLY
|
|
730
|
+
kubectl apply -f $CNPG_CLEANUP_CRONJOB
|
|
731
|
+
}
|
|
732
|
+
|
|
703
733
|
function ensureCnpgSecret() {
|
|
704
734
|
local mgrSecret=$1
|
|
705
735
|
local k8sSecret=$2
|
|
@@ -965,6 +995,11 @@ CATBACKUP
|
|
|
965
995
|
"cnpg-operator")
|
|
966
996
|
installCnpgOperatorEnvironment
|
|
967
997
|
bootstrapLocalSetup $SERVICE
|
|
998
|
+
installCronCnpgCleanupSnapshot
|
|
999
|
+
;;
|
|
1000
|
+
|
|
1001
|
+
"cnpg-cronjob")
|
|
1002
|
+
installCronCnpgCleanupSnapshot
|
|
968
1003
|
;;
|
|
969
1004
|
|
|
970
1005
|
"cronZombieKiller"|"zombie-killer")
|
|
@@ -247,11 +247,11 @@ export default class Config {
|
|
|
247
247
|
}
|
|
248
248
|
|
|
249
249
|
async runNpmScripts( runDirectories = [] ) {
|
|
250
|
-
for ( const runDirectory of runDirectories ) {
|
|
250
|
+
for ( const runDirectory of runDirectories ) {
|
|
251
251
|
const scripts = this.npmScripts
|
|
252
252
|
|
|
253
253
|
// for each script run sequentially
|
|
254
|
-
for ( const script of scripts ) {
|
|
254
|
+
for ( const script of scripts ) {
|
|
255
255
|
const cmd = `npm run ${script}`
|
|
256
256
|
log( `hook-and-release in ${chalk.green( runDirectory )} => ${chalk.green( cmd )}` )
|
|
257
257
|
if ( !this.cliArgs.debug ) {
|
package/src/pkgck.sh
CHANGED
|
@@ -85,9 +85,9 @@ check_git_version() {
|
|
|
85
85
|
printf "$clr$tag$C_off"
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
check_nodemon() {
|
|
89
|
-
nodemon="`getjson --file ./package.json --key nodemon`"
|
|
90
|
-
}
|
|
88
|
+
#check_nodemon() {
|
|
89
|
+
# nodemon="`getjson --file ./package.json --key nodemon`"
|
|
90
|
+
#}
|
|
91
91
|
|
|
92
92
|
check_scope() {
|
|
93
93
|
private="`node -p \"require('./package.json').private == true\"`"
|
package/src/push-my-chart.mjs
CHANGED
|
@@ -1,16 +1,62 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
import chalk from 'chalk'
|
|
4
|
+
import commandLineArgs from 'command-line-args'
|
|
5
|
+
import commandLineUsage from 'command-line-usage'
|
|
3
6
|
import { lt as semverLt } from 'semver'
|
|
4
7
|
|
|
5
|
-
import { log, shellCmd } from './Utils.mjs'
|
|
8
|
+
import { debug, log, shellCmd } from './Utils.mjs'
|
|
9
|
+
|
|
10
|
+
const commandLineOptions = [
|
|
11
|
+
{
|
|
12
|
+
name : 'no-registry',
|
|
13
|
+
type : Boolean,
|
|
14
|
+
defaultValue : false,
|
|
15
|
+
description : '{green push to the museum but not the artifact registry}',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name : 'help',
|
|
19
|
+
type : Boolean,
|
|
20
|
+
description : '{green display this help screen}',
|
|
21
|
+
},
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
const sections = [
|
|
25
|
+
{
|
|
26
|
+
header : 'Leverege Helm Chart Museum Pusher',
|
|
27
|
+
content : `{green This tool pushes Helm charts to both the legacy Chartmuseum (hosted on GCS)
|
|
28
|
+
and a Google Artifact Registry. It maintains compatibility with existing
|
|
29
|
+
Chartmuseum users while enabling a seamless transition to Artifact Registry
|
|
30
|
+
without disrupting current configurations.}`
|
|
31
|
+
},
|
|
32
|
+
{ header : 'Options',
|
|
33
|
+
optionList : commandLineOptions,
|
|
34
|
+
},
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
const args = commandLineArgs( commandLineOptions, { camelCase : true, partial : true } )
|
|
38
|
+
const usage = commandLineUsage( sections )
|
|
39
|
+
|
|
40
|
+
if ( args.help ) {
|
|
41
|
+
log( usage )
|
|
42
|
+
process.exit( 0 )
|
|
43
|
+
}
|
|
6
44
|
|
|
7
45
|
const pushItGood = async () => {
|
|
8
46
|
const version = await shellCmd( 'helm version --short' )
|
|
9
47
|
const pusher = ( semverLt( version, '3.7.0' ) ? 'push' : 'cm-push' )
|
|
10
48
|
|
|
11
49
|
try {
|
|
50
|
+
log( chalk.green( 'Pushing chart to the Chartmuseum\n' ) )
|
|
12
51
|
const museum = await shellCmd( `helm ${pusher} helm leverege` )
|
|
13
|
-
|
|
52
|
+
debug( { museum }, '<==output from helm push' )
|
|
53
|
+
if ( args.noRegistry ) {
|
|
54
|
+
log( `${chalk.bold.yellow( '\nskipping the chart push to the artifact registry' )}` )
|
|
55
|
+
} else {
|
|
56
|
+
log( chalk.green( 'Pushing chart to the Artifact Registry\n' ) )
|
|
57
|
+
const registry = await shellCmd( 'chart-to-registry' )
|
|
58
|
+
debug( { registry }, '<==chart-to-registry' )
|
|
59
|
+
}
|
|
14
60
|
} catch ( ex ) {
|
|
15
61
|
log( ex.stderr )
|
|
16
62
|
process.exit( 1 )
|
package/src/refresh-py-idx.sh
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
|
|
3
3
|
function leveregeBuildToolsRefreshPyIdx() {
|
|
4
|
+
# Execute gcloud command to get the token
|
|
5
|
+
local TOKEN=$(gcloud auth print-access-token)
|
|
6
|
+
|
|
4
7
|
# Write to pip.conf
|
|
5
8
|
local PIP_CONFIG_DIR="$HOME/.config/pip"
|
|
6
9
|
mkdir -p "$PIP_CONFIG_DIR"
|
|
7
10
|
local PIP_CONFIG_CONTENT="
|
|
8
11
|
[global]
|
|
9
|
-
extra-index-url = https://oauth2accesstoken@us-python.pkg.dev/leverege-registry/leverege-python-packages/simple/
|
|
12
|
+
extra-index-url = https://oauth2accesstoken:${TOKEN}@us-python.pkg.dev/leverege-registry/leverege-python-packages/simple/
|
|
10
13
|
"
|
|
11
14
|
echo "$PIP_CONFIG_CONTENT" > "$PIP_CONFIG_DIR/pip.conf"
|
|
12
15
|
echo "Updated ~/.config/pip/pip.conf"
|
|
@@ -26,7 +29,7 @@ function leveregeBuildToolsRefreshPyIdx() {
|
|
|
26
29
|
echo "Updated ~/.pypirc"
|
|
27
30
|
|
|
28
31
|
# Escape for sed
|
|
29
|
-
UV_EXTRA_INDEX_URL="https://oauth2accesstoken@us-python.pkg.dev/leverege-registry/leverege-python-packages/simple"
|
|
32
|
+
UV_EXTRA_INDEX_URL="https://oauth2accesstoken:${TOKEN}@us-python.pkg.dev/leverege-registry/leverege-python-packages/simple"
|
|
30
33
|
|
|
31
34
|
local SHELLS=("bash" "dash" "zsh" "fish")
|
|
32
35
|
|
package/.har/config.json
DELETED
package/.har/pre-commit
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
hook-and-release
|
package/.har/pre-push
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
hook-and-release
|
package/.publishrc
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"validations": {
|
|
3
|
-
"vulnerableDependencies": false,
|
|
4
|
-
"uncommittedChanges": true,
|
|
5
|
-
"untrackedFiles": true,
|
|
6
|
-
"branch": "development",
|
|
7
|
-
"gitTag": true,
|
|
8
|
-
"sensitiveData": false
|
|
9
|
-
},
|
|
10
|
-
"confirm": true,
|
|
11
|
-
"publishCommand": "npm publish",
|
|
12
|
-
"publishTag": "latest",
|
|
13
|
-
"prePublishScript": "npm run build",
|
|
14
|
-
"postPublishScript": false
|
|
15
|
-
}
|
|
@@ -1,611 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
if [ -z "$1" ]; then
|
|
3
|
-
echo " Usage: docker-to-registry <version number>"
|
|
4
|
-
exit 1
|
|
5
|
-
fi
|
|
6
|
-
|
|
7
|
-
# printf "\n****LOCAL DOCKREATE****\n\n" && sleep 1
|
|
8
|
-
|
|
9
|
-
# The base docker image maybe overridden with:
|
|
10
|
-
#
|
|
11
|
-
# BASE_NODE_IMAGE="gallium-alpine" npm run dockerize <version>
|
|
12
|
-
#
|
|
13
|
-
BASE_NODE_IMAGE="${BASE_NODE_IMAGE:-iron-alpine}" # node 20, iron
|
|
14
|
-
|
|
15
|
-
# Load common bash functions
|
|
16
|
-
. `build-tools --bashfun`
|
|
17
|
-
cat<<DEPRECATED_TOOL
|
|
18
|
-
|
|
19
|
-
`color y "***DEPRECATED docker-to-registry.sh - upgrade to docker-to-registry.mjs***"`
|
|
20
|
-
|
|
21
|
-
DEPRECATED_TOOL
|
|
22
|
-
exit 1
|
|
23
|
-
|
|
24
|
-
PKGTOP="$npm_config_local_prefix"
|
|
25
|
-
cd $PKGTOP/docker
|
|
26
|
-
|
|
27
|
-
if [ ! -x "$(command -v jq)" ];
|
|
28
|
-
then
|
|
29
|
-
cat<<NO_JQ
|
|
30
|
-
|
|
31
|
-
`color r "***ERROR: Missing jq JSON processor"` => `color g 'brew install jq'`
|
|
32
|
-
|
|
33
|
-
NO_JQ
|
|
34
|
-
exit 1
|
|
35
|
-
fi
|
|
36
|
-
|
|
37
|
-
if [ ! -d "$PKGTOP/dist" ];
|
|
38
|
-
then
|
|
39
|
-
cat<<NO_DIST
|
|
40
|
-
|
|
41
|
-
`color r "***ERROR: Missing the dist directory, run this first => "``color g 'npm run build'`
|
|
42
|
-
|
|
43
|
-
NO_DIST
|
|
44
|
-
exit 1
|
|
45
|
-
fi
|
|
46
|
-
|
|
47
|
-
function packageJson() {
|
|
48
|
-
result=$(jq -r $1 $PKGTOP/package.json)
|
|
49
|
-
if [ "$result" != "null" ]
|
|
50
|
-
then
|
|
51
|
-
echo $result
|
|
52
|
-
else
|
|
53
|
-
echo $2
|
|
54
|
-
fi
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
# Global Vars
|
|
58
|
-
pluginFile="Dockerfile.plugin"
|
|
59
|
-
|
|
60
|
-
# cleanup trapper for gracefully killing, which doesn't do much right now
|
|
61
|
-
function cleanup() {
|
|
62
|
-
[ ! -z "$DOCKER_SKIP_CLEANUP" ] && printf "\nSkipping clean up\n\n" && exit 1
|
|
63
|
-
printf "\nCleaning up and exiting...\n\n"
|
|
64
|
-
rm -rf ./workspace ./scripts $SSHDIR .npmrc
|
|
65
|
-
exit 0
|
|
66
|
-
}
|
|
67
|
-
trap cleanup INT
|
|
68
|
-
|
|
69
|
-
function strip_undefined() {
|
|
70
|
-
local result="$1"
|
|
71
|
-
[ "$1" == "undefined" ] && result=""
|
|
72
|
-
printf "$result"
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function create_DockerfilePlugin() {
|
|
76
|
-
[ -f 'Dockerfile.plugin' ] && return
|
|
77
|
-
|
|
78
|
-
cat<<DOCKERPLUGIN > Dockerfile.plugin
|
|
79
|
-
# Dockerfile.plugin - optionally extend the service Docker image
|
|
80
|
-
#
|
|
81
|
-
# This file may be used to run additional docker commands during the image
|
|
82
|
-
# build process without needing to maintain a local custom Dockerfile. For
|
|
83
|
-
# example, uncommenting the following docker RUN command will cause the
|
|
84
|
-
# curl and vim packages to be added to the deployed image thus making them
|
|
85
|
-
# available from the pod's command line on k8s:
|
|
86
|
-
#
|
|
87
|
-
# RUN apk update && apk add --no-cache curl vim
|
|
88
|
-
#
|
|
89
|
-
# Keep in mind that the Alpine Linux base image is used to keep image
|
|
90
|
-
# footprints small, so adding packages "just because" is not considered
|
|
91
|
-
# a best practice.
|
|
92
|
-
DOCKERPLUGIN
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
# Useful links with information regarding k8s/docker/nodejs and PID 1
|
|
96
|
-
# No PID 1 for NodeJS => https://bit.ly/2r4gHkZ
|
|
97
|
-
# What tini is all about => https://bit.ly/2HsSxqP
|
|
98
|
-
# Graceful kills with k8s => https://bit.ly/2NONEJG
|
|
99
|
-
#
|
|
100
|
-
# Params: $1 = version from dockerize invocation
|
|
101
|
-
# $2 = additional packages to install (htop redis-cli etc)
|
|
102
|
-
function create_Dockerfile() {
|
|
103
|
-
local regvers="${1}"
|
|
104
|
-
local apkadds="${2}"
|
|
105
|
-
|
|
106
|
-
create_DockerfilePlugin
|
|
107
|
-
|
|
108
|
-
echo "Creating the Dockerfile for node ${BASE_NODE_IMAGE}"
|
|
109
|
-
cat<<DOCKERBLD > Dockerfile
|
|
110
|
-
# Version ${regvers} @ `date`
|
|
111
|
-
#
|
|
112
|
-
# The FROM directive sets the Base Image for subsequent instructions
|
|
113
|
-
FROM node:${BASE_NODE_IMAGE} as intermediate
|
|
114
|
-
ENV NODE_ENV production
|
|
115
|
-
|
|
116
|
-
RUN mkdir -p /usr/src/app
|
|
117
|
-
WORKDIR /usr/src/app
|
|
118
|
-
|
|
119
|
-
# Install app dependencies
|
|
120
|
-
COPY ./workspace/ /usr/src/app/
|
|
121
|
-
ENV GRPC_VERBOSITY ERROR
|
|
122
|
-
|
|
123
|
-
# --------------------------------------------------------------
|
|
124
|
-
# copy the ssh keys into place, npm install, and remove them
|
|
125
|
-
# --------------------------------------------------------------
|
|
126
|
-
|
|
127
|
-
# Install packages to install private repos with ssh keys
|
|
128
|
-
COPY ./.npmrc /usr/src/app/.npmrc
|
|
129
|
-
RUN apk --no-cache add openssh-client && \
|
|
130
|
-
apk --update add --no-cache --virtual build-dep g++ gcc libgcc \\
|
|
131
|
-
libstdc++ linux-headers make ${apkadds} && \
|
|
132
|
-
npm install -g npm@10 && \
|
|
133
|
-
npm ci --only=production --ignore-scripts --no-optional ${npmlogging} && \
|
|
134
|
-
rm -f /usr/src/app/.npmrc /root/.ssh/*
|
|
135
|
-
|
|
136
|
-
# --------------------------------------------------------------
|
|
137
|
-
# On to the real build now, the thing before was just an intermediate container
|
|
138
|
-
# --------------------------------------------------------------
|
|
139
|
-
|
|
140
|
-
FROM node:${BASE_NODE_IMAGE}
|
|
141
|
-
|
|
142
|
-
# Install tini for PID 1 and replace shell with bash so we can source files
|
|
143
|
-
RUN apk update && \
|
|
144
|
-
apk add --no-cache bash curl tini vim ${apkadds} && \
|
|
145
|
-
npm install -g npm@10 && \
|
|
146
|
-
rm /bin/sh && ln -s /bin/bash /bin/sh && \
|
|
147
|
-
mkdir -p /usr/src/app /tmp/levlog && \
|
|
148
|
-
chown node:node /usr/src/app
|
|
149
|
-
DOCKERBLD
|
|
150
|
-
|
|
151
|
-
if [ -f "${pluginFile}" ];
|
|
152
|
-
then
|
|
153
|
-
printf "\n# ${pluginFile} BEGIN\n" >> Dockerfile
|
|
154
|
-
cat $pluginFile >> Dockerfile
|
|
155
|
-
printf "# ${pluginFile} END\n\n" >> Dockerfile
|
|
156
|
-
fi
|
|
157
|
-
|
|
158
|
-
cat<<EODOCKER >> Dockerfile
|
|
159
|
-
ENTRYPOINT [ "/sbin/tini", "--" ]
|
|
160
|
-
WORKDIR /usr/src/app
|
|
161
|
-
|
|
162
|
-
COPY --chown=node:node --from=intermediate /usr/src/app /usr/src/app
|
|
163
|
-
|
|
164
|
-
USER ${runuser}
|
|
165
|
-
COPY ./bashrc /home/node/.bashrc
|
|
166
|
-
CMD [ "/bin/bash", "-c", "node index.js" ]
|
|
167
|
-
EODOCKER
|
|
168
|
-
} # end of create_Dockerfile
|
|
169
|
-
|
|
170
|
-
# Params: $1 = version from dockerize invocation
|
|
171
|
-
function create_bashrc() {
|
|
172
|
-
cat<<EOBASHRC > bashrc
|
|
173
|
-
#!/bin/bash
|
|
174
|
-
#
|
|
175
|
-
# Version $1 @ `date`
|
|
176
|
-
|
|
177
|
-
alias h=history
|
|
178
|
-
|
|
179
|
-
alias ls='ls -CF --color=auto'
|
|
180
|
-
alias ll='ls -lh'
|
|
181
|
-
alias lla='ls -lha'
|
|
182
|
-
alias glep='grep -l -s'
|
|
183
|
-
alias m=less
|
|
184
|
-
alias menv='env | sort | less'
|
|
185
|
-
|
|
186
|
-
alias whatsmyip='wget -qO- ifconfig.co'
|
|
187
|
-
|
|
188
|
-
alias err='wget -q -O- localhost:5111/logLevel/error'
|
|
189
|
-
alias wrn='wget -q -O- localhost:5111/logLevel/warn'
|
|
190
|
-
alias inf='wget -q -O- localhost:5111/logLevel/info'
|
|
191
|
-
alias dbg='wget -q -O- localhost:5111/logLevel/debug'
|
|
192
|
-
alias trc='wget -q -O- localhost:5111/logLevel/trace'
|
|
193
|
-
|
|
194
|
-
socks()
|
|
195
|
-
{
|
|
196
|
-
netstat -ant | awk '{print $6}' | sort | uniq -c | sort -n
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
cmetrics()
|
|
200
|
-
{
|
|
201
|
-
wget -qO- localhost:5111/metrics
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
cmstat()
|
|
205
|
-
{
|
|
206
|
-
wget -qO- localhost:5111\${1}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
cmclear()
|
|
210
|
-
{
|
|
211
|
-
cmstat /status/clear
|
|
212
|
-
}
|
|
213
|
-
EOBASHRC
|
|
214
|
-
} # end of create_bashrc
|
|
215
|
-
|
|
216
|
-
# Spilt a character delimited string and emit the object at the specified
|
|
217
|
-
# index. So passing a full registry string in like:
|
|
218
|
-
# us-docker.pkg.dev/leverege-registry/leverege
|
|
219
|
-
#
|
|
220
|
-
# the project name may be extracted by calling this like:
|
|
221
|
-
# getNthOvjectFromDelimitedString $registry 1 '/'
|
|
222
|
-
#
|
|
223
|
-
function getNthObjectFromDelimitedString() {
|
|
224
|
-
local inputStr=$1
|
|
225
|
-
local index=$2
|
|
226
|
-
local delimeter=$3
|
|
227
|
-
|
|
228
|
-
IFS=$delimeter
|
|
229
|
-
read -ra ADDR <<< "$inputStr"
|
|
230
|
-
|
|
231
|
-
echo ${ADDR[$index]}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
# ---------- MAIN PROCESSING STARTS HERE ----------
|
|
235
|
-
#
|
|
236
|
-
# make sure we have a current npmrc file
|
|
237
|
-
refresh-npm-token
|
|
238
|
-
|
|
239
|
-
# deprecation checks first...
|
|
240
|
-
deprecated=$(packageJson '.leverege.project')
|
|
241
|
-
if [ ! -z "$deprecated" ];
|
|
242
|
-
then
|
|
243
|
-
cat<<DEPRECATED_PROJECT
|
|
244
|
-
|
|
245
|
-
$(color y '***DEPRECATED: leverege.project setting in package.json')
|
|
246
|
-
|
|
247
|
-
Setting the project in the package.json leverege section was used for builds
|
|
248
|
-
being stored in the deprecated GCP container registry. Remove the deprecated
|
|
249
|
-
leverege.project setting from package.json and try again.
|
|
250
|
-
|
|
251
|
-
"leverege": {
|
|
252
|
-
$(color r "\"project\": \"$deprecated\",")
|
|
253
|
-
...
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
DEPRECATED_PROJECT
|
|
257
|
-
exit 1
|
|
258
|
-
fi
|
|
259
|
-
|
|
260
|
-
deprecated=$(packageJson '.leverege.container')
|
|
261
|
-
if [ ! -z "$deprecated" ];
|
|
262
|
-
then
|
|
263
|
-
cat<<DEPRECATED_CONTAINER
|
|
264
|
-
|
|
265
|
-
$(color y '***DEPRECATED: leverege.container is no longer supported')
|
|
266
|
-
|
|
267
|
-
Setting the container name explicitly from the package.json leverge block
|
|
268
|
-
is no longer supported. The container name will be automatically derived
|
|
269
|
-
from the git repository's remote root, which is the default behavior. Remove
|
|
270
|
-
the container line from the leverege section in package.json and try again.
|
|
271
|
-
|
|
272
|
-
"leverege": {
|
|
273
|
-
$(color r "\"container\": \"$deprecated\",")
|
|
274
|
-
...
|
|
275
|
-
}
|
|
276
|
-
DEPRECATED_CONTAINER
|
|
277
|
-
exit 1
|
|
278
|
-
fi
|
|
279
|
-
|
|
280
|
-
deprecated=$(packageJson '.leverege.nodeimg')
|
|
281
|
-
if [ ! -z "$deprecated" ];
|
|
282
|
-
then
|
|
283
|
-
cat<<DEPRECATED_NODEIMAGE
|
|
284
|
-
|
|
285
|
-
$(color y '***DEPRECATED: leverege.nodeimg is no longer supported')
|
|
286
|
-
|
|
287
|
-
Setting the node base image using the nodeimg statement in package.json is no
|
|
288
|
-
longer supported. By default the actual node image version will be defaulted
|
|
289
|
-
by this script and wil rarely need to be a specific version. Remove the
|
|
290
|
-
nodeimg line from the leverege section in package.json and try again.
|
|
291
|
-
|
|
292
|
-
"leverege": {
|
|
293
|
-
$(color r "\"nodeimg\": \"$deprecated\",")
|
|
294
|
-
...
|
|
295
|
-
}
|
|
296
|
-
DEPRECATED_NODEIMAGE
|
|
297
|
-
exit 1
|
|
298
|
-
fi
|
|
299
|
-
|
|
300
|
-
deprecated=$(packageJson '.leverege.artifact')
|
|
301
|
-
if [ ! -z "$deprecated" ];
|
|
302
|
-
then
|
|
303
|
-
cat<<DEPRECATED_ARTIFACT
|
|
304
|
-
|
|
305
|
-
$(color y '***DEPRECATED: leverege.artifact is no longer supported')
|
|
306
|
-
|
|
307
|
-
Setting the artifact registry folder is no longer supported. Instead use the
|
|
308
|
-
$(color g leverege.registry) setting to specify the full artifact registry and folder
|
|
309
|
-
used for storing the docker image. Remove the artifact line from the leverege
|
|
310
|
-
section in package.json and try again.
|
|
311
|
-
|
|
312
|
-
"leverege": {
|
|
313
|
-
$(color r "\"artifact\": \"$deprecated\",")
|
|
314
|
-
...
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
$(color g "New syntax example:")
|
|
318
|
-
|
|
319
|
-
"leverege": {
|
|
320
|
-
$(color g "\"registry\": \"us-docker.pkg.dev/leverege-registry/$deprecated\",")
|
|
321
|
-
}
|
|
322
|
-
DEPRECATED_ARTIFACT
|
|
323
|
-
exit 1
|
|
324
|
-
fi
|
|
325
|
-
|
|
326
|
-
deprecated=$(packageJson '.leverege.nodeops')
|
|
327
|
-
if [ ! -z "$deprecated" ];
|
|
328
|
-
then
|
|
329
|
-
cat<<DEPRECATED_NODEOPS
|
|
330
|
-
|
|
331
|
-
$(color y '***DEPRECATED: leverege.nodeops are no longer supported')
|
|
332
|
-
|
|
333
|
-
Setting the hard coded node options on the image is no longer supported. The
|
|
334
|
-
better approach is to add $(color g 'NODE_OPTIONS') to the config section of the chart's
|
|
335
|
-
values.yaml to allow downstream users to easily tune the options as needed.
|
|
336
|
-
Remove the nodeops line from the leverege section in package.json and try again.
|
|
337
|
-
|
|
338
|
-
"leverege": {
|
|
339
|
-
$(color r "\"nodeops\": \"$deprecated\",")
|
|
340
|
-
...
|
|
341
|
-
}
|
|
342
|
-
DEPRECATED_NODEOPS
|
|
343
|
-
exit 1
|
|
344
|
-
fi
|
|
345
|
-
|
|
346
|
-
# the container name will be the git root for the repo
|
|
347
|
-
gitremote=`git config --get remote.origin.url`
|
|
348
|
-
if [ -z $gitremote ];
|
|
349
|
-
then
|
|
350
|
-
cat<<NOCONTAINER
|
|
351
|
-
|
|
352
|
-
$(color r '***ERROR: attempting to build an unnamed container')
|
|
353
|
-
|
|
354
|
-
You are attempting to create a docker image without a container name or
|
|
355
|
-
a git remote setup. Either define a $(color y 'container') statement in the leverege
|
|
356
|
-
section of package.json, or add a $(color g 'git remote') to this repository.
|
|
357
|
-
|
|
358
|
-
NOCONTAINER
|
|
359
|
-
exit 1
|
|
360
|
-
fi
|
|
361
|
-
container=$(basename $gitremote .git)
|
|
362
|
-
|
|
363
|
-
# build the registry specification
|
|
364
|
-
registry=$(packageJson '.leverege.registry')
|
|
365
|
-
if [ ! -z "$registry" ];
|
|
366
|
-
then
|
|
367
|
-
gcp_project="$(getNthObjectFromDelimitedString $registry 1 '/')"
|
|
368
|
-
registry_folder=$registry/images/$container
|
|
369
|
-
else
|
|
370
|
-
cat<<MISSING_REGISTRY
|
|
371
|
-
|
|
372
|
-
$(color r '***ERROR: the leverege.registry setting is required in package.json')
|
|
373
|
-
|
|
374
|
-
The $(color g 'leverege.registry') setting is now required and must be set to point to the
|
|
375
|
-
base URL of the artifact registry, plus the folder that the image is to be
|
|
376
|
-
stored in. For example, the Leverege Google project that contains our artifact
|
|
377
|
-
registry is $(color g 'leverege-registry') which contains several folders that are used to
|
|
378
|
-
group images by commonality. The stack services store their images in the
|
|
379
|
-
$(color g 'stack') folder, while general purpose services that we use may end up in the
|
|
380
|
-
$(color g 'leverege') folder.
|
|
381
|
-
|
|
382
|
-
Using api-server as an example, given this setting in api-server's package.json:
|
|
383
|
-
|
|
384
|
-
"leverege": {
|
|
385
|
-
$(color g '"registry": "us-docker.pkg.dev/leverege-registry/stack"')
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
the resultant docker image gets stored in:
|
|
389
|
-
|
|
390
|
-
$(color g 'us-docker.pkg.dev/leverege-registry/stack/images/api-server')
|
|
391
|
-
|
|
392
|
-
The helm/values.yaml file would then reference the same location:
|
|
393
|
-
|
|
394
|
-
image:
|
|
395
|
-
pullPolicy: IfNotPresent
|
|
396
|
-
registry: $(color g 'us-docker.pkg.dev/leverege-registry/leverege/images')
|
|
397
|
-
tag: ""
|
|
398
|
-
MISSING_REGISTRY
|
|
399
|
-
exit 1
|
|
400
|
-
fi
|
|
401
|
-
|
|
402
|
-
# verify the cloud build bucket exists
|
|
403
|
-
#
|
|
404
|
-
build_bucket="gs://${gcp_project}_cloudbuild"
|
|
405
|
-
gsutil ls -p $gcp_project -b $build_bucket &> /dev/null
|
|
406
|
-
if [ "$?" -ne 0 ];
|
|
407
|
-
then
|
|
408
|
-
cat<<MISSING_BUILD_BUCKET
|
|
409
|
-
|
|
410
|
-
$(color r "***ERROR: missing the cloud build bucket $build_bucket")
|
|
411
|
-
|
|
412
|
-
Go to Cloud Storage on the $(color g $gcp_project) GCP project and create the
|
|
413
|
-
target cloud build bucket before proceeding.
|
|
414
|
-
|
|
415
|
-
Build bucket => $(color g $build_bucket)
|
|
416
|
-
MISSING_BUILD_BUCKET
|
|
417
|
-
exit 1
|
|
418
|
-
fi
|
|
419
|
-
|
|
420
|
-
version=$1
|
|
421
|
-
[[ -f '.previous' ]] && previous=`cat .previous` || previous='FIRST BUILD'
|
|
422
|
-
#pckgver="v`node -p \"require('../package.json').version\"`"
|
|
423
|
-
pckgver="v$(packageJson '.version')"
|
|
424
|
-
pckgdts="`date +\"%Y%m%d-%H%M\"`"
|
|
425
|
-
# egrep was deprecated in 2007!
|
|
426
|
-
tagging=`echo $version | egrep -e "^v\d+\.\d+\.\d+$"`
|
|
427
|
-
|
|
428
|
-
if [ $tagging ];
|
|
429
|
-
then
|
|
430
|
-
if [[ `git status --porcelain` ]]; then
|
|
431
|
-
cat<<DIRTAG
|
|
432
|
-
|
|
433
|
-
$(color r '***ERROR: attempting to tag a non-beta dirty git repository')
|
|
434
|
-
|
|
435
|
-
You are attempting to create a tagged release image for pushing to the
|
|
436
|
-
container registry, but there are locally modified files. This is not
|
|
437
|
-
allowed since the applied tag will not be relevant to the image version
|
|
438
|
-
due to the pending commits.
|
|
439
|
-
|
|
440
|
-
Available options for proceeding:
|
|
441
|
-
|
|
442
|
-
$(color g '1) cleanly commit all local mods assuming relevance')
|
|
443
|
-
$(color y '2) eliminate unwanted local modifications')
|
|
444
|
-
$(color r '3) stash anything that is irrelevant to this release')
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
DIRTAG
|
|
448
|
-
exit 1
|
|
449
|
-
fi
|
|
450
|
-
|
|
451
|
-
# since we're tagging, the current branch must have an upstream
|
|
452
|
-
branch=`git rev-parse --abbrev-ref HEAD`
|
|
453
|
-
git rev-parse --abbrev-ref ${branch}@{u} &> /dev/null
|
|
454
|
-
|
|
455
|
-
if [ $? -ne 0 ];
|
|
456
|
-
then
|
|
457
|
-
cat<<NOUPSTR
|
|
458
|
-
|
|
459
|
-
$(color r '***ERROR: the current branch must have an upstream')
|
|
460
|
-
|
|
461
|
-
You are attempting to create a tagged release image for pushing to the
|
|
462
|
-
container registry, but the current branch does not have an upstream to
|
|
463
|
-
push to. This is not allowed since the applied tag will be stranded here
|
|
464
|
-
in your local repository, which is what we are attempting to avoid.
|
|
465
|
-
|
|
466
|
-
Available options for proceeding:
|
|
467
|
-
|
|
468
|
-
$(color g '1) set an upstream for this branch via:')
|
|
469
|
-
$(color g " git push --set-upstream origin ${branch}")
|
|
470
|
-
|
|
471
|
-
$(color y '2) rebase, squash and merge onto a branch with an upstream')
|
|
472
|
-
|
|
473
|
-
NOUPSTR
|
|
474
|
-
exit 1
|
|
475
|
-
fi
|
|
476
|
-
|
|
477
|
-
tagstat=$(color y 'will be tagged')
|
|
478
|
-
else
|
|
479
|
-
tagstat=$(color r 'BETA RELEASE WILL NOT BE TAGGED')
|
|
480
|
-
fi
|
|
481
|
-
|
|
482
|
-
pluggedIn=$(color g "no")
|
|
483
|
-
[ -f "${pluginFile}" ] && pluggedIn=$(color y "YES")
|
|
484
|
-
|
|
485
|
-
apkadds=$(packageJson '.leverege.apkadds')
|
|
486
|
-
runuser=$(packageJson '.leverege.runuser')
|
|
487
|
-
[ -z "${runuser}" ] && runuser='node'
|
|
488
|
-
|
|
489
|
-
npmlogging='--silent' # allow for verbose npm logs
|
|
490
|
-
if [ "$VERBOSE_DOCKREATE_NPM" == "yes" ];
|
|
491
|
-
then
|
|
492
|
-
npmlogging='--ddd'
|
|
493
|
-
else
|
|
494
|
-
hintverbose=1
|
|
495
|
-
fi
|
|
496
|
-
|
|
497
|
-
echo "Updating dependencies and workspace..." && npm install
|
|
498
|
-
if [ $? -ne 0 ];
|
|
499
|
-
then
|
|
500
|
-
cat<<INSTALLFAILED
|
|
501
|
-
|
|
502
|
-
$(color y 'npm install') $(color r 'FAILED') - fix it in order to proceed
|
|
503
|
-
|
|
504
|
-
INSTALLFAILED
|
|
505
|
-
exit 1
|
|
506
|
-
fi
|
|
507
|
-
|
|
508
|
-
cat<<IMGINFO
|
|
509
|
-
Project: $(color g $gcp_project)
|
|
510
|
-
Registry: $(color g $registry)
|
|
511
|
-
Container: $(color g $container)
|
|
512
|
-
Version: $(color g $version) $tagstat
|
|
513
|
-
Folder: $(color y $registry_folder)
|
|
514
|
-
NodeImage: $(color g $BASE_NODE_IMAGE)
|
|
515
|
-
AddedPkgs: $(color g $apkadds)
|
|
516
|
-
PluggedIn: ${pluggedIn}
|
|
517
|
-
Run User: $(color g $runuser)
|
|
518
|
-
Previous: $(color y $previous)
|
|
519
|
-
DateStamp: $(color g $pckgdts)
|
|
520
|
-
NPM Logs: $(color g $npmlogging)
|
|
521
|
-
|
|
522
|
-
IMGINFO
|
|
523
|
-
|
|
524
|
-
[ $hintverbose ] && printf " Define $(color g VERBOSE_DOCKREATE_NPM=\"yes\") for verbose build logging\n\n"
|
|
525
|
-
|
|
526
|
-
if [ "$pckgver" != "$version" ];
|
|
527
|
-
then
|
|
528
|
-
cat<<EOPKG
|
|
529
|
-
$(color y '***WARNING: specified version does not match package.json version' )
|
|
530
|
-
package.json => $(color g "$pckgver")
|
|
531
|
-
specified => $(color r "$version")
|
|
532
|
-
|
|
533
|
-
EOPKG
|
|
534
|
-
if [ $tagging ];
|
|
535
|
-
then
|
|
536
|
-
cat<<EONOPE
|
|
537
|
-
|
|
538
|
-
$(color r '... and you are attempting to release so NOPE!' )
|
|
539
|
-
|
|
540
|
-
EONOPE
|
|
541
|
-
exit 1
|
|
542
|
-
fi
|
|
543
|
-
fi
|
|
544
|
-
|
|
545
|
-
create_Dockerfile "$version" "$apkadds"
|
|
546
|
-
create_bashrc "$version"
|
|
547
|
-
|
|
548
|
-
rm -rf ./workspace && mkdir -p ./workspace
|
|
549
|
-
cp -rfp ${PKGTOP}/package*json ${PKGTOP}/dist/* ./workspace
|
|
550
|
-
|
|
551
|
-
# grab the npmrc token for the image
|
|
552
|
-
cp -f "$HOME/.npmrc" .npmrc
|
|
553
|
-
|
|
554
|
-
[ "$CIRCLECI" == "true" ] && exit 0
|
|
555
|
-
|
|
556
|
-
printf "Hit return to continue or ^C to exit\n\n"; read ANS
|
|
557
|
-
|
|
558
|
-
echo $version > .previous
|
|
559
|
-
|
|
560
|
-
echo "Changing Google Project to $project"
|
|
561
|
-
gcloud config set project $gcp_project
|
|
562
|
-
|
|
563
|
-
echo "Creating Docker Image for $registry_folder:$version"
|
|
564
|
-
echo " Building the workspace"
|
|
565
|
-
|
|
566
|
-
# use kaniko to cache builds
|
|
567
|
-
if [ "$USE_KANIKO" == "yes" ];
|
|
568
|
-
then
|
|
569
|
-
gcloud config set builds/use_kaniko True
|
|
570
|
-
else
|
|
571
|
-
gcloud config unset builds/use_kaniko
|
|
572
|
-
fi
|
|
573
|
-
|
|
574
|
-
# need a logging area outside of the default cloud build bucket in order
|
|
575
|
-
# to enable 3rd party builders from outside of leverege.com user space
|
|
576
|
-
build_logs="--gcs-log-dir $build_bucket/logs"
|
|
577
|
-
|
|
578
|
-
# submit the build request to gcloud with logs directed to the cloudbuild
|
|
579
|
-
# logging bucket from the docker directory
|
|
580
|
-
time gcloud builds submit $build_logs --tag $registry_folder:$version .
|
|
581
|
-
|
|
582
|
-
if [ $? -ne 0 ];
|
|
583
|
-
then
|
|
584
|
-
bldErr=$?
|
|
585
|
-
cat<<BUILDERR
|
|
586
|
-
|
|
587
|
-
$(color r '***ERROR: build failed! Aborting without tagging.')
|
|
588
|
-
|
|
589
|
-
The gcloud build process seems to have run into a problem. Please fix the
|
|
590
|
-
issue and rerun the dockerize process. This build will not be tagged, nor
|
|
591
|
-
will it be pushed.
|
|
592
|
-
|
|
593
|
-
BUILDERR
|
|
594
|
-
exit $bldErr
|
|
595
|
-
fi
|
|
596
|
-
|
|
597
|
-
# Tag the container with the node detailsand the culprit.
|
|
598
|
-
gcloud container images add-tag --quiet $registry_folder:$version \
|
|
599
|
-
$registry_folder:$pckgdts-$BASE_NODE_IMAGE-$USER \
|
|
600
|
-
$registry_folder:latest
|
|
601
|
-
|
|
602
|
-
if [ $tagging ];
|
|
603
|
-
then
|
|
604
|
-
printf "\n$(color g "Tagging and Pushing $version")\n"
|
|
605
|
-
git tag -af $1 -m "Docker version $1"
|
|
606
|
-
git push --follow-tags
|
|
607
|
-
else
|
|
608
|
-
printf "\n$(color y '*** Skipped git tagging - beta release')\n\n"
|
|
609
|
-
fi
|
|
610
|
-
|
|
611
|
-
cleanup
|
|
File without changes
|