[stable/stolon] add prometheus service monitor (#18212)

* add service monitor

Signed-off-by: arjan.ligthart <arjan.ligthart@gmail.com>

* update chart version

Signed-off-by: arjan.ligthart <arjan.ligthart@gmail.com>

* improved explanation (including fix for max_connections)

Signed-off-by: arjan.ligthart <arjan.ligthart@gmail.com>

* avoid duplicate endpoints being scraped

Signed-off-by: arjan.ligthart <arjan.ligthart@gmail.com>

* remove hardcoded 8080 ports

Signed-off-by: arjan.ligthart <arjan.ligthart@gmail.com>
This commit is contained in:
aligthart
2019-12-01 22:51:04 -08:00
committed by Kubernetes Prow Robot
parent f709c524e7
commit 69db007e34
8 changed files with 68 additions and 4 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
apiVersion: v1
name: stolon
version: 1.4.1
version: 1.5.0
appVersion: 0.13.0
description: Stolon - PostgreSQL cloud native High Availability.
home: https://github.com/sorintlab/stolon
+4
View File
@@ -55,6 +55,10 @@ Kubernetes is the default store backend. `consul`, `etcdv2` or `etcdv3` can also
| `store.kubeResourceKind` | Kubernetes resource kind (only for kubernetes) | `configmap` |
| `pgParameters` | [`postgresql.conf`][pgconf] options used during cluster creation | `{}` |
| `ports` | Ports to expose on pods | `{"stolon":{"containerPort": 5432},"metrics":{"containerPort": 8080}}`|
| `serviceMonitor.enabled` | Creates a Prometheus serviceMonitor and service object | `false`|
| `serviceMonitor.namespace` | Set to use a different value than the release namespace for deploying the ServiceMonitor object | `nil` |
| `serviceMonitor.interval` | Set to use a different value than the default Prometheus scrape interval | `nil` |
| `serviceMonitor.scrapeTimeout` | Set to use a different value than the default Prometheus scrape timeout | `nil` |
| `job.autoCreateCluster` | Set to `false` to force-disable auto-cluster-creation which may clear pre-existing postgres db data | `true` |
| `job.autoUpdateClusterSpec` | Set to `false` to force-disable auto-cluster-spec-update | `true` |
| `clusterSpec` | Stolon cluster spec [reference](https://github.com/sorintlab/stolon/blob/master/doc/cluster_spec.md) | `{}` |
@@ -97,7 +97,7 @@ spec:
value: "/etc/secrets/stolon/pg_su_password"
{{ end }}
- name: STKEEPER_METRICS_LISTEN_ADDRESS
value: "0.0.0.0:8080"
value: "0.0.0.0:{{ .Values.ports.metrics.containerPort }}"
- name: STKEEPER_DEBUG
value: {{ .Values.debug | quote}}
{{- if .Values.keeper.extraEnv }}
@@ -0,0 +1,19 @@
{{- if .Values.serviceMonitor.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ template "stolon.fullname" . }}-metrics
labels:
app: {{ template "stolon.name" . }}
chart: {{ template "stolon.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
component: "all"
spec:
ports:
- name: metrics
port: {{ .Values.ports.metrics.containerPort }}
selector:
app: {{ template "stolon.name" . }}
release: {{ .Release.Name }}
{{- end }}
@@ -0,0 +1,31 @@
{{- if .Values.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "stolon.fullname" . }}
labels:
app: {{ template "stolon.name" . }}
chart: {{ template "stolon.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- if .Values.serviceMonitor.namespace }}
namespace: {{ .Values.serviceMonitor.namespace }}
{{- end }}
spec:
endpoints:
- targetPort: "metrics"
{{- if .Values.serviceMonitor.interval }}
interval: {{ .Values.serviceMonitor.interval }}
{{- end }}
{{- if .Values.serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ .Values.serviceMonitor.scrapeTimeout }}
{{- end }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
selector:
matchLabels:
app: {{ template "stolon.name" . }}
release: {{ .Release.Name }}
component: "all"
{{- end }}
@@ -58,7 +58,7 @@ spec:
- name: STPROXY_LISTEN_ADDRESS
value: {{ default "0.0.0.0" .Values.proxy.listenAddress | quote }}
- name: STPROXY_METRICS_LISTEN_ADDRESS
value: "0.0.0.0:8080"
value: "0.0.0.0:{{ .Values.ports.metrics.containerPort }}"
- name: STPROXY_DEBUG
value: {{ .Values.debug | quote}}
{{- if .Values.proxy.extraEnv }}
@@ -57,7 +57,7 @@ spec:
value: {{ .Values.store.endpoints | quote}}
{{- end }}
- name: STSENTINEL_METRICS_LISTEN_ADDRESS
value: "0.0.0.0:8080"
value: "0.0.0.0:{{ .Values.ports.metrics.containerPort }}"
- name: STSENTINEL_DEBUG
value: {{ .Values.debug | quote}}
{{- if .Values.sentinel.extraEnv }}
+10
View File
@@ -66,6 +66,16 @@ ports:
metrics:
containerPort: 8080
serviceMonitor:
# When set to true then use a ServiceMonitor to collect metrics
enabled: false
# Set the namespace the ServiceMonitor should be deployed to
# namespace: default
# Set how frequently Prometheus should scrape
# interval: 30s
# Set timeout for scrape
# scrapeTimeout: 10s
job:
autoCreateCluster: true
autoUpdateClusterSpec: true