From 1947fa46fe94e73d02947446bd59e87b7beb1db7 Mon Sep 17 00:00:00 2001 From: Barry O'Neill Date: Thu, 22 Nov 2018 10:06:03 -0500 Subject: [PATCH] add metrics servicemonitor to stable/redis (#9281) * Add prometheus ServiceMonitor for metrics Signed-off-by: Barry O'Neill * bump chart version Signed-off-by: Barry O'Neill * PR Feedback Signed-off-by: Barry O'Neill * Make scraping interval optional Signed-off-by: Barry O'Neill * Accept version change suggestion Co-Authored-By: barryoneill Signed-off-by: Barry O'Neill --- stable/redis/Chart.yaml | 2 +- stable/redis/README.md | 4 +++ .../redis/templates/metrics-prometheus.yaml | 28 +++++++++++++++++++ stable/redis/values-production.yaml | 12 ++++++++ stable/redis/values.yaml | 12 ++++++++ 5 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 stable/redis/templates/metrics-prometheus.yaml diff --git a/stable/redis/Chart.yaml b/stable/redis/Chart.yaml index f11ed45bba..9a493d88b8 100644 --- a/stable/redis/Chart.yaml +++ b/stable/redis/Chart.yaml @@ -1,5 +1,5 @@ name: redis -version: 4.2.10 +version: 4.3.0 appVersion: 4.0.11 description: Open source, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets. keywords: diff --git a/stable/redis/README.md b/stable/redis/README.md index a14da72697..d7e88295a4 100644 --- a/stable/redis/README.md +++ b/stable/redis/README.md @@ -109,6 +109,10 @@ The following table lists the configurable parameters of the Redis chart and the | `metrics.service.annotations` | Annotations for the services to monitor (redis master and redis slave service) | {} | | `metrics.service.loadBalancerIP` | loadBalancerIP if redis metrics service type is `LoadBalancer` | `nil` | | `metrics.resources` | Exporter resource requests/limit | Memory: `256Mi`, CPU: `100m` | +| `metrics.serviceMonitor.enabled` | if `true`, creates a Prometheus Operator ServiceMonitor (also requires `metrics.enabled` to be `true`) | `false` | +| `metrics.serviceMonitor.namespace` | Namespace which Prometheus is running in | `monitoring` | +| `metrics.serviceMonitor.interval` | How frequently to scrape metrics (use by default, falling back to Prometheus' default) | `nil` | +| `metrics.serviceMonitor.selector` | Default to kube-prometheus install (CoreOS recommended), but should be set according to Prometheus install | `{ prometheus: kube-prometheus }` | | `persistence.existingClaim` | Provide an existing PersistentVolumeClaim | `nil` | | `master.persistence.enabled` | Use a PVC to persist data (master node) | `true` | | `master.persistence.path` | Path to mount the volume at, to use other images | `/bitnami` | diff --git a/stable/redis/templates/metrics-prometheus.yaml b/stable/redis/templates/metrics-prometheus.yaml new file mode 100644 index 0000000000..369aa2776d --- /dev/null +++ b/stable/redis/templates/metrics-prometheus.yaml @@ -0,0 +1,28 @@ +{{- if and (.Values.metrics.enabled) (.Values.metrics.serviceMonitor.enabled) }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ template "redis.fullname" . }} + {{- if .Values.metrics.serviceMonitor.namespace }} + namespace: {{ .Values.metrics.serviceMonitor.namespace }} + {{- end }} + labels: + app: {{ template "redis.name" . }} + chart: {{ template "redis.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + {{- range $key, $value := .Values.metrics.serviceMonitor.selector }} + {{ $key }}: {{ $value | quote }} + {{- end }} +spec: + endpoints: + - port: metrics + {{- if .Values.metrics.serviceMonitor.interval }} + interval: {{ .Values.metrics.serviceMonitor.interval }} + {{- end }} + selector: + matchLabels: + app: {{ template "redis.name" . }} + namespaceSelector: + any: true +{{- end -}} diff --git a/stable/redis/values-production.yaml b/stable/redis/values-production.yaml index 94d56e4f76..3d63bb7d0c 100644 --- a/stable/redis/values-production.yaml +++ b/stable/redis/values-production.yaml @@ -337,6 +337,18 @@ metrics: # podAnnotations: {} # podLabels: {} + # Enable this if you're using https://github.com/coreos/prometheus-operator + serviceMonitor: + enabled: false + namespace: monitoring + # fallback to the prometheus default unless specified + # interval: 10s + ## Defaults to what's used if you follow CoreOS [Prometheus Install Instructions](https://github.com/helm/charts/tree/master/stable/prometheus-operator#tldr) + ## [Prometheus Selector Label](https://github.com/helm/charts/tree/master/stable/prometheus-operator#prometheus-operator-1) + ## [Kube Prometheus Selector Label](https://github.com/helm/charts/tree/master/stable/prometheus-operator#exporters) + selector: + prometheus: kube-prometheus + ## ## Init containers parameters: ## volumePermissions: Change the owner of the persist volume mountpoint to RunAsUser:fsGroup diff --git a/stable/redis/values.yaml b/stable/redis/values.yaml index 0ceb1f17a0..b1ef804ccb 100644 --- a/stable/redis/values.yaml +++ b/stable/redis/values.yaml @@ -341,6 +341,18 @@ metrics: # podAnnotations: {} # podLabels: {} + # Enable this if you're using https://github.com/coreos/prometheus-operator + serviceMonitor: + enabled: false + namespace: monitoring + # fallback to the prometheus default unless specified + # interval: 10s + ## Defaults to what's used if you follow CoreOS [Prometheus Install Instructions](https://github.com/helm/charts/tree/master/stable/prometheus-operator#tldr) + ## [Prometheus Selector Label](https://github.com/helm/charts/tree/master/stable/prometheus-operator#prometheus-operator-1) + ## [Kube Prometheus Selector Label](https://github.com/helm/charts/tree/master/stable/prometheus-operator#exporters) + selector: + prometheus: kube-prometheus + ## ## Init containers parameters: ## volumePermissions: Change the owner of the persist volume mountpoint to RunAsUser:fsGroup