@leverege/build-tools 2.82.0 → 2.83.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/src/bash-funcs +1 -1
- package/src/helm-charts/postgres/postgres-local.yaml +3 -3
- package/src/helm-charts/prom-operator/rules/kubestate-rules.yaml +1 -1
- package/src/helmup.sh +17 -31
- package/src/pg_repack/Dockerfile +37 -0
- package/src/pg_repack/README.md +6 -0
- package/src/pg_repack/build-repack-kubectl.sh +8 -0
- package/src/pg_repack/charts/repack/Chart.yaml +5 -0
- package/src/pg_repack/charts/repack/templates/_helpers.tpl +46 -0
- package/src/pg_repack/charts/repack/templates/configmap.yaml +8 -0
- package/src/pg_repack/charts/repack/templates/cronjob.yaml +33 -0
- package/src/pg_repack/charts/repack/templates/rbac.yaml +25 -0
- package/src/pg_repack/charts/repack/templates/secret.yaml +8 -0
- package/src/pg_repack/charts/repack/templates/serviceaccount.yaml +5 -0
- package/src/pg_repack/charts/repack/values.yaml +23 -0
- package/src/pg_repack/deploy.sh +3 -0
- package/src/pg_repack/quick.yaml +10 -0
- package/src/bitnami-audit.sh +0 -75
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leverege/build-tools",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.83.1",
|
|
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.
|
|
68
|
+
"chalk": "^5.6.0",
|
|
69
69
|
"command-line-args": "^6.0.1",
|
|
70
70
|
"command-line-usage": "^7.0.3",
|
|
71
71
|
"commander": "^14.0.0",
|
|
@@ -75,13 +75,13 @@
|
|
|
75
75
|
"glob": "^11.0.3",
|
|
76
76
|
"handlebars": "^4.7.8",
|
|
77
77
|
"ignore": "^7.0.5",
|
|
78
|
-
"inquirer": "^12.9.
|
|
78
|
+
"inquirer": "^12.9.3",
|
|
79
79
|
"js-yaml": "^4.1.0",
|
|
80
80
|
"jsdoc": "^4.0.4",
|
|
81
81
|
"ms": "^2.1.3",
|
|
82
82
|
"npm-registry-fetch": "^19.0.0",
|
|
83
83
|
"ora": "^8.2.0",
|
|
84
|
-
"p-limit": "^
|
|
84
|
+
"p-limit": "^7.1.0",
|
|
85
85
|
"package-up": "^5.0.0",
|
|
86
86
|
"readline-sync": "^1.4.10",
|
|
87
87
|
"semver": "^7.7.2",
|
package/src/bash-funcs
CHANGED
|
@@ -153,7 +153,7 @@ REPOADD
|
|
|
153
153
|
# *** DEPRECATED *** REMOVE AFTER BITNAMI ERADICATED ***
|
|
154
154
|
# *** DEPRECATED *** REMOVE AFTER BITNAMI ERADICATED ***
|
|
155
155
|
#
|
|
156
|
-
function
|
|
156
|
+
function addBitnamiRepoDEPRECATED() {
|
|
157
157
|
if [ ! -z "$BITNAMI_LATEST" ] || [ "$1" == "latest" ];
|
|
158
158
|
then
|
|
159
159
|
BITNAMI_URL="https://charts.bitnami.com/bitnami"
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
#
|
|
3
3
|
image:
|
|
4
4
|
registry: us-docker.pkg.dev
|
|
5
|
-
repository: leverege-registry/
|
|
6
|
-
|
|
5
|
+
repository: leverege-registry/system/images/leverege-pgsql11-repack-kubectl
|
|
6
|
+
tag: 11.14-kctl.3
|
|
7
7
|
|
|
8
8
|
postgresqlExtendedConf:
|
|
9
9
|
maxWorkerProcesses: 4
|
|
@@ -33,7 +33,7 @@ metrics:
|
|
|
33
33
|
repository: leverege-registry/bitnami-mirror/images/postgres-exporter
|
|
34
34
|
# tag: 0.10.0-debian-10-r172
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
primary:
|
|
37
37
|
tolerations:
|
|
38
38
|
- key: "database"
|
|
39
39
|
operator: "Equal"
|
|
@@ -229,7 +229,7 @@ spec:
|
|
|
229
229
|
LABELS = {{ $labels }}
|
|
230
230
|
- alert: KubernetesReplicasetReplicasMismatch
|
|
231
231
|
expr: kube_replicaset_spec_replicas != kube_replicaset_status_ready_replicas
|
|
232
|
-
for: 10m
|
|
232
|
+
for: 15m # awesome was => 10m
|
|
233
233
|
labels:
|
|
234
234
|
severity: warning
|
|
235
235
|
annotations:
|
package/src/helmup.sh
CHANGED
|
@@ -59,7 +59,7 @@ SYSTEM=(
|
|
|
59
59
|
traefik
|
|
60
60
|
prom-operator
|
|
61
61
|
elasticsearch8
|
|
62
|
-
|
|
62
|
+
valkey
|
|
63
63
|
cnpg-operator
|
|
64
64
|
preemptible-killer
|
|
65
65
|
zombie-killer
|
|
@@ -246,32 +246,20 @@ SERVICE_BOOTSTRAP
|
|
|
246
246
|
ifPluggedIn $SERVICE
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
-
#
|
|
250
|
-
#
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
argocd
|
|
254
|
-
cnpg-operator
|
|
255
|
-
cnpg-db-psql-stack
|
|
256
|
-
cnpg-db-tsdb-basic
|
|
257
|
-
elasticsearch8
|
|
258
|
-
pgbouncer
|
|
259
|
-
prom-operator
|
|
260
|
-
redis
|
|
261
|
-
valkey
|
|
262
|
-
traefik
|
|
263
|
-
traefik-canary
|
|
264
|
-
velero
|
|
265
|
-
)
|
|
249
|
+
# If the service is already plugged in the go - otherwise if this is a first
|
|
250
|
+
# time install of a known service then bootstrap it and go. Otherwise return
|
|
251
|
+
# a status of 1 to indicate to continue processing.
|
|
252
|
+
function ifPluggedInOrBootstrapped() {
|
|
266
253
|
local svc_name="$1"
|
|
267
254
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
255
|
+
ifPluggedIn $svc_name && return 0 # if it's already plugged in then go
|
|
256
|
+
|
|
257
|
+
# check to see if build-tools knows about the new service in its configs
|
|
258
|
+
local svc_plugin="$(build-tools --reporoot)/src/helm-charts/${svc_name}/helmup.plugin"
|
|
259
|
+
[[ ! -x "$svc_plugin" ]] && return 1 # indicates unknown
|
|
260
|
+
|
|
261
|
+
bootstrapLocalSetup $svc_name
|
|
262
|
+
return 0
|
|
275
263
|
}
|
|
276
264
|
|
|
277
265
|
function installDefaultConfigs() {
|
|
@@ -396,7 +384,7 @@ spec:
|
|
|
396
384
|
containers:
|
|
397
385
|
- name: cron-zombie-killer
|
|
398
386
|
imagePullPolicy: IfNotPresent
|
|
399
|
-
image:
|
|
387
|
+
image: registry.k8s.io/kubectl:v1.30.3
|
|
400
388
|
command:
|
|
401
389
|
- "/bin/sh"
|
|
402
390
|
args:
|
|
@@ -590,11 +578,9 @@ CATBACKUP
|
|
|
590
578
|
helmdn $SERVICE
|
|
591
579
|
fi
|
|
592
580
|
|
|
593
|
-
# If
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
# If we can bootstrap a service on a new setup
|
|
597
|
-
ifCanBootstrap $SERVICE && continue
|
|
581
|
+
# If the service is already plugged in or can be bootstrapped
|
|
582
|
+
# during initial install then do so here
|
|
583
|
+
ifPluggedInOrBootstrapped $SERVICE && continue
|
|
598
584
|
|
|
599
585
|
case "$SERVICE" in
|
|
600
586
|
"platform")
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
FROM bitnami/postgresql:11.14.0-debian-10-r28
|
|
2
|
+
|
|
3
|
+
USER root
|
|
4
|
+
|
|
5
|
+
# ---- Patch apt to use Debian archive repos since Buster is EOL ----
|
|
6
|
+
RUN sed -i 's|http://deb.debian.org/debian|http://archive.debian.org/debian|g' /etc/apt/sources.list \
|
|
7
|
+
&& sed -i 's|http://security.debian.org|http://archive.debian.org/debian-security|g' /etc/apt/sources.list \
|
|
8
|
+
&& echo 'Acquire::Check-Valid-Until "false";' > /etc/apt/apt.conf.d/99no-check-valid-until \
|
|
9
|
+
&& apt-get update
|
|
10
|
+
|
|
11
|
+
# ---- Install pg_repack build dependencies ----
|
|
12
|
+
RUN install_packages \
|
|
13
|
+
git \
|
|
14
|
+
build-essential \
|
|
15
|
+
libpq-dev \
|
|
16
|
+
postgresql-server-dev-11 \
|
|
17
|
+
libssl-dev \
|
|
18
|
+
zlib1g-dev \
|
|
19
|
+
ca-certificates \
|
|
20
|
+
curl
|
|
21
|
+
|
|
22
|
+
# ---- Build and install pg_repack ----
|
|
23
|
+
RUN git clone https://github.com/reorg/pg_repack.git /tmp/pg_repack \
|
|
24
|
+
&& cd /tmp/pg_repack \
|
|
25
|
+
&& make \
|
|
26
|
+
&& make install \
|
|
27
|
+
&& rm -rf /tmp/pg_repack
|
|
28
|
+
|
|
29
|
+
# ---- Install kubectl ----
|
|
30
|
+
ARG KUBECTL_VERSION=1.30.0
|
|
31
|
+
RUN curl -LO "https://dl.k8s.io/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl" \
|
|
32
|
+
&& install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl \
|
|
33
|
+
&& rm kubectl
|
|
34
|
+
|
|
35
|
+
# Drop back to non-root user (Bitnami default)
|
|
36
|
+
USER 1001
|
|
37
|
+
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
## Docker with pg_repack and kubectl
|
|
2
|
+
|
|
3
|
+
This configuration is needed for providing repack capabilities for legacy
|
|
4
|
+
postgresql 11 systems. Specifically, rule-engine / scheduler on prd-recovr-auto
|
|
5
|
+
cause PVC issues with the constant one-shot timer rescheduling, which gets
|
|
6
|
+
auto vacuumed but the PVC will continue to grow.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{{- define "repackMaintScript" -}}
|
|
2
|
+
#!/usr/bin/env bash
|
|
3
|
+
set -euo pipefail
|
|
4
|
+
|
|
5
|
+
NAMESPACE="{{ .Values.namespace }}"
|
|
6
|
+
DEPLOY="{{ .Values.deploymentName }}"
|
|
7
|
+
DB_HOST="{{ .Values.db.host }}"
|
|
8
|
+
DB_PORT="{{ .Values.db.port }}"
|
|
9
|
+
DB_USER="{{ .Values.db.user }}"
|
|
10
|
+
DB_NAME="{{ .Values.db.name }}"
|
|
11
|
+
WAIT_TIMEOUT="{{ .Values.repack.waitTimeout }}"
|
|
12
|
+
|
|
13
|
+
CURRENT=$(kubectl -n "$NAMESPACE" get deploy "$DEPLOY" -o jsonpath='{.spec.replicas}' 2>/dev/null || echo "")
|
|
14
|
+
REPLICAS="${CURRENT:-1}"
|
|
15
|
+
echo "[maint] current replicas for $DEPLOY: $REPLICAS"
|
|
16
|
+
|
|
17
|
+
scale_up() {
|
|
18
|
+
echo "[maint] scaling $DEPLOY back to $REPLICAS"
|
|
19
|
+
kubectl -n "$NAMESPACE" scale deploy "$DEPLOY" --replicas="$REPLICAS" || true
|
|
20
|
+
echo "[maint] waiting for rollout..."
|
|
21
|
+
kubectl -n "$NAMESPACE" rollout status deploy/"$DEPLOY" --timeout=5m || true
|
|
22
|
+
}
|
|
23
|
+
trap 'echo "[maint] EXIT trap fired"; scale_up' EXIT
|
|
24
|
+
|
|
25
|
+
echo "[maint] scaling $DEPLOY to 0"
|
|
26
|
+
kubectl -n "$NAMESPACE" scale deploy "$DEPLOY" --replicas=0
|
|
27
|
+
kubectl -n "$NAMESPACE" rollout status deploy/"$DEPLOY" --timeout=5m || true
|
|
28
|
+
|
|
29
|
+
echo "[maint] waiting for DB sessions to drain..."
|
|
30
|
+
for i in {1..10}; do
|
|
31
|
+
ACTIVE=$(psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d "$DB_NAME" -Atc \
|
|
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
|
|
44
|
+
|
|
45
|
+
echo "[maint] repack finished successfully"
|
|
46
|
+
{{- end -}}
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
apiVersion: rbac.authorization.k8s.io/v1
|
|
2
|
+
kind: Role
|
|
3
|
+
metadata:
|
|
4
|
+
name: repack-maint-role
|
|
5
|
+
namespace: {{ .Values.namespace }}
|
|
6
|
+
rules:
|
|
7
|
+
- apiGroups: ["apps"]
|
|
8
|
+
resources: ["deployments", "deployments/scale"]
|
|
9
|
+
verbs: ["get","list","watch","patch","update"]
|
|
10
|
+
- apiGroups: [""]
|
|
11
|
+
resources: ["pods"]
|
|
12
|
+
verbs: ["get","list","watch"]
|
|
13
|
+
---
|
|
14
|
+
apiVersion: rbac.authorization.k8s.io/v1
|
|
15
|
+
kind: RoleBinding
|
|
16
|
+
metadata:
|
|
17
|
+
name: repack-maint-rb
|
|
18
|
+
namespace: {{ .Values.namespace }}
|
|
19
|
+
subjects:
|
|
20
|
+
- kind: ServiceAccount
|
|
21
|
+
name: {{ .Values.serviceAccountName }}
|
|
22
|
+
roleRef:
|
|
23
|
+
apiGroup: rbac.authorization.k8s.io
|
|
24
|
+
kind: Role
|
|
25
|
+
name: repack-maint-role
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
package/src/bitnami-audit.sh
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
BITNAMI_CTX=(
|
|
4
|
-
dev-controltek
|
|
5
|
-
dev-cox-health
|
|
6
|
-
dev-pitcrew
|
|
7
|
-
dev-recovr-auto
|
|
8
|
-
dev-schnucks
|
|
9
|
-
dev-tpi
|
|
10
|
-
discount-tire-prd
|
|
11
|
-
discount-tire-stg
|
|
12
|
-
leverege-cnpg-20240729
|
|
13
|
-
leverege-ops-20250730
|
|
14
|
-
leverege-demo
|
|
15
|
-
leverege-elastic
|
|
16
|
-
leverege-onboarding
|
|
17
|
-
leverege-sandbox
|
|
18
|
-
nimbelink-demo
|
|
19
|
-
prd-controltek
|
|
20
|
-
prd-cox-health
|
|
21
|
-
prd-generic-kudelski
|
|
22
|
-
prd-les-schwab
|
|
23
|
-
prd-recovr-auto
|
|
24
|
-
prd-skymirr
|
|
25
|
-
prd-tpi
|
|
26
|
-
prd-valvoline
|
|
27
|
-
qa-cox-health
|
|
28
|
-
siren-marine-dev
|
|
29
|
-
siren-marine-prd
|
|
30
|
-
siren-marine-staging
|
|
31
|
-
siren-marine-test
|
|
32
|
-
stg-cox-health
|
|
33
|
-
stg-generic-kudelski
|
|
34
|
-
stg-recovr-auto
|
|
35
|
-
stg-recovr-perf
|
|
36
|
-
)
|
|
37
|
-
|
|
38
|
-
function gitCheckoutCleanBranch() {
|
|
39
|
-
# find the cruft, namely any values.yaml files which tend to block the
|
|
40
|
-
# cleaning of subdirs that contain them (values.yaml aren't tracked in git)
|
|
41
|
-
find . -not \( -path \*junk -prune -o -path \*helm-elasticsearch -prune \) -name values.yaml -exec rm {} \;
|
|
42
|
-
git ko bootstrap-k8s &> /dev/null
|
|
43
|
-
git clean -d --force &> /dev/null
|
|
44
|
-
|
|
45
|
-
local branch=${1:bootstrap-k8s}
|
|
46
|
-
git ko "$branch" &> /dev/null
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
# create a clean sheet with headers
|
|
50
|
-
CSV_FILE="../BitnamiImageRegistry.csv"
|
|
51
|
-
rm -f $CSV_FILE
|
|
52
|
-
echo 'project,namespace,service,image,version' > $CSV_FILE
|
|
53
|
-
|
|
54
|
-
gitCheckoutCleanBranch # start clean
|
|
55
|
-
|
|
56
|
-
for CTX in "${BITNAMI_CTX[@]}";
|
|
57
|
-
do
|
|
58
|
-
gitCheckoutCleanBranch $CTX
|
|
59
|
-
|
|
60
|
-
if [[ $? -eq 0 ]];
|
|
61
|
-
then
|
|
62
|
-
overwhelm -f
|
|
63
|
-
overwhelm -m
|
|
64
|
-
if [[ $? -ne 0 ]];
|
|
65
|
-
then
|
|
66
|
-
echo "Project [${CTX}] is valid, but the k8s context is not - skipping..."
|
|
67
|
-
continue
|
|
68
|
-
fi
|
|
69
|
-
echo "Context GOOD [$CTX]"
|
|
70
|
-
kubectl get deploy,statefulset -A -o json | bitnami-k8s-parse $CTX >> $CSV_FILE
|
|
71
|
-
fi
|
|
72
|
-
find . -not \( -path \*junk -prune -o -path \*helm-elasticsearch -prune \) -name values.yaml -exec rm {} \;
|
|
73
|
-
done
|
|
74
|
-
|
|
75
|
-
gitCheckoutCleanBranch # end clean
|