Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
155 changes: 155 additions & 0 deletions charts/pgbouncer/templates/daemonset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
{{- if eq .Values.kind "DaemonSet" }}
apiVersion: {{ template "deployment.apiVersion" . }}
kind: DaemonSet
metadata:
name: {{ include "pgbouncer.fullname" . }}
labels:
{{- include "pgbouncer.labels" . | nindent 4 }}
spec:
revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
{{ if .Values.minReadySeconds -}}
minReadySeconds: {{ .Values.minReadySeconds }}
{{ end -}}
selector:
matchLabels:
{{- include "pgbouncer.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "pgbouncer.selectorLabels" . | nindent 8 }}
{{- if .Values.podLabels }}
{{- range $key, $value := .Values.podLabels }}
{{ $key }}: {{ $value | quote }}
{{- end -}}
{{- end }}
annotations:
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
{{- if .Values.pgbouncerExporter.enabled }}
prometheus.io/scrape: "true"
prometheus.io/port: "{{ .Values.pgbouncerExporter.port }}"
prometheus.io/path: "/metrics"
{{- end }}
{{- range $key, $value := .Values.podAnnotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
spec:
serviceAccountName: {{ template "pgbouncer.serviceAccountName" . }}
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
{{ if .Values.nodeSelector -}}
nodeSelector: {{ toYaml .Values.nodeSelector | trimSuffix "\n" | nindent 8 }}
{{ end -}}
{{ if .Values.tolerations -}}
tolerations: {{ toYaml .Values.tolerations | trimSuffix "\n" | nindent 6 }}
{{ end -}}
{{ if .Values.affinity -}}
affinity: {{ toYaml .Values.affinity | trimSuffix "\n" | nindent 8 }}
{{ end -}}
{{ if .Values.priorityClassName -}}
priorityClassName: {{ .Values.priorityClassName }}
{{ end -}}
{{ if .Values.runtimeClassName -}}
runtimeClassName: {{ .Values.runtimeClassName }}
{{ end -}}
{{ if len .Values.imagePullSecrets -}}
imagePullSecrets: {{ toYaml .Values.imagePullSecrets | trimSuffix "\n" | nindent 6 }}
{{ end -}}
{{ if .Values.extraInitContainers -}}
initContainers: {{ toYaml .Values.extraInitContainers | trimSuffix "\n" | nindent 6 }}
{{ end -}}
containers:
- name: pgbouncer
image: {{ template "pgbouncer.image" . }}
{{- if .Values.command }}
command:
{{ toYaml .Values.command | nindent 10 }}
{{- end }}
{{- if .Values.args }}
args:
{{ toYaml .Values.args | nindent 10 }}
{{- end }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- if .Values.lifecycle }}
lifecycle: {{ toYaml .Values.lifecycle | trimSuffix "\n" | nindent 10 }}
{{- end }}
{{- if .Values.extraEnvs }}
env:
{{ toYaml .Values.extraEnvs | trimSuffix "\n" | nindent 10 }}
{{- end }}
ports:
- name: psql
containerPort: 5432
protocol: TCP
readinessProbe:
tcpSocket:
port: 5432
initialDelaySeconds: 10
periodSeconds: 5
livenessProbe:
tcpSocket:
port: 5432
initialDelaySeconds: 60
periodSeconds: 10
{{- if .Values.resources }}
resources: {{ toYaml .Values.resources | trimSuffix "\n" | nindent 10 }}
{{- end }}
{{- if .Values.securityContext }}
securityContext: {{ toYaml .Values.securityContext | trimSuffix "\n" | nindent 10 }}
{{- end }}
volumeMounts:
- name: tmp
mountPath: /tmp
- name: config
mountPath: /etc/pgbouncer/
- name: userlist
mountPath: /etc/userlist/
{{- if .Values.extraVolumeMounts -}}
{{ toYaml .Values.extraVolumeMounts | trimSuffix "\n" | nindent 8 }}
{{- end }}
{{- if .Values.pgbouncerExporter.enabled }}
- name: exporter
image: {{ template "pgbouncer.exporterImage" . }}
imagePullPolicy: {{ .Values.pgbouncerExporter.image.pullPolicy }}
args:
- --web.listen-address=:{{ .Values.pgbouncerExporter.port }}
- --web.telemetry-path=/metrics
- --log.level={{ .Values.pgbouncerExporter.log.level }}
- --log.format={{ .Values.pgbouncerExporter.log.format }}
- --pgBouncer.connectionString=postgres://$(PGBOUNCER_USER):$(PGBOUNCER_PASS)@127.0.0.1:5432/pgbouncer?sslmode=disable&connect_timeout=10
env:
- name: PGBOUNCER_USER
valueFrom:
secretKeyRef:
name: {{ .Values.config.existingAdminSecret | default (printf "%s-secret" (include "pgbouncer.fullname" .)) }}
key: {{ .Values.config.adminUserKey | default "adminUser" }}
- name: PGBOUNCER_PASS
valueFrom:
secretKeyRef:
name: {{ .Values.config.existingAdminSecret | default (printf "%s-secret" (include "pgbouncer.fullname" .)) }}
key: {{ .Values.config.adminPasswordKey | default "adminPassword" }}
{{- if .Values.pgbouncerExporter.resources }}
resources: {{ toYaml .Values.pgbouncerExporter.resources | trimSuffix "\n" | nindent 10 }}
{{- end }}
{{- if .Values.securityContext }}
securityContext: {{ toYaml .Values.pgbouncerExporter.securityContext | trimSuffix "\n" | nindent 10 }}
{{- end }}
ports:
- name: exporter
containerPort: {{ .Values.pgbouncerExporter.port }}
protocol: TCP
{{- end }}
{{ if .Values.extraContainers -}}
{{ toYaml .Values.extraContainers | trimSuffix "\n" | indent 6 | trimPrefix " " }}
{{ end -}}
volumes:
- name: tmp
emptyDir: {}
- name: config
configMap:
name: {{ template "pgbouncer.fullname" . }}-configmap
- name: userlist
secret:
secretName: {{ .Values.config.existingUserlistSecret | default (printf "%s-userlist-secret" (include "pgbouncer.fullname" .)) }}
{{- if .Values.extraVolumes -}}
{{ toYaml .Values.extraVolumes | trimSuffix "\n" | nindent 6 }}
{{ end -}}
{{- end }}
2 changes: 2 additions & 0 deletions charts/pgbouncer/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if eq .Values.kind "Deployment" }}
apiVersion: {{ template "deployment.apiVersion" . }}
kind: Deployment
metadata:
Expand Down Expand Up @@ -155,3 +156,4 @@ spec:
{{- if .Values.extraVolumes -}}
{{ toYaml .Values.extraVolumes | trimSuffix "\n" | nindent 6 }}
{{ end -}}
{{- end }}
1 change: 1 addition & 0 deletions charts/pgbouncer/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ metadata:
{{- include "pgbouncer.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
internalTrafficPolicy: {{ .Values.service.internalTrafficPolicy | default "Cluster" }}
ports:
- port: {{ .Values.service.port }}
targetPort: psql
Expand Down
3 changes: 3 additions & 0 deletions charts/pgbouncer/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ fullnameOverride: ""
# -- Number of replicas for the PgBouncer Deployment (see Kubernetes docs for Deployments).
replicaCount: 1

kind: Deployment

# -- The update strategy to apply to the Deployment (e.g. Recreate or RollingUpdate).
updateStrategy: {}
# type: Recreate
Expand Down Expand Up @@ -51,6 +53,7 @@ service:
type: ClusterIP
# -- The service port for PgBouncer.
port: 5432
internalTrafficPolicy: Cluster

# -- Additional labels to add to each PgBouncer pod.
podLabels: {}
Expand Down
Loading