Skip to content

Commit 37ff723

Browse files
feat(monitoring): disable PodMonitor by default and add PodMonitor template
Signed-off-by: Nelson Alfonso <[email protected]>
1 parent 92e6c3d commit 37ff723

File tree

2 files changed

+49
-19
lines changed

2 files changed

+49
-19
lines changed

charts/cluster/templates/cluster.yaml

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ spec:
116116
{{- end }}
117117

118118
monitoring:
119-
enablePodMonitor: {{ and .Values.cluster.monitoring.enabled .Values.cluster.monitoring.podMonitor.enabled }}
119+
enablePodMonitor: false
120120
disableDefaultQueries: {{ .Values.cluster.monitoring.disableDefaultQueries }}
121121
{{- if not (empty .Values.cluster.monitoring.customQueries) }}
122122
customQueriesConfigMap:
@@ -129,23 +129,5 @@ spec:
129129
{{- toYaml . | nindent 6 }}
130130
{{ end }}
131131
{{- end }}
132-
{{- if not (empty .Values.cluster.monitoring.podMonitor.relabelings) }}
133-
{{- with .Values.cluster.monitoring.podMonitor.relabelings }}
134-
podMonitorRelabelings:
135-
{{- toYaml . | nindent 6 }}
136-
{{ end }}
137-
{{- end }}
138-
{{- if not (empty .Values.cluster.monitoring.podMonitor.metricRelabelings) }}
139-
{{- with .Values.cluster.monitoring.podMonitor.metricRelabelings }}
140-
podMonitorMetricRelabelings:
141-
{{- toYaml . | nindent 6 }}
142-
{{ end }}
143-
{{- end }}
144-
{{- if not (empty .Values.cluster.monitoring.podMonitor.labels) }}
145-
{{- with .Values.cluster.monitoring.podMonitor.labels }}
146-
podMonitorAdditionalLabels:
147-
{{- toYaml . | nindent 6 }}
148-
{{ end }}
149-
{{- end }}
150132
{{ include "cluster.bootstrap" . | nindent 2 }}
151133
{{ include "cluster.backup" . | nindent 2 }}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#
2+
# Copyright © contributors to CloudNativePG, established as
3+
# CloudNativePG a Series of LF Projects, LLC.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
# SPDX-License-Identifier: Apache-2.0
18+
#
19+
{{- if and .Values.cluster.monitoring.enabled .Values.cluster.monitoring.podMonitor.enabled }}
20+
apiVersion: monitoring.coreos.com/v1
21+
kind: PodMonitor
22+
metadata:
23+
name: {{ include "cluster.fullname" . }}
24+
namespace: {{ include "cluster.namespace" . }}
25+
labels:
26+
{{- include "cluster.labels" . | nindent 4 }}
27+
{{- with .Values.cluster.monitoring.podMonitor.labels }}
28+
{{- toYaml . | nindent 4 }}
29+
{{- end }}
30+
{{- with .Values.cluster.annotations }}
31+
annotations:
32+
{{- toYaml . | nindent 4 }}
33+
{{- end }}
34+
spec:
35+
selector:
36+
matchLabels:
37+
cnpg.io/cluster: {{ include "cluster.fullname" . }}
38+
podMetricsEndpoints:
39+
- port: metrics
40+
{{- with .Values.cluster.monitoring.podMonitor.relabelings }}
41+
relabelings:
42+
{{- toYaml . | nindent 8 }}
43+
{{- end }}
44+
{{- with .Values.cluster.monitoring.podMonitor.metricRelabelings }}
45+
metricRelabelings:
46+
{{- toYaml . | nindent 8 }}
47+
{{- end }}
48+
{{- end }}

0 commit comments

Comments
 (0)