Skip to content

Commit

Permalink
Merge pull request #19 from simonostendorf/feat/chart/servicemonitor-…
Browse files Browse the repository at this point in the history
…dashboard

feat(chart): add servicemonitor and dashboard
  • Loading branch information
wacken89 authored Jun 28, 2024
2 parents c8d8034 + d8e7bcd commit 21b6294
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 0 deletions.
1 change: 1 addition & 0 deletions deploy/helm-chart/src/dashboards/dashboard.json
19 changes: 19 additions & 0 deletions deploy/helm-chart/templates/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{{- if and .Values.rbac.enabled (not (eq .Values.rbac.name "")) }}
apiVersion: rbac.authorization.k8s.io/v1
kind: {{ .Values.rbac.type }}Binding
metadata:
labels:
{{- include "exporter.labels" . | nindent 4 }}
name: {{ include "exporter.fullname" . }}
{{- if eq .Values.rbac.type "Role" }}
namespace: {{ .Release.Namespace }}
{{- end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: {{ .Values.rbac.type }}
name: {{ .Values.rbac.name }}
subjects:
- kind: ServiceAccount
name: {{ include "exporter.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{- end }}
13 changes: 13 additions & 0 deletions deploy/helm-chart/templates/dashboard.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- if .Values.dashboard.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
labels:
{{- include "exporter.labels" . | nindent 4 }}
{{- toYaml .Values.dashboard.labels | nindent 4 }}
name: {{ include "exporter.fullname" . }}
namespace: {{ .Values.dashboard.namespace | default .Release.Namespace }}
data:
dashboard.yaml: |-
{{ $.Files.Get "src/dashboards/dashboard.json" | fromJson | toJson }}
{{- end }}
3 changes: 3 additions & 0 deletions deploy/helm-chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ spec:
{{- end }}
labels:
{{- include "exporter.selectorLabels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
Expand Down
42 changes: 42 additions & 0 deletions deploy/helm-chart/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{{- if .Values.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "exporter.fullname" . }}
namespace: {{ .Values.serviceMonitor.namespace | default .Release.Namespace }}
labels:
{{- include "exporter.labels" . | nindent 4 }}
{{- if .Values.serviceMonitor.labels }}
{{- toYaml .Values.serviceMonitor.labels | nindent 4 }}
{{- end }}
{{- if .Values.serviceMonitor.annotations }}
annotations:
{{- toYaml .Values.serviceMonitor.annotations | nindent 4 }}
{{- end }}
spec:
jobLabel: {{ .Values.serviceMonitor.jobLabel | quote }}
selector:
matchLabels:
{{- include "exporter.selectorLabels" . | nindent 6 }}
endpoints:
- port: http
scheme: "http"
{{- if .Values.serviceMonitor.interval }}
interval: {{ .Values.serviceMonitor.interval }}
{{- end }}
{{- if .Values.serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ .Values.serviceMonitor.scrapeTimeout }}
{{- end }}
{{- if .Values.serviceMonitor.honorLabels }}
honorLabels: {{ .Values.serviceMonitor.honorLabels }}
{{- end }}
{{- if .Values.serviceMonitor.metricRelabelings }}
metricRelabelings: {{ .Values.serviceMonitor.metricRelabelings }}
{{- end }}
{{- if .Values.serviceMonitor.relabelings }}
relabelings: {{ .Values.serviceMonitor.relabelings }}
{{- end }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
{{- end }}
25 changes: 25 additions & 0 deletions deploy/helm-chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,17 @@ serviceAccount:
# If not set and create is true, a name is generated using the fullname template
name: ""

rbac:
enabled: false
type: ClusterRole # ClusterRole or Role
name: "" # example: system:auth-delegator

podAnnotations:
prometheus.io/scrape: 'true'
prometheus.io/port: '8000'
prometheus.io/path: '/'

podLabels: {}

env:
# Set envs like in the kubernetes pod spec
Expand Down Expand Up @@ -84,3 +90,22 @@ nodeSelector: {}
tolerations: []

affinity: {}

dashboard:
enabled: false
namespace: "" # will be set to .Release.Namespace if empty
labels:
grafana_dashboard: "1"

serviceMonitor:
enabled: false
namespace: ""
annotations: {}
labels: {}
jobLabel: ""
honorLabels: false
interval: ""
scrapeTimeout: ""
metricRelabelings: []
relabelings: []
selector: {}

0 comments on commit 21b6294

Please sign in to comment.