Skip to content

Commit

Permalink
Add extra fields for keda triggers and add authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorns163 committed Dec 30, 2024
1 parent f8e07d0 commit 2484213
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,32 @@ spec:
triggers:
- metadata:
query: max_over_time(sum(sum by (pod) (rate(container_cpu_usage_seconds_total{container="distributor",namespace="{{ .Release.Namespace }}"}[5m])) and max by (pod) (up{container="distributor",namespace="{{ .Release.Namespace }}"}) > 0)[15m:]) * 1000
serverAddress: {{ include "mimir.kedaPrometheusAddress" (dict "ctx" $) }}
serverAddress: {{ include "mimir.kedaPrometheusAddress" (dict "ctx" $) }}
{{- $cpu_request := dig "requests" "cpu" nil .Values.distributor.resources }}
threshold: {{ mulf (include "mimir.cpuToMilliCPU" (dict "value" $cpu_request)) (divf .Values.distributor.kedaAutoscaling.targetCPUUtilizationPercentage 100) | floor | int64 | quote }}
{{- if .Values.kedaAutoscaling.customHeaders }}
customHeaders: {{ (include "mimir.lib.mapToCSVString" (dict "map" .Values.kedaAutoscaling.customHeaders)) | quote }}
{{- end }}
ignoreNullValues: {{ .Values.kedaAutoscaling.ignoreNullValues }}
unsafeSsl: {{ .Values.kedaAutoscaling.ignoreNullValues }}
type: prometheus
{{- if .Values.kedaAutoscaling.authentication.enabled }}
authenticationRef:
name: {{ include "mimir.resourceName" (dict "ctx" .) }}
{{- end }}
- metadata:
query: max_over_time(sum((sum by (pod) (container_memory_working_set_bytes{container="distributor",namespace="{{ .Release.Namespace }}"}) and max by (pod) (up{container="distributor",namespace="{{ .Release.Namespace }}"}) > 0) or vector(0))[15m:]) + sum(sum by (pod) (max_over_time(kube_pod_container_resource_requests{container="distributor",namespace="{{ .Release.Namespace }}", resource="memory"}[15m])) and max by (pod) (changes(kube_pod_container_status_restarts_total{container="distributor",namespace="{{ .Release.Namespace }}"}[15m]) > 0) and max by (pod) (kube_pod_container_status_last_terminated_reason{container="distributor",namespace="{{ .Release.Namespace }}", reason="OOMKilled"}) or vector(0))
serverAddress: {{ include "mimir.kedaPrometheusAddress" (dict "ctx" $) }}
serverAddress: {{ include "mimir.kedaPrometheusAddress" (dict "ctx" $) }}
{{- $mem_request := dig "requests" "memory" nil .Values.distributor.resources }}
threshold: {{ mulf (include "mimir.siToBytes" (dict "value" $mem_request)) (divf .Values.distributor.kedaAutoscaling.targetMemoryUtilizationPercentage 100) | floor | int64 | quote }}
{{- if .Values.kedaAutoscaling.customHeaders }}
customHeaders: {{ (include "mimir.lib.mapToCSVString" (dict "map" .Values.kedaAutoscaling.customHeaders)) | quote }}
{{- end }}
ignoreNullValues: {{ .Values.kedaAutoscaling.ignoreNullValues }}
unsafeSsl: {{ .Values.kedaAutoscaling.ignoreNullValues }}
type: prometheus
{{- if .Values.kedaAutoscaling.authentication.enabled }}
authenticationRef:
name: {{ include "mimir.resourceName" (dict "ctx" .) }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if .Values.kedaAutoscaling.authentication.enabled }}
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: keda-triggger-auth
namespace: {{ .Release.Namespace | quote }}
spec:
secretTargetRef:
{{- with .Values.kedaAutoscaling.authentication.secretTargetRef }}
{{- toYaml . | nindent 2 }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,34 @@ spec:
triggers:
- metadata:
query: sum(max_over_time(cortex_query_scheduler_inflight_requests{container="query-scheduler",namespace="{{ .Release.Namespace }}",quantile="0.5"}[1m]))
serverAddress: {{ include "mimir.kedaPrometheusAddress" (dict "ctx" $) }}
serverAddress: {{ include "mimir.kedaPrometheusAddress" (dict "ctx" $) }}
threshold: {{ .Values.querier.kedaAutoscaling.querySchedulerInflightRequestsThreshold | quote }}
{{- if .Values.kedaAutoscaling.customHeaders }}
customHeaders: {{ (include "mimir.lib.mapToCSVString" (dict "map" .Values.kedaAutoscaling.customHeaders)) | quote }}
{{- end }}
ignoreNullValues: {{ .Values.kedaAutoscaling.ignoreNullValues }}
unsafeSsl: {{ .Values.kedaAutoscaling.ignoreNullValues }}
name: cortex_querier_hpa_default
type: prometheus
{{- if .Values.kedaAutoscaling.authentication.enabled }}
authenticationRef:
name: {{ include "mimir.resourceName" (dict "ctx" .) }}
{{- end }}
- metadata:
query: sum(rate(cortex_querier_request_duration_seconds_sum{container="querier",namespace="{{ .Release.Namespace }}"}[1m]))
serverAddress: {{ include "mimir.kedaPrometheusAddress" (dict "ctx" $) }}
serverAddress: {{ include "mimir.kedaPrometheusAddress" (dict "ctx" $) }}
threshold: {{ .Values.querier.kedaAutoscaling.querySchedulerInflightRequestsThreshold | quote }}
{{- if .Values.kedaAutoscaling.customHeaders }}
customHeaders: {{ (include "mimir.lib.mapToCSVString" (dict "map" .Values.kedaAutoscaling.customHeaders)) | quote }}
{{- end }}
ignoreNullValues: {{ .Values.kedaAutoscaling.ignoreNullValues }}
unsafeSsl: {{ .Values.kedaAutoscaling.ignoreNullValues }}
name: cortex_querier_hpa_default_requests_duration
type: prometheus
{{- if .Values.kedaAutoscaling.authentication.enabled }}
authenticationRef:
name: {{ include "mimir.resourceName" (dict "ctx" .) }}
{{- end }}
{{- $autoscaling := .Values.querier.kedaAutoscaling -}}
{{- if .Values.querier.kedaAutoscaling.predictiveScalingEnabled }}
- metadata:
Expand All @@ -53,7 +65,13 @@ spec:
{{- if .Values.kedaAutoscaling.customHeaders }}
customHeaders: {{ (include "mimir.lib.mapToCSVString" (dict "map" .Values.kedaAutoscaling.customHeaders)) | quote }}
{{- end }}
ignoreNullValues: {{ .Values.kedaAutoscaling.ignoreNullValues }}
unsafeSsl: {{ .Values.kedaAutoscaling.ignoreNullValues }}
name: cortex_querier_hpa_default_predictive
type: prometheus
{{- if .Values.kedaAutoscaling.authentication.enabled }}
authenticationRef:
name: {{ include "mimir.resourceName" (dict "ctx" .) }}
{{- end }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,32 @@ spec:
triggers:
- metadata:
query: max_over_time(sum(sum by (pod) (rate(container_cpu_usage_seconds_total{container="query-frontend",namespace="{{ .Release.Namespace }}"}[5m])) and max by (pod) (up{container="query-frontend",namespace="{{ .Release.Namespace }}"}) > 0)[15m:]) * 1000
serverAddress: {{ include "mimir.kedaPrometheusAddress" (dict "ctx" $) }}
serverAddress: {{ include "mimir.kedaPrometheusAddress" (dict "ctx" $) }}
{{- $cpu_request := dig "requests" "cpu" nil .Values.query_frontend.resources }}
threshold: {{ mulf (include "mimir.cpuToMilliCPU" (dict "value" $cpu_request)) (divf .Values.query_frontend.kedaAutoscaling.targetCPUUtilizationPercentage 100) | floor | int64 | quote }}
{{- if .Values.kedaAutoscaling.customHeaders }}
customHeaders: {{ (include "mimir.lib.mapToCSVString" (dict "map" .Values.kedaAutoscaling.customHeaders)) | quote }}
{{- end }}
ignoreNullValues: {{ .Values.kedaAutoscaling.ignoreNullValues }}
unsafeSsl: {{ .Values.kedaAutoscaling.ignoreNullValues }}
type: prometheus
{{- if .Values.kedaAutoscaling.authentication.enabled }}
authenticationRef:
name: {{ include "mimir.resourceName" (dict "ctx" .) }}
{{- end }}
- metadata:
query: max_over_time(sum((sum by (pod) (container_memory_working_set_bytes{container="query-frontend",namespace="{{ .Release.Namespace }}"}) and max by (pod) (up{container="query-frontend",namespace="{{ .Release.Namespace }}"}) > 0) or vector(0))[15m:]) + sum(sum by (pod) (max_over_time(kube_pod_container_resource_requests{container="query-frontend",namespace="{{ .Release.Namespace }}", resource="memory"}[15m])) and max by (pod) (changes(kube_pod_container_status_restarts_total{container="query-frontend",namespace="{{ .Release.Namespace }}"}[15m]) > 0) and max by (pod) (kube_pod_container_status_last_terminated_reason{container="query-frontend",namespace="{{ .Release.Namespace }}", reason="OOMKilled"}) or vector(0))
serverAddress: {{ include "mimir.kedaPrometheusAddress" (dict "ctx" $) }}
serverAddress: {{ include "mimir.kedaPrometheusAddress" (dict "ctx" $) }}
{{- $mem_request := dig "requests" "memory" nil .Values.query_frontend.resources }}
threshold: {{ mulf (include "mimir.siToBytes" (dict "value" $mem_request)) (divf .Values.query_frontend.kedaAutoscaling.targetMemoryUtilizationPercentage 100) | floor | int64 | quote }}
{{- if .Values.kedaAutoscaling.customHeaders }}
customHeaders: {{ (include "mimir.lib.mapToCSVString" (dict "map" .Values.kedaAutoscaling.customHeaders)) | quote }}
{{- end }}
ignoreNullValues: {{ .Values.kedaAutoscaling.ignoreNullValues }}
unsafeSsl: {{ .Values.kedaAutoscaling.ignoreNullValues }}
type: prometheus
{{- if .Values.kedaAutoscaling.authentication.enabled }}
authenticationRef:
name: {{ include "mimir.resourceName" (dict "ctx" .) }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,33 @@ spec:
triggers:
- metadata:
query: sum(max_over_time(cortex_query_scheduler_inflight_requests{container="ruler-query-scheduler",namespace="{{ .Release.Namespace }}",quantile="0.5"}[1m]))
serverAddress: {{ include "mimir.kedaPrometheusAddress" (dict "ctx" $) }}
serverAddress: {{ include "mimir.kedaPrometheusAddress" (dict "ctx" $) }}
threshold: {{ .Values.ruler_querier.kedaAutoscaling.querySchedulerInflightRequestsThreshold | quote }}
{{- if .Values.kedaAutoscaling.customHeaders }}
customHeaders: {{ (include "mimir.lib.mapToCSVString" (dict "map" .Values.kedaAutoscaling.customHeaders)) | quote }}
{{- end }}
ignoreNullValues: {{ .Values.kedaAutoscaling.ignoreNullValues }}
unsafeSsl: {{ .Values.kedaAutoscaling.ignoreNullValues }}
name: cortex_querier_hpa_default
type: prometheus
{{- if .Values.kedaAutoscaling.authentication.enabled }}
authenticationRef:
name: {{ include "mimir.resourceName" (dict "ctx" .) }}
{{- end }}
- metadata:
query: sum(rate(cortex_querier_request_duration_seconds_sum{container="ruler-querier",namespace="{{ .Release.Namespace }}"}[1m]))
serverAddress: {{ include "mimir.kedaPrometheusAddress" (dict "ctx" $) }}
serverAddress: {{ include "mimir.kedaPrometheusAddress" (dict "ctx" $) }}
threshold: {{ .Values.ruler_querier.kedaAutoscaling.querySchedulerInflightRequestsThreshold | quote }}
{{- if .Values.kedaAutoscaling.customHeaders }}
customHeaders: {{ (include "mimir.lib.mapToCSVString" (dict "map" .Values.kedaAutoscaling.customHeaders)) | quote }}
{{- end }}
ignoreNullValues: {{ .Values.kedaAutoscaling.ignoreNullValues }}
unsafeSsl: {{ .Values.kedaAutoscaling.ignoreNullValues }}
name: cortex_querier_hpa_default_requests_duration
type: prometheus
{{- if .Values.kedaAutoscaling.authentication.enabled }}
authenticationRef:
name: {{ include "mimir.resourceName" (dict "ctx" .) }}
{{- end }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ spec:
{{- if .Values.kedaAutoscaling.customHeaders }}
customHeaders: {{ (include "mimir.lib.mapToCSVString" (dict "map" .Values.kedaAutoscaling.customHeaders)) | quote }}
{{- end }}
ignoreNullValues: {{ .Values.kedaAutoscaling.ignoreNullValues }}
unsafeSsl: {{ .Values.kedaAutoscaling.ignoreNullValues }}
type: prometheus
{{- if .Values.kedaAutoscaling.authentication.enabled }}
authenticationRef:
name: {{ include "mimir.resourceName" (dict "ctx" .) }}
{{- end }}
- metadata:
query: max_over_time(sum((sum by (pod) (container_memory_working_set_bytes{container="ruler-query-frontend",namespace="{{ .Release.Namespace }}"}) and max by (pod) (up{container="ruler-query-frontend",namespace="{{ .Release.Namespace }}"}) > 0) or vector(0))[15m:]) + sum(sum by (pod) (max_over_time(kube_pod_container_resource_requests{container="ruler-query-frontend",namespace="{{ .Release.Namespace }}", resource="memory"}[15m])) and max by (pod) (changes(kube_pod_container_status_restarts_total{container="ruler-query-frontend",namespace="{{ .Release.Namespace }}"}[15m]) > 0) and max by (pod) (kube_pod_container_status_last_terminated_reason{container="ruler-query-frontend",namespace="{{ .Release.Namespace }}", reason="OOMKilled"}) or vector(0))
serverAddress: {{ include "mimir.kedaPrometheusAddress" (dict "ctx" $) }}
Expand All @@ -41,6 +47,12 @@ spec:
{{- if .Values.kedaAutoscaling.customHeaders }}
customHeaders: {{ (include "mimir.lib.mapToCSVString" (dict "map" .Values.kedaAutoscaling.customHeaders)) | quote }}
{{- end }}
ignoreNullValues: {{ .Values.kedaAutoscaling.ignoreNullValues }}
unsafeSsl: {{ .Values.kedaAutoscaling.ignoreNullValues }}
type: prometheus
{{- if .Values.kedaAutoscaling.authentication.enabled }}
authenticationRef:
name: {{ include "mimir.resourceName" (dict "ctx" .) }}
{{- end }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,32 @@ spec:
triggers:
- metadata:
query: max_over_time(sum(sum by (pod) (rate(container_cpu_usage_seconds_total{container="ruler",namespace="{{ .Release.Namespace }}"}[5m])) and max by (pod) (up{container="ruler",namespace="{{ .Release.Namespace }}"}) > 0)[15m:]) * 1000
serverAddress: {{ include "mimir.kedaPrometheusAddress" (dict "ctx" $) }}
serverAddress: {{ include "mimir.kedaPrometheusAddress" (dict "ctx" $) }}
{{- $cpu_request := dig "requests" "cpu" nil .Values.ruler.resources }}
threshold: {{ mulf (include "mimir.cpuToMilliCPU" (dict "value" $cpu_request)) (divf .Values.ruler.kedaAutoscaling.targetCPUUtilizationPercentage 100) | floor | int64 | quote }}
{{- if .Values.kedaAutoscaling.customHeaders }}
customHeaders: {{ (include "mimir.lib.mapToCSVString" (dict "map" .Values.kedaAutoscaling.customHeaders)) | quote }}
{{- end }}
ignoreNullValues: {{ .Values.kedaAutoscaling.ignoreNullValues }}
unsafeSsl: {{ .Values.kedaAutoscaling.ignoreNullValues }}
type: prometheus
{{- if .Values.kedaAutoscaling.authentication.enabled }}
authenticationRef:
name: {{ include "mimir.resourceName" (dict "ctx" .) }}
{{- end }}
- metadata:
query: max_over_time(sum((sum by (pod) (container_memory_working_set_bytes{container="ruler",namespace="{{ .Release.Namespace }}"}) and max by (pod) (up{container="ruler",namespace="{{ .Release.Namespace }}"}) > 0) or vector(0))[15m:]) + sum(sum by (pod) (max_over_time(kube_pod_container_resource_requests{container="ruler",namespace="{{ .Release.Namespace }}", resource="memory"}[15m])) and max by (pod) (changes(kube_pod_container_status_restarts_total{container="ruler",namespace="{{ .Release.Namespace }}"}[15m]) > 0) and max by (pod) (kube_pod_container_status_last_terminated_reason{container="ruler",namespace="{{ .Release.Namespace }}", reason="OOMKilled"}) or vector(0))
serverAddress: {{ include "mimir.kedaPrometheusAddress" (dict "ctx" $) }}
serverAddress: {{ include "mimir.kedaPrometheusAddress" (dict "ctx" $) }}
{{- $mem_request := dig "requests" "memory" nil .Values.ruler.resources }}
threshold: {{ mulf (include "mimir.siToBytes" (dict "value" $mem_request)) (divf .Values.ruler.kedaAutoscaling.targetMemoryUtilizationPercentage 100) | floor | int64 | quote }}
{{- if .Values.kedaAutoscaling.customHeaders }}
customHeaders: {{ (include "mimir.lib.mapToCSVString" (dict "map" .Values.kedaAutoscaling.customHeaders)) | quote }}
{{- end }}
ignoreNullValues: {{ .Values.kedaAutoscaling.ignoreNullValues }}
unsafeSsl: {{ .Values.kedaAutoscaling.ignoreNullValues }}
type: prometheus
{{- if .Values.kedaAutoscaling.authentication.enabled }}
authenticationRef:
name: {{ include "mimir.resourceName" (dict "ctx" .) }}
{{- end }}
{{- end }}
14 changes: 14 additions & 0 deletions operations/helm/charts/mimir-distributed/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,21 @@ kedaAutoscaling:
prometheusAddress: ""
customHeaders: {}
pollingInterval: 10
ignoreNullValues: true
unsafeSsl: false

# --KEDA trigger authentication settings.
# ref: https://keda.sh/docs/2.16/scalers/pulsar/#authentication-parameters
authentication:
enabled: false
authModes: ""
secretTargetRef: []
# - key: username
# name: my-secret-name
# parameter: username
# - key: password
# name: my-secret-name
# parameter: password
alertmanager:
enabled: true
# -- Total number of replicas for the alertmanager across all availability zones
Expand Down

0 comments on commit 2484213

Please sign in to comment.