Skip to content

Commit 53f6af7

Browse files
committed
chore(postgresql-cluster): add metrics
1 parent 3249716 commit 53f6af7

4 files changed

Lines changed: 54 additions & 5 deletions

File tree

addons/postgresql-cluster/15/chart/postgresql/Chart.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ keywords:
1717
- sql
1818
- replication
1919
- cluster
20+
- patroni
2021
maintainers:
2122
- email: zhang.eamon@hotmail.com
2223
name: zhangeamon
2324
name: postgresql
2425
sources:
2526
- https://github.com/drycc-addons/
2627
- https://www.postgresql.org/
27-
version: 15.4.1
28+
version: 15.3.1
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{{- if .Values.metrics.enabled }}
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: {{ printf "%s-metrics" (include "patroni.fullname" .) }}
6+
namespace: {{ .Release.Namespace | quote }}
7+
labels: {{- include "common.labels.standard" . | nindent 4 }}
8+
app.kubernetes.io/component: metrics
9+
{{- if .Values.commonLabels }}
10+
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
11+
{{- end }}
12+
annotations:
13+
{{- if .Values.commonAnnotations }}
14+
{{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
15+
{{- end }}
16+
{{- if .Values.metrics.service.annotations }}
17+
{{- include "common.tplvalues.render" ( dict "value" .Values.metrics.service.annotations "context" $ ) | nindent 4 }}
18+
{{- end }}
19+
spec:
20+
type: ClusterIP
21+
sessionAffinity: {{ .Values.metrics.service.sessionAffinity }}
22+
{{- if .Values.metrics.service.clusterIP }}
23+
clusterIP: {{ .Values.metrics.service.clusterIP }}
24+
{{- end }}
25+
ports:
26+
- name: http-metrics
27+
port: {{ .Values.metrics.service.ports.metrics }}
28+
targetPort: http-metrics
29+
selector: {{- include "common.labels.matchLabels" . | nindent 4 }}
30+
app.kubernetes.io/component: patroni
31+
{{- end }}

addons/postgresql-cluster/15/chart/postgresql/templates/statefulset.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ kind: StatefulSet
33
metadata:
44
name: {{ template "patroni.fullname" . }}
55
namespace: {{ include "common.names.namespace" . | quote }}
6-
labels:
6+
labels: {{- include "common.labels.standard" . | nindent 4 }}
7+
app.kubernetes.io/component: patroni
78
app: {{ template "patroni.fullname" . }}
89
chart: {{ template "patroni.chart" . }}
910
release: {{ .Release.Name }}
@@ -13,14 +14,16 @@ spec:
1314
serviceName: {{ template "patroni.fullname" . }}
1415
replicas: {{ .Values.replicaCount }}
1516
selector:
16-
matchLabels:
17+
matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }}
18+
app.kubernetes.io/component: patroni
1719
app: {{ template "patroni.fullname" . }}
1820
release: {{ .Release.Name }}
1921
cluster-name: {{ template "patroni.fullname" . }}
2022
template:
2123
metadata:
2224
name: {{ template "patroni.fullname" . }}
23-
labels:
25+
labels: {{- include "common.labels.standard" . | nindent 8 }}
26+
app.kubernetes.io/component: patroni
2427
app: {{ template "patroni.fullname" . }}
2528
release: {{ .Release.Name }}
2629
cluster-name: {{ template "patroni.fullname" . }}

addons/postgresql-cluster/15/chart/postgresql/values.yaml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,21 @@ metrics:
133133
## usage: "GAUGE"
134134
## description: "Size of the database in bytes"
135135
##
136+
service:
137+
ports:
138+
metrics: 9187
139+
clusterIP: ""
140+
## @param metrics.service.sessionAffinity Control where client requests go, to the same pod or round-robin
141+
## Values: ClientIP or None
142+
## ref: https://kubernetes.io/docs/user-guide/services/
143+
##
144+
sessionAffinity: None
145+
## @param metrics.service.annotations [object] Annotations for Prometheus to auto-discover the metrics endpoint
146+
##
147+
annotations:
148+
prometheus.io/scrape: "true"
149+
prometheus.io/port: "{{ .Values.metrics.service.ports.metrics }}"
150+
136151
customMetrics: {}
137152
containerPort: 9187
138153
containerSecurityContext:
@@ -142,7 +157,6 @@ metrics:
142157
customLivenessProbe: {}
143158
customReadinessProbe:
144159
enabled: true
145-
service: port
146160
resources: {}
147161
walE:
148162
# Specifies whether Wal-E should be enabled

0 commit comments

Comments
 (0)