Skip to content

Commit 771aa85

Browse files
committed
feat: add Prometheus metrics and ServiceMonitor support
Add custom Prometheus metrics for operator observability: - openvox_server_replicas_desired/ready per Server CR - openvox_certificate_expiry_timestamp_seconds for certs and CAs Helm chart changes: - metrics.enabled toggle (default: true, set false to disable) - metrics.port exposed in Deployment containerPorts - metrics Service for scraping - optional ServiceMonitor for Prometheus Operator Closes #33 Signed-off-by: Simon Lauger <simon@lauger.de>
1 parent 8771dfd commit 771aa85

12 files changed

Lines changed: 700 additions & 605 deletions

File tree

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
{
2-
"$schema": "https://json-schema.org/draft/2020-12/schema",
3-
"type": "object",
4-
"properties": {
5-
"database": {
6-
"description": "PostgreSQL database name.",
7-
"type": "string"
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"type": "object",
4+
"properties": {
5+
"database": {
6+
"description": "PostgreSQL database name.",
7+
"type": "string"
8+
},
9+
"instances": {
10+
"description": "Number of PostgreSQL instances.",
11+
"type": "integer",
12+
"minimum": 1
13+
},
14+
"postInitSQL": {
15+
"description": "Extra SQL statements to run after database creation (pg_trgm is always included).",
16+
"type": "array"
17+
},
18+
"storage": {
19+
"type": "object",
20+
"properties": {
21+
"size": {
22+
"description": "PVC size for each PostgreSQL instance.",
23+
"type": "string"
824
},
9-
"instances": {
10-
"description": "Number of PostgreSQL instances.",
11-
"type": "integer",
12-
"minimum": 1
13-
},
14-
"postInitSQL": {
15-
"description": "Extra SQL statements to run after database creation (pg_trgm is always included).",
16-
"type": "array"
17-
},
18-
"storage": {
19-
"type": "object",
20-
"properties": {
21-
"size": {
22-
"description": "PVC size for each PostgreSQL instance.",
23-
"type": "string"
24-
},
25-
"storageClass": {
26-
"description": "Storage class for PostgreSQL PVCs. Empty uses cluster default.",
27-
"type": "string"
28-
}
29-
}
25+
"storageClass": {
26+
"description": "Storage class for PostgreSQL PVCs. Empty uses cluster default.",
27+
"type": "string"
3028
}
29+
}
3130
}
31+
}
3232
}

charts/openvox-operator/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ To deploy a complete OpenVox stack after installing the operator, use the
4646
| image.tag | string | `"latest"` | Image tag. Ignored if digest is set. |
4747
| imagePullSecrets | list | `[]` | Image pull secrets for private registries. |
4848
| leaderElect | bool | `true` | Enable leader election for controller manager. |
49+
| metrics.enabled | bool | `true` | Enable the metrics endpoint. |
50+
| metrics.port | int | `8080` | Port for the metrics endpoint. |
51+
| metrics.service.enabled | bool | `true` | Create a Service for the metrics endpoint. |
52+
| metrics.serviceMonitor.enabled | bool | `false` | Create a Prometheus ServiceMonitor resource. |
53+
| metrics.serviceMonitor.interval | string | `"30s"` | Scrape interval for the ServiceMonitor. |
54+
| metrics.serviceMonitor.labels | object | `{}` | Additional labels for the ServiceMonitor. |
4955
| nodeSelector | object | `{}` | Node selector for pod scheduling. |
5056
| podAnnotations | object | `{}` | Annotations applied to the operator Pod template (e.g. for log collectors, Prometheus scraping, or forcing rollouts via a checksum annotation). |
5157
| replicaCount | int | `1` | Number of operator pod replicas. |

charts/openvox-operator/templates/deployment.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,20 @@ spec:
4949
{{- if not .Values.gatewayAPI.enabled }}
5050
- --enable-gateway-api=false
5151
{{- end }}
52+
{{- if .Values.metrics.enabled }}
53+
- --metrics-bind-address=:{{ .Values.metrics.port | default 8080 }}
54+
{{- else }}
55+
- --metrics-bind-address=0
56+
{{- end }}
5257
ports:
5358
- name: health
5459
containerPort: 8081
5560
protocol: TCP
61+
{{- if .Values.metrics.enabled }}
62+
- name: metrics
63+
containerPort: {{ .Values.metrics.port | default 8080 }}
64+
protocol: TCP
65+
{{- end }}
5666
{{- if .Values.webhook.enabled }}
5767
- name: webhook
5868
containerPort: {{ .Values.webhook.port | default 9443 }}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{{- if and .Values.metrics.enabled .Values.metrics.service.enabled }}
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: {{ include "openvox-operator.fullname" . }}-metrics
6+
namespace: {{ .Release.Namespace }}
7+
labels:
8+
{{- include "openvox-operator.labels" . | nindent 4 }}
9+
spec:
10+
type: ClusterIP
11+
ports:
12+
- name: metrics
13+
port: {{ .Values.metrics.port | default 8080 }}
14+
targetPort: metrics
15+
protocol: TCP
16+
selector:
17+
{{- include "openvox-operator.selectorLabels" . | nindent 4 }}
18+
{{- end }}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{{- if and .Values.metrics.enabled .Values.metrics.serviceMonitor.enabled }}
2+
apiVersion: monitoring.coreos.com/v1
3+
kind: ServiceMonitor
4+
metadata:
5+
name: {{ include "openvox-operator.fullname" . }}
6+
namespace: {{ .Release.Namespace }}
7+
labels:
8+
{{- include "openvox-operator.labels" . | nindent 4 }}
9+
{{- with .Values.metrics.serviceMonitor.labels }}
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
12+
spec:
13+
selector:
14+
matchLabels:
15+
{{- include "openvox-operator.selectorLabels" . | nindent 6 }}
16+
endpoints:
17+
- port: metrics
18+
interval: {{ .Values.metrics.serviceMonitor.interval | default "30s" }}
19+
{{- end }}

0 commit comments

Comments
 (0)