@leverege/build-tools 2.83.5 → 2.84.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 +2 -2
- package/src/Utils.mjs +2 -2
- package/src/chart-to-registry.mjs +10 -8
- package/src/custom-images/{bitnami-audit.mjs → bitnami-audits/bitnami-audit.mjs} +1 -1
- package/src/custom-images/kubectl/build-kubetcl.sh +3 -1
- package/src/custom-images/pg_repack/README.md +15 -1
- package/src/custom-images/pg_repack/charts/push-charts.sh +3 -0
- package/src/custom-images/pg_repack/charts/repack-cron/Chart.yaml +7 -0
- package/src/custom-images/pg_repack/charts/{repack → repack-cron}/templates/_helpers.tpl +5 -15
- package/src/custom-images/pg_repack/charts/{repack → repack-cron}/templates/configmap.yaml +1 -1
- package/src/custom-images/pg_repack/charts/repack-cron/templates/cronjob.yaml +54 -0
- package/src/custom-images/pg_repack/charts/repack-cron/values.yaml +33 -0
- package/src/custom-images/pg_repack/{Dockerfile → docker/Dockerfile} +5 -2
- package/src/custom-images/pg_repack/{build-repack-kubectl.sh → docker/build-repack-kubectl.sh} +1 -1
- package/src/helm-charts/pg-repack/helmup.plugin +11 -0
- package/src/helm-charts/pg-repack/values-local.yaml +16 -0
- package/src/helm-charts/prom-operator/prometheus-stack.yaml.ovh +1 -1
- package/src/helm-charts/prom-operator/rules/kubestate-rules.yaml +1 -1
- package/src/push-my-chart.mjs +8 -2
- package/src/custom-images/pg_repack/charts/repack/Chart.yaml +0 -5
- package/src/custom-images/pg_repack/charts/repack/templates/cronjob.yaml +0 -33
- package/src/custom-images/pg_repack/charts/repack/templates/secret.yaml +0 -8
- package/src/custom-images/pg_repack/charts/repack/values.yaml +0 -23
- package/src/custom-images/pg_repack/deploy.sh +0 -3
- /package/src/custom-images/{bitnami-to-leverege-artifacts.sh → bitnami-audits/bitnami-to-leverege-artifacts.sh} +0 -0
- /package/src/custom-images/pg_repack/charts/{repack → repack-cron}/templates/rbac.yaml +0 -0
- /package/src/custom-images/pg_repack/charts/{repack → repack-cron}/templates/serviceaccount.yaml +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leverege/build-tools",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.84.0",
|
|
4
4
|
"description": "A collection of build / support tools for Leverege developers",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"@leverege/jsdoc-template": "^1.0.1",
|
|
68
|
-
"chalk": "^5.6.
|
|
68
|
+
"chalk": "^5.6.2",
|
|
69
69
|
"command-line-args": "^6.0.1",
|
|
70
70
|
"command-line-usage": "^7.0.3",
|
|
71
71
|
"commander": "^14.0.0",
|
package/src/Utils.mjs
CHANGED
|
@@ -134,10 +134,10 @@ export const getDateTimestamp = () => {
|
|
|
134
134
|
return `${fullDTS.slice( 0, 8 )}-${fullDTS.slice( 8, 12 )}`
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
export const getCleanTag = (str) => {
|
|
137
|
+
export const getCleanTag = ( str ) => {
|
|
138
138
|
// Sanitize string to only include characters allowed in GCP Artifact Registry image tags
|
|
139
139
|
// Allowed characters: abcdefghijklmnopqrstuvwxyz0123456789_-./
|
|
140
|
-
return str.replace(/[^a-zA-Z0-9_
|
|
140
|
+
return str.replace( /[^a-zA-Z0-9_\-./]/g, '' )
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
export const getGcpAccount = async () => {
|
|
@@ -14,11 +14,17 @@ import {
|
|
|
14
14
|
errorExit,
|
|
15
15
|
log,
|
|
16
16
|
warning,
|
|
17
|
-
|
|
17
|
+
parseHelmChart,
|
|
18
18
|
shellCmd,
|
|
19
19
|
} from './Utils.mjs'
|
|
20
20
|
|
|
21
21
|
const commandLineOptions = [ // Use commandLineOptions to tie into the Usage statements
|
|
22
|
+
{
|
|
23
|
+
name : 'chart',
|
|
24
|
+
type : String,
|
|
25
|
+
defaultValue : 'helm',
|
|
26
|
+
description : '{green directory containing the chart - default: helm}',
|
|
27
|
+
},
|
|
22
28
|
{
|
|
23
29
|
name : 'location',
|
|
24
30
|
type : String,
|
|
@@ -83,12 +89,8 @@ if ( semverLt( process.version, minNodejsVersion ) ) {
|
|
|
83
89
|
errorExit( `\n***ERROR: must be running at least node ${minNodejsVersion}\n` )
|
|
84
90
|
}
|
|
85
91
|
|
|
86
|
-
// load up all we need to know about the
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
const {
|
|
90
|
-
helmChart,
|
|
91
|
-
} = repoDescr
|
|
92
|
+
// load up all we need to know about the chart
|
|
93
|
+
const helmChart = await parseHelmChart( args.chart )
|
|
92
94
|
|
|
93
95
|
// helm push helm-package.tgz oci://REGISTRY_LOCATION/REGISTRY_PROJECT/REGISTRY_REPOSITORY/charts
|
|
94
96
|
//
|
|
@@ -133,7 +135,7 @@ try {
|
|
|
133
135
|
}
|
|
134
136
|
|
|
135
137
|
try {
|
|
136
|
-
await shellCmd(
|
|
138
|
+
await shellCmd( `helm package ${args.chart}` )
|
|
137
139
|
if ( !existsSync( chartPackage ) ) { // eslint-disable-line security/detect-non-literal-fs-filename
|
|
138
140
|
errorExit( `Error: expected helm package to produce ${chartPackage}` )
|
|
139
141
|
}
|
|
@@ -3,4 +3,18 @@
|
|
|
3
3
|
This configuration is needed for providing repack capabilities for legacy
|
|
4
4
|
postgresql 11 systems. Specifically, rule-engine / scheduler on prd-recovr-auto
|
|
5
5
|
cause PVC issues with the constant one-shot timer rescheduling, which gets
|
|
6
|
-
auto vacuumed but the PVC will continue to grow.
|
|
6
|
+
auto vacuumed but the PVC will continue to grow.
|
|
7
|
+
|
|
8
|
+
### Docker subdir
|
|
9
|
+
|
|
10
|
+
The Dockerfile in the docker directory is used for building the all-in-one
|
|
11
|
+
image bundle of debian postgres which pg_repack and kubectl. This is the
|
|
12
|
+
image that is used by the cronjob that periodically repacks the configured
|
|
13
|
+
database. This was initially created for managing the scheduler database
|
|
14
|
+
on prd-recovr. Rebuild the image with => build-repack-kubectl.sh
|
|
15
|
+
|
|
16
|
+
### Charts subdir
|
|
17
|
+
|
|
18
|
+
The charts directory houses the custom charts that we are using. In particular,
|
|
19
|
+
the cronjob that run the scheduler database repacking resides down in this area.
|
|
20
|
+
|
|
@@ -20,27 +20,17 @@ scale_up() {
|
|
|
20
20
|
echo "[maint] waiting for rollout..."
|
|
21
21
|
kubectl -n "$NAMESPACE" rollout status deploy/"$DEPLOY" --timeout=5m || true
|
|
22
22
|
}
|
|
23
|
+
|
|
24
|
+
# this trap ensures the scale_up function always runs on exit
|
|
23
25
|
trap 'echo "[maint] EXIT trap fired"; scale_up' EXIT
|
|
24
26
|
|
|
25
27
|
echo "[maint] scaling $DEPLOY to 0"
|
|
26
28
|
kubectl -n "$NAMESPACE" scale deploy "$DEPLOY" --replicas=0
|
|
27
29
|
kubectl -n "$NAMESPACE" rollout status deploy/"$DEPLOY" --timeout=5m || true
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"SELECT count(*) FROM pg_stat_activity
|
|
33
|
-
WHERE datname=current_database()
|
|
34
|
-
AND pid <> pg_backend_pid()
|
|
35
|
-
AND state IS DISTINCT FROM 'idle';" || echo "999")
|
|
36
|
-
echo "[maint] active sessions: $ACTIVE"
|
|
37
|
-
[ "$ACTIVE" -eq 0 ] && break
|
|
38
|
-
sleep 6
|
|
39
|
-
done
|
|
40
|
-
|
|
41
|
-
echo "[maint] running pg_repack..."
|
|
42
|
-
pg_repack -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d "$DB_NAME" \
|
|
43
|
-
--wait-timeout="$WAIT_TIMEOUT" -E DEBUG
|
|
31
|
+
PG_REPACK_CMD="pg_repack -h $DB_HOST -p $DB_PORT -U $DB_USER -d $DB_NAME --wait-timeout=$WAIT_TIMEOUT -E INFO"
|
|
32
|
+
echo "[maint] Running => $PG_REPACK_CMD"
|
|
33
|
+
$PG_REPACK_CMD
|
|
44
34
|
|
|
45
35
|
echo "[maint] repack finished successfully"
|
|
46
36
|
{{- end -}}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
apiVersion: batch/v1
|
|
2
|
+
kind: CronJob
|
|
3
|
+
metadata:
|
|
4
|
+
name: {{ .Values.deploymentName }}-repack-job
|
|
5
|
+
namespace: {{ .Values.namespace }}
|
|
6
|
+
spec:
|
|
7
|
+
schedule: {{ .Values.schedule | quote }}
|
|
8
|
+
concurrencyPolicy: Forbid
|
|
9
|
+
successfulJobsHistoryLimit: 1
|
|
10
|
+
failedJobsHistoryLimit: 2
|
|
11
|
+
jobTemplate:
|
|
12
|
+
metadata:
|
|
13
|
+
labels:
|
|
14
|
+
helm.sh/chart: {{ .Chart.Version }}
|
|
15
|
+
spec:
|
|
16
|
+
backoffLimit: 0
|
|
17
|
+
template:
|
|
18
|
+
spec:
|
|
19
|
+
serviceAccountName: {{ .Values.serviceAccountName }}
|
|
20
|
+
restartPolicy: Never
|
|
21
|
+
containers:
|
|
22
|
+
- name: repack
|
|
23
|
+
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
|
24
|
+
image: {{ .Values.image.registry }}/{{ .Values.image.repo }}:{{ default .Chart.AppVersion .Values.image.tag }}
|
|
25
|
+
env:
|
|
26
|
+
- name: NAMESPACE
|
|
27
|
+
value: "{{ .Values.namespace }}"
|
|
28
|
+
- name: TARGET_DEPLOYMENT
|
|
29
|
+
value: "{{ .Values.deploymentName }}"
|
|
30
|
+
- name: PGHOST
|
|
31
|
+
value: "{{ .Values.db.host }}"
|
|
32
|
+
- name: PGPORT
|
|
33
|
+
value: "{{ .Values.db.port }}"
|
|
34
|
+
- name: PGUSER
|
|
35
|
+
value: "{{ .Values.db.user }}"
|
|
36
|
+
- name: PGDATABASE
|
|
37
|
+
value: "{{ .Values.db.name }}"
|
|
38
|
+
- name: REPACK_WAIT_TIMEOUT
|
|
39
|
+
value: "{{ .Values.repack.waitTimeout }}"
|
|
40
|
+
# password from EXISTING secret
|
|
41
|
+
- name: PGPASSWORD
|
|
42
|
+
valueFrom:
|
|
43
|
+
secretKeyRef:
|
|
44
|
+
name: {{ .Values.secret.name }}
|
|
45
|
+
key: {{ .Values.secret.passwordKey }}
|
|
46
|
+
volumeMounts:
|
|
47
|
+
- name: script
|
|
48
|
+
mountPath: /opt/maint
|
|
49
|
+
command: ["/bin/bash","/opt/maint/maint.sh"]
|
|
50
|
+
volumes:
|
|
51
|
+
- name: script
|
|
52
|
+
configMap:
|
|
53
|
+
name: {{ .Values.deploymentName }}-repack-script
|
|
54
|
+
defaultMode: 0755
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
namespace: default
|
|
2
|
+
|
|
3
|
+
image:
|
|
4
|
+
pullPolicy: IfNotPresent
|
|
5
|
+
registry: us-docker.pkg.dev/leverege-registry/system/images
|
|
6
|
+
repo: leverege-pgsql11-repack-kubectl
|
|
7
|
+
# Overrides the image tag whose default is the chart appVersion.
|
|
8
|
+
tag: ""
|
|
9
|
+
|
|
10
|
+
schedule: "0 3 * * *" # 3 in the morning UTC
|
|
11
|
+
#schedule: "*/5 * * * *" # every 5 minutes for testing
|
|
12
|
+
|
|
13
|
+
serviceAccountName: repack-maint-sa
|
|
14
|
+
deploymentName: scheduler
|
|
15
|
+
|
|
16
|
+
db:
|
|
17
|
+
host: postgres-scheduler
|
|
18
|
+
port: "5432"
|
|
19
|
+
user: postgres
|
|
20
|
+
name: scheduler
|
|
21
|
+
|
|
22
|
+
repack:
|
|
23
|
+
waitTimeout: "15"
|
|
24
|
+
allowKillBlockers: "false" # "true" to cancel residual blockers (rarely needed)
|
|
25
|
+
|
|
26
|
+
# EXISTING secret in the cluster; we do NOT create it here
|
|
27
|
+
# Default assumes the secret has key "password". Change if yours differs.
|
|
28
|
+
secret:
|
|
29
|
+
name: authz-postgres
|
|
30
|
+
passwordKey: postgresql-password
|
|
31
|
+
|
|
32
|
+
# leave blank to auto-detect current replicas before scaling down
|
|
33
|
+
replicasDefault: ""
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
# Create a legacy psql11 image that includes the pg_repack extension and
|
|
2
|
+
# the k8s kubectl command. This image may be used as either a psql11 pod
|
|
3
|
+
# or as a pod for running remote repacks on a deployed db.
|
|
4
|
+
#
|
|
1
5
|
FROM bitnami/postgresql:11.14.0-debian-10-r28
|
|
2
6
|
|
|
3
7
|
USER root
|
|
@@ -32,6 +36,5 @@ RUN curl -LO "https://dl.k8s.io/release/v${KUBECTL_VERSION}/bin/linux/amd64/kube
|
|
|
32
36
|
&& install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl \
|
|
33
37
|
&& rm kubectl
|
|
34
38
|
|
|
35
|
-
# Drop back to non-root user
|
|
39
|
+
# Drop back to non-root user
|
|
36
40
|
USER 1001
|
|
37
|
-
|
package/src/custom-images/pg_repack/{build-repack-kubectl.sh → docker/build-repack-kubectl.sh}
RENAMED
|
@@ -4,5 +4,5 @@ docker buildx build \
|
|
|
4
4
|
--platform linux/amd64 \
|
|
5
5
|
--build-arg KUBECTL_VERSION=1.30.2 \
|
|
6
6
|
--push \
|
|
7
|
-
-t us-docker.pkg.dev/leverege-registry/system/images/leverege-pgsql11-repack-kubectl:11.14-kctl.
|
|
7
|
+
-t us-docker.pkg.dev/leverege-registry/system/images/leverege-pgsql11-repack-kubectl:11.14-kctl.3 \
|
|
8
8
|
.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
showInstalling "PG Repacking Cronjob"
|
|
4
|
+
|
|
5
|
+
OCI_CHART="oci://us-docker.pkg.dev/leverege-registry/system/charts/repack-cron"
|
|
6
|
+
|
|
7
|
+
[ -z "$PG_REPACK_CHART_VERSION" ] && PG_REPACK_CHART_VERSION="0.5.2"
|
|
8
|
+
|
|
9
|
+
helm upgrade --install repack $OCI_CHART \
|
|
10
|
+
--values pg-repack/values.yaml \
|
|
11
|
+
--version $PG_REPACK_CHART_VERSION $HELM_WHAT
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#
|
|
2
|
+
# 0 3 * * * - 3am UTC
|
|
3
|
+
# */15 * * * * - 15 minute intervals
|
|
4
|
+
#
|
|
5
|
+
schedule: "*/5 * * * *"
|
|
6
|
+
|
|
7
|
+
db:
|
|
8
|
+
host: "postgres-scheduler"
|
|
9
|
+
port: "5432"
|
|
10
|
+
user: "postgres"
|
|
11
|
+
name: "scheduler"
|
|
12
|
+
|
|
13
|
+
# the existing password to use
|
|
14
|
+
secret:
|
|
15
|
+
name: "authz-postgres"
|
|
16
|
+
passwordKey: "postgresql-password"
|
|
@@ -221,7 +221,7 @@ alertmanager:
|
|
|
221
221
|
continue: true # 👈 KEEP GOING after this match
|
|
222
222
|
|
|
223
223
|
- matchers:
|
|
224
|
-
- namespace
|
|
224
|
+
- namespace=~"kube-system|gmp-system" # 🙈 ignore these alerts - GKE will handle them
|
|
225
225
|
receiver: discard
|
|
226
226
|
|
|
227
227
|
- matchers:
|
|
@@ -383,7 +383,7 @@ spec:
|
|
|
383
383
|
LABELS = {{ $labels }}
|
|
384
384
|
- alert: KubernetesApiServerLatency
|
|
385
385
|
expr: histogram_quantile(0.99, sum(rate(apiserver_request_duration_seconds_bucket{verb!~"(?:CONNECT|WATCHLIST|WATCH|PROXY)"} [10m])) WITHOUT (subresource)) > 1
|
|
386
|
-
for: 15m
|
|
386
|
+
for: 30m # awesome was 15m
|
|
387
387
|
labels:
|
|
388
388
|
severity: warning
|
|
389
389
|
annotations:
|
package/src/push-my-chart.mjs
CHANGED
|
@@ -8,6 +8,12 @@ import { lt as semverLt } from 'semver'
|
|
|
8
8
|
import { debug, log, shellCmd } from './Utils.mjs'
|
|
9
9
|
|
|
10
10
|
const commandLineOptions = [
|
|
11
|
+
{
|
|
12
|
+
name : 'chart',
|
|
13
|
+
type : String,
|
|
14
|
+
defaultValue : 'helm',
|
|
15
|
+
description : '{green directory containing the chart - default: helm}',
|
|
16
|
+
},
|
|
11
17
|
{
|
|
12
18
|
name : 'no-registry',
|
|
13
19
|
type : Boolean,
|
|
@@ -49,7 +55,7 @@ const pushItGood = async () => {
|
|
|
49
55
|
let museumStatus = 0
|
|
50
56
|
try {
|
|
51
57
|
log( chalk.green( 'Pushing chart to the Chartmuseum\n' ) )
|
|
52
|
-
const museum = await shellCmd( `helm ${pusher}
|
|
58
|
+
const museum = await shellCmd( `helm ${pusher} ${args.chart} leverege` )
|
|
53
59
|
debug( { museum }, '<==output from helm push' )
|
|
54
60
|
} catch ( ex ) {
|
|
55
61
|
log( ex.stderr )
|
|
@@ -63,7 +69,7 @@ const pushItGood = async () => {
|
|
|
63
69
|
|
|
64
70
|
try {
|
|
65
71
|
log( chalk.green( 'Pushing chart to the Artifact Registry\n' ) )
|
|
66
|
-
const registry = await shellCmd(
|
|
72
|
+
const registry = await shellCmd( `chart-to-registry --chart ${args.chart}` )
|
|
67
73
|
debug( { registry }, '<==chart-to-registry' )
|
|
68
74
|
process.exit( museumStatus )
|
|
69
75
|
} catch ( ex ) {
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
apiVersion: batch/v1
|
|
2
|
-
kind: CronJob
|
|
3
|
-
metadata:
|
|
4
|
-
name: scheduler-db-repack
|
|
5
|
-
namespace: {{ .Values.namespace }}
|
|
6
|
-
spec:
|
|
7
|
-
schedule: {{ .Values.schedule | quote }}
|
|
8
|
-
concurrencyPolicy: Forbid
|
|
9
|
-
successfulJobsHistoryLimit: 1
|
|
10
|
-
failedJobsHistoryLimit: 2
|
|
11
|
-
jobTemplate:
|
|
12
|
-
spec:
|
|
13
|
-
backoffLimit: 0
|
|
14
|
-
template:
|
|
15
|
-
spec:
|
|
16
|
-
serviceAccountName: {{ .Values.serviceAccountName }}
|
|
17
|
-
restartPolicy: Never
|
|
18
|
-
containers:
|
|
19
|
-
- name: repack
|
|
20
|
-
image: "{{ .Values.image.repo }}:{{ .Values.image.tag }}"
|
|
21
|
-
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
|
22
|
-
envFrom:
|
|
23
|
-
- secretRef:
|
|
24
|
-
name: scheduler-pg-creds
|
|
25
|
-
volumeMounts:
|
|
26
|
-
- name: script
|
|
27
|
-
mountPath: /opt/maint
|
|
28
|
-
command: ["/bin/bash","/opt/maint/maint.sh"]
|
|
29
|
-
volumes:
|
|
30
|
-
- name: script
|
|
31
|
-
configMap:
|
|
32
|
-
name: repack-maint-script
|
|
33
|
-
defaultMode: 0755
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
namespace: default
|
|
2
|
-
|
|
3
|
-
image:
|
|
4
|
-
repo: us-docker.pkg.dev/leverege-registry/system/images/leverege-pgsql11-repack-kubectl
|
|
5
|
-
tag: 11.14-kctl.2
|
|
6
|
-
pullPolicy: IfNotPresent
|
|
7
|
-
|
|
8
|
-
#schedule: "0 3 * * *" # 3 in the morning UTC
|
|
9
|
-
schedule: "*/5 * * * *" # every 5 minutes for testing
|
|
10
|
-
deploymentName: scheduler
|
|
11
|
-
db:
|
|
12
|
-
host: postgres-scheduler
|
|
13
|
-
port: "5432"
|
|
14
|
-
user: postgres
|
|
15
|
-
name: scheduler
|
|
16
|
-
repack:
|
|
17
|
-
waitTimeout: "15"
|
|
18
|
-
|
|
19
|
-
# You can set this via --set-file or external secrets in prod
|
|
20
|
-
pgPassword: "REPLACE_ME"
|
|
21
|
-
|
|
22
|
-
replicasDefault: "" # leave blank to detect automatically
|
|
23
|
-
serviceAccountName: repack-maint-sa
|
|
File without changes
|
|
File without changes
|
/package/src/custom-images/pg_repack/charts/{repack → repack-cron}/templates/serviceaccount.yaml
RENAMED
|
File without changes
|