Skip to content

Commit

Permalink
feat: add ServiceMonitor support to helm chart (#114)
Browse files Browse the repository at this point in the history
* Scrape metrics automatically when using Prometheus operator

Signed-off-by: Kevin Lefevre <archi@kiln.fi>
  • Loading branch information
ArchiFleKs authored Sep 11, 2024
1 parent 0e88c32 commit ab78990
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 4 deletions.
41 changes: 41 additions & 0 deletions k8s/commit-boost/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{{- if .Values.serviceMonitor.enabled -}}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "commit-boost.fullname" . }}
{{- if .Values.serviceMonitor.namespace }}
namespace: {{ .Values.serviceMonitor.namespace | quote }}
{{- end }}
labels:
{{- include "commit-boost.labels" . | nindent 4 }}
{{- if .Values.serviceMonitor.additionalLabels }}
{{- toYaml .Values.serviceMonitor.additionalLabels | nindent 4 }}
{{- end }}
spec:
endpoints:
- port: http-metrics
interval: {{ .Values.serviceMonitor.scrapeInterval }}
{{- if .Values.serviceMonitor.honorLabels }}
honorLabels: true
{{- end }}
{{- if .Values.serviceMonitor.metricRelabelings }}
metricRelabelings: {{ toYaml .Values.serviceMonitor.metricRelabelings | nindent 8 }}
{{- end }}
path: {{ .Values.serviceMonitor.path }}
{{- if .Values.serviceMonitor.namespaceSelector }}
namespaceSelector: {{ toYaml .Values.serviceMonitor.namespaceSelector | nindent 4 }}
{{ else }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
{{- end }}
{{- if .Values.serviceMonitor.targetLabels }}
targetLabels:
{{- range .Values.serviceMonitor.targetLabels }}
- {{ . }}
{{- end }}
{{- end }}
selector:
matchLabels:
{{- include "commit-boost.selectorLabels" . | nindent 6 }}
{{- end }}
27 changes: 23 additions & 4 deletions k8s/commit-boost/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ serviceAccount:
podAnnotations: {}
podLabels: {}

podSecurityContext: {}
podSecurityContext:
{}
# fsGroup: 2000

securityContext: {}
securityContext:
{}
# capabilities:
# drop:
# - ALL
Expand All @@ -46,7 +48,8 @@ service:
ingress:
enabled: false
className: ""
annotations: {}
annotations:
{}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
Expand All @@ -59,7 +62,8 @@ ingress:
# hosts:
# - chart-example.local

resources: {}
resources:
{}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
Expand Down Expand Up @@ -97,6 +101,21 @@ tolerations: []

affinity: {}

serviceMonitor:
enabled: false
additionalLabels: {}
namespace: ""
namespaceSelector: {}
# Default: scrape .Release.Namespace only
# To scrape all, use the following:
# namespaceSelector:
# any: true
scrapeInterval: 30s
# honorLabels: true
targetLabels: []
metricRelabelings: []
# path: /metrics

commitBoost:
pbs:
enable: true
Expand Down

0 comments on commit ab78990

Please sign in to comment.