Skip to content

Commit

Permalink
Add PrometheusRules support for keda operator (#157)
Browse files Browse the repository at this point in the history
Signed-off-by: Oded David <[email protected]>
  • Loading branch information
oded-dd authored May 31, 2021
1 parent 19fbab8 commit 57e68fc
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 5 deletions.
2 changes: 1 addition & 1 deletion keda/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: Event-based autoscaler for workloads on Kubernetes

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
version: 2.3.0
version: 2.3.1

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application.
Expand Down
12 changes: 8 additions & 4 deletions keda/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,14 @@ their default values.
| `prometheus.operator.podMonitor.scrapeTimeout` | Scraping timeout for keda operator using podMonitor crd (prometheus operator) | ``
| `prometheus.operator.podMonitor.namespace` | Scraping namespace for keda operator using podMonitor crd (prometheus operator) | ``
| `prometheus.operator.podMonitor.additionalLabels` | Additional labels to add for keda operator using podMonitor crd (prometheus operator) | `{}`
| `volumes.keda.extraVolumes` | Extra volumes for keda deployment | `[]`
| `volumes.keda.extraVolumeMounts` | Extra volume mounts for keda deployment | `[]`
| `volumes.metricsApiServer.extraVolumes` | Extra volumes for metric server deployment | `[]`
| `volumes.metricsApiServer.extraVolumeMounts` | Extra volume mounts for metric server deployment | `[]`
| `prometheus.operator.prometheusRules.enabled` | Enable monitoring for keda operator using prometheusRules crd (prometheus operator) | `false`
| `prometheus.operator.prometheusRules.namespace` | Scraping namespace for keda operator using prometheusRules crd (prometheus operator) | ``
| `prometheus.operator.prometheusRules.additionalLabels` | Additional labels to add for keda operator using prometheusRules crd (prometheus operator) | `{}`
| `prometheus.operator.prometheusRules.alerts` | Additional alerts to add for keda operator using prometheusRules crd (prometheus operator) | `[]`
| `volumes.keda.extraVolumes` | Extra volumes for keda deployment | `[]`
| `volumes.keda.extraVolumeMounts` | Extra volume mounts for keda deployment | `[]`
| `volumes.metricsApiServer.extraVolumes` | Extra volumes for metric server deployment | `[]`
| `volumes.metricsApiServer.extraVolumeMounts` | Extra volume mounts for metric server deployment | `[]`

Specify each parameter using the `--set key=value[,key=value]` argument to
`helm install`. For example:
Expand Down
23 changes: 23 additions & 0 deletions keda/templates/15-keda-prometheusrules.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{{- if and .Values.prometheus.operator.enabled .Values.prometheus.operator.prometheusRules.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: prometheusRule
metadata:
name: {{ .Values.operator.name }}
labels:
app.kubernetes.io/name: {{ .Values.operator.name }}
app.kubernetes.io/version: {{ .Chart.AppVersion }}
app.kubernetes.io/part-of: {{ .Values.operator.name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- range $key, $value := .Values.prometheus.operator.prometheusRules.additionalLabels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- with .Values.prometheus.operator.prometheusRules.namespace }}
namespace: {{ . }}
{{- end }}
spec:
groups:
- name: {{ .Values.operator.name }}
rules:
{{ toYaml .Values.prometheus.operator.prometheusRules.alerts | indent 6 }}
{{- end }}
15 changes: 15 additions & 0 deletions keda/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,18 @@ prometheus:
scrapeTimeout:
namespace:
additionalLabels: {}
prometheusRules:
# Enables PrometheusRules creation for the Prometheus Operator
enabled: false
namespace:
additionalLabels: {}
alerts: []
# - alert: KedaScalerErrors
# annotations:
# description: Keda scaledObject {{ $labels.scaledObject }} is experiencing erros with {{ $labels.scaler }} scaler
# summary: Keda Scaler {{ $labels.scaler }} Errors
# expr: sum by ( scaledObject , scaler) (rate(keda_metrics_adapter_scaler_errors[2m])) > 0
# for: 2m
# labels:


0 comments on commit 57e68fc

Please sign in to comment.