Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
feat: add support for ServiceMonitors (#117)
Browse files Browse the repository at this point in the history
Co-authored-by: Max Rosin <[email protected]>
  • Loading branch information
morremeyer and ekeih authored Sep 13, 2022
1 parent 7a91442 commit 5d3d264
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 2 deletions.
2 changes: 1 addition & 1 deletion charts/generic/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: generic
description: A chart for generic applications. Use this if you need to deploy something without wanting to build a fully fledged new helm chart.
type: application
version: 3.7.0
version: 3.8.0
maintainers:
- name: morremeyer
- name: ekeih
10 changes: 9 additions & 1 deletion charts/generic/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# generic

![Version: 3.7.0](https://img.shields.io/badge/Version-3.7.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)
![Version: 3.8.0](https://img.shields.io/badge/Version-3.8.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)

A chart for generic applications. Use this if you need to deploy something without wanting to build a fully fledged new helm chart.

Expand Down Expand Up @@ -152,5 +152,13 @@ If you have environment variables set from ConfigMaps or Secrets, check out `env
| serviceAccount.annotations | object | `{}` | Annotations to add to the service account |
| serviceAccount.create | bool | `true` | Specifies whether a service account should be created |
| serviceAccount.name | string | `""` | The name of the service account to use. If not set and create is true, a name is generated using the fullname template. |
| serviceMonitors[0] | object | `{"additionalLabels":{},"enabled":false,"interval":"1m","jobLabel":"","name":"","path":"/metrics","port":"http","scrapeTimeout":"10s"}` | If a ServiceMonitor should be deployed. Needs the CRD installed |
| serviceMonitors[0].additionalLabels | object | `{}` | Additional labels for the ServiceMonitor resource |
| serviceMonitors[0].interval | string | `"1m"` | How often to scrape |
| serviceMonitors[0].jobLabel | string | `""` | The label 'job' in prometheus. Defaults to the release name |
| serviceMonitors[0].name | string | `""` | Name of the resource, defaults to the release name |
| serviceMonitors[0].path | string | `"/metrics"` | The path of the metrics endpoint |
| serviceMonitors[0].port | string | `"http"` | The port to scrape |
| serviceMonitors[0].scrapeTimeout | string | `"10s"` | Timeout for scraping |
| startupProbe | string | `nil` | Configure a startup probe for the pod |
| tolerations | list | `[]` | |
32 changes: 32 additions & 0 deletions charts/generic/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{- range .Values.serviceMonitors -}}
{{- if .enabled }}
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ .name | default (include "generic.fullname" $) }}
namespace: {{ $.Release.Namespace }}
labels:
{{- include "generic.labels" $ | nindent 4 }}
{{- with .additionalLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
jobLabel: {{ .jobLabel | default $.Release.Name }}
namespaceSelector:
matchNames:
- {{ $.Release.Namespace }}
selector:
matchLabels:
{{- include "generic.selectorLabels" $ | nindent 6 }}
endpoints:
- port: {{ .port }}
path: {{ .path }}
{{- with .interval }}
interval: {{ . }}
{{- end }}
{{- with .scrapeTimeout }}
scrapeTimeout: {{ . }}
{{- end }}
{{- end }}
{{- end }}
18 changes: 18 additions & 0 deletions charts/generic/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,24 @@ autoscaling:
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80

serviceMonitors:
# -- If a ServiceMonitor should be deployed. Needs the CRD installed
- enabled: false
# -- Name of the resource, defaults to the release name
name: ""
# -- Additional labels for the ServiceMonitor resource
additionalLabels: {}
# -- How often to scrape
interval: 1m
# -- Timeout for scraping
scrapeTimeout: 10s
# -- The port to scrape
port: http
# -- The path of the metrics endpoint
path: /metrics
# -- The label 'job' in prometheus. Defaults to the release name
jobLabel: ""

nodeSelector: {}

tolerations: []
Expand Down

0 comments on commit 5d3d264

Please sign in to comment.