add prometheus-operator servicemonitor support for helm-exporter (#12024)

Signed-off-by: Alex Snast <alexsn@fb.com>
This commit is contained in:
Alex Snast
2019-03-10 21:35:25 -07:00
committed by Kubernetes Prow Robot
parent 641b216a13
commit 59572d16f3
5 changed files with 46 additions and 1 deletions
+1 -1
View File
@@ -2,7 +2,7 @@ apiVersion: v1
appVersion: "0.1.0"
description: Exports helm release stats to prometheus
name: helm-exporter
version: 0.1.0
version: 0.2.0
home: https://github.com/sstarcher/helm-exporter
sources:
- https://github.com/sstarcher/helm-exporter
+6
View File
@@ -12,6 +12,8 @@ $ helm install stable/helm-exporter
This chart bootstraps a [helm-exporter](https://github.com/sstarcher/helm-exporter) deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.
The chart comes with a ServiceMonitor for use with the [Prometheus Operator](https://github.com/helm/charts/tree/master/stable/prometheus-operator).
## Installing the Chart
To install the chart with the release name `my-release`:
@@ -45,6 +47,10 @@ Parameter | Description | Default
`nodeSelector` | node labels for pod assignment | `{}`
`resources` | pod resource requests & limits | `{}`
`tolerations` | List of node taints to tolerate (requires Kubernetes 1.6+) | `[]`
`serviceMonitor.create` | Set to true if using the Prometheus Operator | `false`
`serviceMonitor.interval` | Interval at which metrics should be scraped | ``
`serviceMonitor.namespace` | The namespace where the Prometheus Operator is deployed | ``
`serviceMonitor.additionalLabels` | Additional labels to add to the ServiceMonitor | `{}`
```console
$ helm install stable/helm-exporter --name my-release
@@ -7,8 +7,10 @@ metadata:
helm.sh/chart: {{ include "helm-exporter.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- if not .Values.serviceMonitor.create }}
annotations:
prometheus.io/scrape: "true"
{{- end }}
spec:
type: ClusterIP
clusterIP: None
@@ -0,0 +1,30 @@
{{ if .Values.serviceMonitor.create }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "helm-exporter.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "helm-exporter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "helm-exporter.chart" . }}
{{- range $key, $value := .Values.serviceMonitor.additionalLabels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- with .Values.serviceMonitor.namespace }}
namespace: {{ . }}
{{- end }}
spec:
endpoints:
- port: metrics
{{- with .Values.serviceMonitor.interval }}
interval: {{ . }}
{{- end }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "helm-exporter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
+7
View File
@@ -26,3 +26,10 @@ serviceAccount:
# The name of the ServiceAccount to use.
# If not set and create is true, a name is generated using the fullname template
name:
serviceMonitor:
# Specifies whether a ServiceMonitor should be created
create: false
interval:
namespace:
additionalLabels: {}