Skip to content

Commit 6b2c76c

Browse files
committed
feat(cluster): Add tls management for monitoring
Signed-off-by: Erwan SEITE <925205+wanix@users.noreply.github.com>
1 parent ee3aad8 commit 6b2c76c

9 files changed

Lines changed: 41 additions & 3 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ charts/**/charts/*.tgz
2020
.idea
2121
*.swp
2222
*.swo
23+
.vscode
2324
*~
2425

2526
# macOS
2627
.DS_Store
28+
29+
# Tooling for local development
30+
mise.local.toml

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
[![Stack Overflow](https://img.shields.io/badge/stackoverflow-cloudnative--pg-blue?logo=stackoverflow&logoColor=%23F48024&link=https%3A%2F%2Fstackoverflow.com%2Fquestions%2Ftagged%2Fcloudnative-pg)][stackoverflow]
44
[![GitHub License](https://img.shields.io/github/license/cloudnative-pg/charts)][license]
55

6-
76
[![GitHub Release](https://img.shields.io/github/v/release/cloudnative-pg/charts?filter=cloudnative-pg-*)](https://github.com/cloudnative-pg/charts/tree/main/charts/cloudnative-pg)
87
[![GitHub Release](https://img.shields.io/github/v/release/cloudnative-pg/charts?filter=cluster-*)](https://github.com/cloudnative-pg/charts/tree/main/charts/cluster)
98

10-
119
## Operator chart
1210

1311
Helm chart to install the
@@ -16,6 +14,7 @@ Helm chart to install the
1614
running in private, public, or hybrid cloud environments.
1715

1816
**NOTE**: supports only the latest point release of the CloudNativePG operator.
17+
1918
```console
2019
helm repo add cnpg https://cloudnative-pg.github.io/charts
2120
helm upgrade --install cnpg \

charts/cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ Kubernetes: `>=1.29.0-0`
180180
| cluster.monitoring.podMonitor.relabelings | list | `[]` | The list of relabelings for the PodMonitor. Applied to samples before scraping. |
181181
| cluster.monitoring.prometheusRule.enabled | bool | `true` | Whether to enable the PrometheusRule automated alerts |
182182
| cluster.monitoring.prometheusRule.excludeRules | list | `[]` | Exclude specified rules |
183+
| cluster.monitoring.tls.enabled | bool | `false` | Whether to enable tls on the metrics port. |
183184
| cluster.podSecurityContext | object | `{}` | Configure the Pod Security Context. See: https://cloudnative-pg.io/documentation/preview/security/ |
184185
| cluster.postgresGID | int | `-1` | The GID of the postgres user inside the image, defaults to 26 |
185186
| cluster.postgresUID | int | `-1` | The UID of the postgres user inside the image, defaults to 26 |

charts/cluster/templates/cluster.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ spec:
138138
{{- toYaml . | nindent 6 }}
139139
{{ end }}
140140
{{- end }}
141+
tls:
142+
enabled: {{ .Values.cluster.monitoring.tls.enabled }}
141143
{{ include "cluster.bootstrap" . | nindent 2 }}
142144
{{ include "cluster.externalClusters" . | nindent 2 }}
143145
{{ include "cluster.backup" . | nindent 2 }}

charts/cluster/templates/podmonitor-cluster.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ spec:
2121
cnpg.io/podRole: instance
2222
podMetricsEndpoints:
2323
- port: metrics
24+
{{- if .Values.cluster.monitoring.tls.enabled }}
25+
scheme: https
26+
tlsConfig:
27+
ca:
28+
secret:
29+
name: {{ include "cluster.fullname" . }}-ca
30+
key: ca.crt
31+
serverName: {{ include "cluster.fullname" . }}-rw
32+
{{- end }}
2433
{{- with .Values.cluster.monitoring.podMonitor.relabelings }}
2534
relabelings:
2635
{{- toYaml . | nindent 8 }}

charts/cluster/test/monitoring/01-monitoring_cluster-assert.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ spec:
1212
size: 256Mi
1313
storageClass: standard
1414
monitoring:
15+
tls:
16+
enabled: true
1517
disableDefaultQueries: true
1618
customQueriesConfigMap:
1719
- name: monitoring-cluster-monitoring
@@ -31,7 +33,15 @@ spec:
3133
cnpg.io/cluster: monitoring-cluster
3234
cnpg.io/podRole: instance
3335
podMetricsEndpoints:
34-
- relabelings:
36+
- port: metrics
37+
scheme: https
38+
tlsConfig:
39+
ca:
40+
secret:
41+
name: monitoring-cluster-ca
42+
key: ca.crt
43+
serverName: monitoring-cluster-rw
44+
relabelings:
3545
- targetLabel: environment
3646
replacement: test
3747
- targetLabel: team

charts/cluster/test/monitoring/01-monitoring_cluster.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ cluster:
88
monitoring:
99
enabled: true
1010
disableDefaultQueries: true
11+
tls:
12+
enabled: true
1113
customQueries:
1214
- name: "pg_cache_hit_ratio"
1315
query: "SELECT current_database() as datname, sum(heap_blks_hit) / (sum(heap_blks_hit) + sum(heap_blks_read)) as ratio FROM pg_statio_user_tables;"

charts/cluster/values.schema.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,14 @@
278278
"type": "array"
279279
}
280280
}
281+
},
282+
"tls": {
283+
"type": "object",
284+
"properties": {
285+
"enabled": {
286+
"type": "boolean"
287+
}
288+
}
281289
}
282290
}
283291
},

charts/cluster/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,9 @@ cluster:
349349
customQueriesSecret: []
350350
# - name: custom-queries-secret
351351
# key: custom-queries
352+
tls:
353+
# -- Whether to enable tls on the metrics port.
354+
enabled: false
352355

353356
postgresql:
354357
# -- PostgreSQL configuration options (postgresql.conf)

0 commit comments

Comments
 (0)