@leverege/build-tools 2.67.0 → 2.67.2-pedro.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leverege/build-tools",
3
- "version": "2.67.0",
3
+ "version": "2.67.2-pedro.1",
4
4
  "description": "A collection of build / support tools for Leverege developers",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -92,4 +92,4 @@
92
92
  "@leverege/eslint-config-leverege": "^5.0.1",
93
93
  "npm": "^11.4.1"
94
94
  }
95
- }
95
+ }
package/src/DockerPy.mjs CHANGED
@@ -221,9 +221,9 @@ async function buildContainerImage( {
221
221
  await shellCmd( `${cloudBuildCmd} ${cloudBuildLogs} ${cloudBuildCfg} ./build`, { stdio : 'inherit' } )
222
222
  }
223
223
 
224
- async function repoCleanup() {
224
+ async function repoCleanup( doNotCleanupPaths = [] ) {
225
225
  // remove garbage from the repo
226
- const garbage = [
226
+ let garbage = [
227
227
  'build',
228
228
  'dist',
229
229
  'docker/.keep',
@@ -233,6 +233,10 @@ async function repoCleanup() {
233
233
  'docker/Dockerfile',
234
234
  'docker/workspace',
235
235
  ]
236
+
237
+ // Remove any paths that are in the doNotCleanupPaths array from the garbage list
238
+ garbage = garbage.filter( path => !doNotCleanupPaths.includes( path ) )
239
+
236
240
  garbage.forEach( trash => fs.rmSync( trash, { recursive : true, force : true } ) )
237
241
 
238
242
  fs.writeFileSync( 'docker/.gitignore', '.previous\nDockerfile' )
package/src/Utils.mjs CHANGED
@@ -537,7 +537,7 @@ export const analyzeRepository = async ( giveGuidance ) => {
537
537
  const containerName = closestPackageJson?.name.replace( /^@[^/]+\//, '' ) || rootPyProjectToml?.project.name
538
538
  const artifactProject = closestPackageJson?.artifactRegistry.project || 'unused'
539
539
  const artifactRegistry = closestPackageJson?.leverege.registry || rootPyProjectToml?.registry
540
- const packageVersion = `v${closestPackageJson?.version}` || rootPyProjectToml?.project.version
540
+ const packageVersion = `v${closestPackageJson?.version || rootPyProjectToml?.project.version}`
541
541
 
542
542
  const currentDir = process.cwd()
543
543
  const closestPkg = await packageUp()
@@ -89,10 +89,10 @@ const pyproject = toml.parse( tomlStr )
89
89
  const repoDescr = {
90
90
  artifactProject : pyproject.leverege.project || 'leverege-registry',
91
91
  containerName : pyproject.project.name,
92
- packageVersion : pyproject.project.version,
92
+ packageVersion : `v${pyproject.project.version}`,
93
93
  artifactRegistry : pyproject.leverege.registry || 'us-docker.pkg.dev/leverege-registry/stack',
94
- registryFolder : `${pyproject.leverege.registryFolder}/images/${pyproject.project.name}`,
95
- imageBase : pyproject.leverege.imageBase,
94
+ registryFolder : `${pyproject.leverege['registry-folder']}/images/${pyproject.project.name}`,
95
+ imageBase : pyproject.leverege['image-base'],
96
96
  helmChart : await parseHelmChart(),
97
97
  }
98
98
 
@@ -124,7 +124,11 @@ const registryFolder = `${artifactRegistry}/images/${containerName}`
124
124
  // await shellCmd( 'npm install', { stdio : 'inherit' } )
125
125
 
126
126
  if ( giveGuidance ) {
127
- await Docker.repoCleanup() // adjusts gitignore files and removes cruft
127
+ const doNotCleanupPaths = [
128
+ 'docker/Dockerfile',
129
+ ]
130
+
131
+ await Docker.repoCleanup( doNotCleanupPaths ) // adjusts gitignore files and removes cruft
128
132
  log( `
129
133
 
130
134
 
File without changes
@@ -0,0 +1,11 @@
1
+ #!/bin/bash
2
+
3
+ showInstalling "PG Bouncer"
4
+
5
+ OCI_CHART="oci://ghcr.io/icoretech/charts/pgbouncer"
6
+
7
+ [ -z "$PGBOUNCER_CHART_VERSION" ] && PGBOUNCER_CHART_VERSION="2.7.0"
8
+
9
+ helm upgrade --install pgbouncer $OCI_CHART \
10
+ --values pgbouncer/values-local.yaml \
11
+ --version $PGBOUNCER_CHART_VERSION $HELM_WHAT
@@ -0,0 +1,56 @@
1
+ # pgbouncer.values.yaml - https://artifacthub.io/packages/helm/icoretech/pgbouncer
2
+
3
+ replicaCount: 1
4
+
5
+ config:
6
+ existingAdminSecret: "pgbouncer-admin"
7
+ existingUserlistSecret: "pgbouncer-userlist-secret"
8
+ pgbouncer:
9
+ default_pool_size: "20"
10
+ idle_transaction_timeout: "60"
11
+ ignore_startup_parameters: "extra_float_digits"
12
+ max_client_conn: "1000"
13
+ pool_mode: "transaction" # Options: session | transaction | statement
14
+ query_wait_timeout: "120"
15
+ reserve_pool_size: "5"
16
+ reserve_pool_timeout: "5"
17
+ server_connect_timeout: "15"
18
+ server_idle_timeout: "600"
19
+ server_lifetime: "3600"
20
+ server_login_retry: "15"
21
+ # https://www.pgbouncer.org/config.html#log-settings
22
+ log_connections: "1"
23
+ log_disconnections: "0"
24
+ verbose: "0"
25
+ databases:
26
+ scheduler:
27
+ host: postgres-postgresql
28
+ port: 5432
29
+ dbname: scheduler
30
+ user: postgres
31
+ models:
32
+ host: postgres-postgresql
33
+ port: 5432
34
+ dbname: models
35
+ user: postgres
36
+
37
+ service:
38
+ port: 8432
39
+
40
+ resources:
41
+ requests:
42
+ cpu: 100m
43
+ memory: 128Mi
44
+ limits:
45
+ cpu: 200m
46
+ memory: 256Mi
47
+
48
+ # Optional: Configure a serviceAccount if needed
49
+ serviceAccount:
50
+ create: true
51
+ name: ""
52
+
53
+ # Optional: Add any needed nodeSelectors or tolerations
54
+ nodeSelector: {}
55
+ tolerations: []
56
+ affinity: {}
@@ -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="73"
9
+ [ -z "$PROMETHEUS_STACK_CHART_VERSION" ] && PROMETHEUS_STACK_CHART_VERSION="74"
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 \
@@ -109,7 +109,13 @@ alertmanager:
109
109
  operator: "Equal"
110
110
  value: "true"
111
111
  effect: "NoSchedule"
112
-
112
+ storage:
113
+ volumeClaimTemplate:
114
+ spec:
115
+ accessModes: ["ReadWriteOnce"]
116
+ resources:
117
+ requests:
118
+ storage: 10Gi # or however much you need
113
119
  strategy:
114
120
  type: Recreate
115
121
 
@@ -162,19 +162,19 @@ spec:
162
162
  Elasticsearch has pending tasks. Cluster works slowly.
163
163
  VALUE = {{ $value }}
164
164
  LABELS = {{ $labels }}
165
- - alert: ElasticsearchNoNewDocuments
166
- expr: increase(elasticsearch_indices_indexing_index_total{es_data_node="true"}[10m]) < 1
167
- for: 0m
168
- labels:
169
- severity: warning
170
- annotations:
171
- summary: Elasticsearch no new documents (instance {{ $labels.instance }})
172
- description: |-
173
- No new documents for 10 min!
174
- VALUE = {{ $value }}
175
- LABELS = {{ $labels }}
165
+ # - alert: ElasticsearchNoNewDocuments
166
+ # expr: increase(elasticsearch_indices_indexing_index_total{es_data_node="true"}[10m]) < 1
167
+ # for: 0m
168
+ # labels:
169
+ # severity: warning
170
+ # annotations:
171
+ # summary: Elasticsearch no new documents (instance {{ $labels.instance }})
172
+ # description: |-
173
+ # No new documents for 10 min!
174
+ # VALUE = {{ $value }}
175
+ # LABELS = {{ $labels }}
176
176
  - alert: ElasticsearchHighIndexingLatency
177
- expr: elasticsearch_indices_indexing_index_time_seconds_total / elasticsearch_indices_indexing_index_total > 0.005 # awesome was 0.0005
177
+ expr: elasticsearch_indices_indexing_index_time_seconds_total / elasticsearch_indices_indexing_index_total > 0.010 # awesome was 0.0005
178
178
  for: 10m
179
179
  labels:
180
180
  severity: warning
@@ -154,7 +154,7 @@ spec:
154
154
  LABELS = {{ $labels }}
155
155
  - alert: KubernetesStatefulsetDown
156
156
  expr: kube_statefulset_replicas != kube_statefulset_status_replicas_ready > 0
157
- for: 1m
157
+ for: 3m # awesome was 1m
158
158
  labels:
159
159
  severity: critical
160
160
  annotations:
@@ -194,17 +194,17 @@ spec:
194
194
  summary: Kubernetes HPA scale maximum (instance {{ $labels.instance }})
195
195
  description: |-
196
196
  HPA {{ $labels.namespace }}/{{ $labels.horizontalpodautoscaler }} has hit max replica pods of {{ $value }}
197
- - alert: KubernetesHpaUnderutilized
198
- expr: max(quantile_over_time(0.5, kube_horizontalpodautoscaler_status_desired_replicas[1d]) == kube_horizontalpodautoscaler_spec_min_replicas) by (horizontalpodautoscaler) > 3
199
- for: 0m
200
- labels:
201
- severity: info
202
- annotations:
203
- summary: Kubernetes HPA underutilized (instance {{ $labels.instance }})
204
- description: |-
205
- HPA {{ $labels.namespace }}/{{ $labels.horizontalpodautoscaler }} is constantly at minimum replicas for 50% of the time. Potential cost saving here.
206
- VALUE = {{ $value }}
207
- LABELS = {{ $labels }}
197
+ # - alert: KubernetesHpaUnderutilized
198
+ # expr: max(quantile_over_time(0.5, kube_horizontalpodautoscaler_status_desired_replicas[1d]) == kube_horizontalpodautoscaler_spec_min_replicas) by (horizontalpodautoscaler) > 3
199
+ # for: 0m
200
+ # labels:
201
+ # severity: info
202
+ # annotations:
203
+ # summary: Kubernetes HPA underutilized (instance {{ $labels.instance }})
204
+ # description: |-
205
+ # HPA {{ $labels.namespace }}/{{ $labels.horizontalpodautoscaler }} is constantly at minimum replicas for 50% of the time. Potential cost saving here.
206
+ # VALUE = {{ $value }}
207
+ # LABELS = {{ $labels }}
208
208
  - alert: KubernetesPodNotHealthy
209
209
  expr: sum by (namespace, pod) (kube_pod_status_phase{phase=~"Pending|Unknown|Failed"}) > 0
210
210
  for: 15m
@@ -2,10 +2,10 @@
2
2
  # reserved static IPs and for creating a secondary LB for UDP traffic.
3
3
  # See the *** UDP PORTS *** section below for more info.
4
4
  #
5
- #service:
6
- # spec:
7
- # loadBalancerIP: ${TRAEFIK_IP} # set in overwhelm.yaml
8
- # single: true # true by default, set to false for UDP support
5
+ service:
6
+ spec:
7
+ loadBalancerIP: ${TRAEFIK_IP} # set in overwhelm.yaml
8
+ single: true # true by default, set to false for UDP support
9
9
 
10
10
  deployment:
11
11
  replicas: 3
@@ -28,7 +28,7 @@ resources:
28
28
  metrics:
29
29
  prometheus:
30
30
  serviceMonitor:
31
- enabled: false
31
+ enabled: true
32
32
  interval: 30s
33
33
  namespace: prometheus
34
34
 
package/src/helmup.sh CHANGED
@@ -40,6 +40,7 @@ AUXILIARY=(
40
40
  fota-server
41
41
  geotile-server
42
42
  overdose
43
+ pgbouncer,
43
44
  pubsub-pulse
44
45
  push-notifier
45
46
  pusher
@@ -198,6 +199,27 @@ function setupStackBuckets() {
198
199
  makeUniformBucketWithCors geotile-server PUBLIC
199
200
  }
200
201
 
202
+ function setupPgbouncerSecret() {
203
+ # pgbouncer uses a k8s secret for the user access list which is in the form
204
+ # of => "user" "password" - this function will create the pgbouncer secret
205
+ # if it does not exist by pulling the password from the PG_PASSWORD secret
206
+ # managed by the Google Secret Manager service.
207
+ USERLIST_SECRET='pgbouncer-userlist-secret'
208
+ kubectl get secret $USERLIST_SECRET &> $DEVNULL
209
+ [[ $? -eq 0 ]] && return # already exists - bail
210
+
211
+ cat<<PGB_SECRET
212
+
213
+ `color y "Creatng $USERLIST_SECRET k8s secret from secret manager PG_PASSWORD secret..."`
214
+
215
+ PGB_SECRET
216
+ DECODED_PSQL_PASSWORD=$(gcloud secrets versions access latest --secret=PG_PASSWORD --project $GCP_PROJECT_ID)
217
+ exitOnError $? "Failed to fetch PG_PASSWORD from the secret manager"
218
+
219
+ kubectl create secret generic $USERLIST_SECRET --from-literal=userlist.txt="\"postgres\" \"$DECODED_PSQL_PASSWORD\""
220
+ exitOnError $? "Failed to create the $USERLIST_SECRET k8s secret"
221
+ }
222
+
201
223
  function doPlatormPreInstallChecks() {
202
224
  # This is where we handle platform specific things that need to be setup,
203
225
  # usuall once, and then promptly forgotten about.
@@ -1126,6 +1148,11 @@ CATBACKUP
1126
1148
  setupStackBuckets && exit 0
1127
1149
  ;;
1128
1150
 
1151
+ "pgbouncer")
1152
+ setupPgbouncerSecret
1153
+ bootstrapLocalSetup $SERVICE
1154
+ ;;
1155
+
1129
1156
  "postgres")
1130
1157
  bootstrapLocalSetup $SERVICE
1131
1158
  ;;
package/src/klog.sh CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/bin/bash
2
2
 
3
- [ -f overwhelm.yaml ] && [ -f package.json ] && npm run ahoy
3
+ overwhelm
4
4
 
5
5
  DTS="`date +\"%Y%m%d-%H%M%S\"`"
6
6
  PRETTY="pino-pretty -c -t 'HH:MM:ss.l' -i 'severity'"
@@ -1,5 +0,0 @@
1
- {
2
- "files.associations": {
3
- "*.yaml.ovh": "yaml"
4
- }
5
- }
package/src/.swo DELETED
Binary file