Skip to content

Commit 115b667

Browse files
committed
feat(pgbouncerExporter): add imagePullSecrets support with global deduplication, refs #18
1 parent 78b268b commit 115b667

File tree

4 files changed

+29
-5
lines changed

4 files changed

+29
-5
lines changed

charts/pgbouncer/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: pgbouncer
33
description: A Helm chart for deploying PgBouncer, a PostgreSQL connection pooler, on Kubernetes
44
type: application
5-
version: 2.6.1
5+
version: 2.7.0
66
appVersion: 1.24.1
77
kubeVersion: ">= 1.22.0-0"
88
icon: https://icoretech.github.io/helm/charts/pgbouncer/logo.png

charts/pgbouncer/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ The following table lists the configurable parameters of the PgBouncer chart and
6666
| pgbouncerExporter.image.registry | string | `""` | Exporter image registry |
6767
| pgbouncerExporter.image.repository | string | `"prometheuscommunity/pgbouncer-exporter"` | Exporter image repository |
6868
| pgbouncerExporter.image.tag | string | `"v0.10.2"` | Exporter image tag |
69+
| pgbouncerExporter.imagePullSecrets | list | `[]` | Array of imagePullSecrets to use for pulling the pgbouncer-exporter image. |
6970
| pgbouncerExporter.log.format | string | `"logfmt"` | Exporter log format (logfmt or json) |
7071
| pgbouncerExporter.log.level | string | `"info"` | Exporter log level (debug, info, warn, error) |
7172
| pgbouncerExporter.podMonitor | bool | `false` | Whether to create a PodMonitor for scraping metrics (Prometheus Operator). |

charts/pgbouncer/templates/deployment.yaml

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,30 @@ spec:
5454
{{ if .Values.runtimeClassName -}}
5555
runtimeClassName: {{ .Values.runtimeClassName }}
5656
{{ end -}}
57-
{{ if len .Values.imagePullSecrets -}}
58-
imagePullSecrets: {{ toYaml .Values.imagePullSecrets | trimSuffix "\n" | nindent 6 }}
59-
{{ end -}}
57+
58+
{{- /* Combine global and exporter-specific imagePullSecrets */}}
59+
{{- $allPullSecrets := .Values.imagePullSecrets | default list -}}
60+
{{- if and .Values.pgbouncerExporter.enabled .Values.pgbouncerExporter.imagePullSecrets -}}
61+
{{- $exporterPullSecrets := .Values.pgbouncerExporter.imagePullSecrets | default list -}}
62+
{{- $allPullSecrets = concat $allPullSecrets $exporterPullSecrets -}}
63+
{{- end -}}
64+
65+
{{- /* De-duplicate secrets by name */}}
66+
{{- $uniquePullSecrets := list -}}
67+
{{- $seenSecretNames := dict -}}
68+
{{- range $allPullSecrets -}}
69+
{{- if .name -}} {{/* Ensure item is a map with a 'name' key to avoid errors with malformed entries */}}
70+
{{- if not (hasKey $seenSecretNames .name) -}}
71+
{{- $uniquePullSecrets = append $uniquePullSecrets . -}}
72+
{{- $_ := set $seenSecretNames .name true -}}
73+
{{- end -}}
74+
{{- end -}}
75+
{{- end -}}
76+
77+
{{- if $uniquePullSecrets }}
78+
imagePullSecrets: {{- toYaml $uniquePullSecrets | nindent 8 }}
79+
{{- end }}
80+
6081
{{ if .Values.extraInitContainers -}}
6182
initContainers: {{ toYaml .Values.extraInitContainers | trimSuffix "\n" | nindent 6 }}
6283
{{ end -}}
@@ -156,4 +177,4 @@ spec:
156177
{{- if .Values.extraVolumes -}}
157178
{{ toYaml .Values.extraVolumes | trimSuffix "\n" | nindent 6 }}
158179
{{ end -}}
159-
{{- end }}
180+
{{- end }}

charts/pgbouncer/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ extraVolumes: []
221221
pgbouncerExporter:
222222
# -- Enable or disable the PgBouncer exporter sidecar container.
223223
enabled: false
224+
# -- Array of imagePullSecrets to use for pulling the pgbouncer-exporter image.
225+
imagePullSecrets: []
224226
# -- Whether to create a PodMonitor for scraping metrics (Prometheus Operator).
225227
podMonitor: false
226228
# -- The container port for the exporter.

0 commit comments

Comments
 (0)