Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ Periodic probe of container liveness. Container will be restarted if the probe f
| ------------------------ | -------------------------------------------------------------------------------------------- | --------------- |
| serviceMonitor.enabled | Enable serviceMonitor | `false` |
| serviceMonitor.additionalLabels | Labels for serviceMonitor | `{}` |
| serviceMonitor.name | ServiceMonitor name | `<applicationName>-svc-monitor` |
| serviceMonitor.annotations | Annotations for serviceMonitor | `{}` |
| serviceMonitor.jobLabel | Job Label used for application selector | `k8s-app` |
| serviceMonitor.endpoints | Array of endpoints to be scraped by prometheus | - interval: 5s<br>&nbsp;&nbsp;path: /actuator/prometheus<br>&nbsp;&nbsp;port: http |
Expand Down Expand Up @@ -411,12 +412,12 @@ Periodic probe of container liveness. Container will be restarted if the probe f
| keda.name | ScaledObject name | `<applicationName>-scaler` |
| keda.scaleTargetRef | `{apiVersion, kind, name}` of the scaled workload | `<applicationName>` |
| keda.minReplicaCount / keda.maxReplicaCount | Replica bounds | `` |
| keda.pollingInterval / keda.cooldownPeriod / keda.advanced | Passed through | `` |
| keda.pollingInterval / keda.cooldownPeriod / keda.fallback / keda.advanced | Passed through | `` |
| keda.triggerAuthentication.enabled | Render the TriggerAuthentication and reference it from every trigger | `true` |
| keda.triggerAuthentication.name | TriggerAuthentication name | `<applicationName>-aws-credentials` |
| keda.triggerAuthentication.podIdentityProvider | `spec.podIdentity.provider` | `aws` |
| keda.triggerAuthentication.spec | Full spec, replaces `podIdentity` | `` |
| keda.triggers | Triggers rendered verbatim: `[{type, metadata, authenticationRef}]`; metadata values may use templates | `[]` |
| keda.triggers | Triggers rendered verbatim: `[{type, name, metricType, useCachedMetrics, metadata, authenticationRef}]`; metadata values may use templates; `authenticationRef: false` omits the reference for that trigger | `[]` |

### ExternalSecret Parameters

Expand Down
19 changes: 17 additions & 2 deletions charts/application/templates/keda.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ spec:
{{- end }}
{{- with .Values.keda.cooldownPeriod }}
cooldownPeriod: {{ . }}
{{- end }}
{{- with .Values.keda.fallback }}
fallback:
{{ toYaml . | indent 4 }}
{{- end }}
{{- with .Values.keda.advanced }}
advanced:
Expand All @@ -65,9 +69,20 @@ spec:
triggers:
{{- range .Values.keda.triggers }}
- type: {{ .type }}
{{- if or (not (hasKey $auth "enabled")) $auth.enabled }}
{{- with .name }}
name: {{ . }}
{{- end }}
{{- with .metricType }}
metricType: {{ . }}
{{- end }}
{{- if not (kindIs "invalid" .useCachedMetrics) }}
useCachedMetrics: {{ .useCachedMetrics }}
{{- end }}
{{- /* authenticationRef: false opts a trigger out (e.g. prometheus, which has no AWS identity to assume). */}}
{{- $ref := .authenticationRef }}
{{- if and (or (not (hasKey $auth "enabled")) $auth.enabled) (not (and (kindIs "bool" $ref) (not $ref))) }}
authenticationRef:
name: {{ .authenticationRef | default $authName }}
name: {{ if kindIs "string" $ref }}{{ $ref }}{{ else }}{{ $authName }}{{ end }}
{{- end }}
metadata:
{{- range $k, $v := .metadata }}
Expand Down
2 changes: 1 addition & 1 deletion charts/application/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ metadata:
annotations:
{{ toYaml .Values.serviceMonitor.annotations | indent 4 }}
{{- end }}
name: {{ template "application.name" . }}-svc-monitor
name: {{ .Values.serviceMonitor.name | default (printf "%s-svc-monitor" (include "application.name" .)) }}
namespace: {{ template "application.namespace" . }}
spec:
selector:
Expand Down
71 changes: 71 additions & 0 deletions charts/application/tests/keda_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,74 @@ tests:
count: 1
- notExists:
path: spec.triggers[0].authenticationRef

- it: trigger name, metricType and useCachedMetrics are emitted when set, and fallback is passed through
set:
keda.enabled: true
keda.fallback:
failureThreshold: 3
replicas: 2
keda.triggers:
- type: aws-sqs-queue
name: sqs_backlog
metricType: AverageValue
useCachedMetrics: true
metadata:
queueURL: https://sqs.us-east-1.amazonaws.com/123456789012/my-queue
asserts:
- equal:
path: spec.triggers[0].name
value: sqs_backlog
documentSelector:
path: kind
value: ScaledObject
- equal:
path: spec.triggers[0].metricType
value: AverageValue
documentSelector:
path: kind
value: ScaledObject
- equal:
path: spec.triggers[0].useCachedMetrics
value: true
documentSelector:
path: kind
value: ScaledObject
- equal:
path: spec.fallback.replicas
value: 2
documentSelector:
path: kind
value: ScaledObject

- it: a trigger with authenticationRef false has no authenticationRef while its siblings keep theirs
set:
keda.enabled: true
keda.triggers:
- type: aws-sqs-queue
metadata:
queueURL: https://sqs.us-east-1.amazonaws.com/123456789012/my-queue
- type: prometheus
authenticationRef: false
metadata:
serverAddress: http://prometheus.monitoring.svc:9090
query: vector(1)
threshold: "1.5"
asserts:
- equal:
path: spec.triggers[0].authenticationRef.name
value: application-aws-credentials
documentSelector:
path: kind
value: ScaledObject
- notExists:
path: spec.triggers[1].authenticationRef
documentSelector:
path: kind
value: ScaledObject
- equal:
path: spec.triggers[1].metadata.threshold
value: "1.5"
documentSelector:
path: kind
value: ScaledObject
34 changes: 34 additions & 0 deletions charts/application/tests/servicemonitor_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
suite: servicemonitor
templates:
- servicemonitor.yaml
tests:
- it: enabled false renders nothing
asserts:
- hasDocuments:
count: 0

- it: name defaults to applicationName-svc-monitor
set:
serviceMonitor.enabled: true
serviceMonitor.endpoints:
- port: http
path: /metrics
interval: 30s
asserts:
- equal:
path: metadata.name
value: application-svc-monitor
- equal:
path: spec.endpoints[0].port
value: http

- it: serviceMonitor.name overrides the default
set:
serviceMonitor.enabled: true
serviceMonitor.name: executor
serviceMonitor.endpoints:
- port: http
asserts:
- equal:
path: metadata.name
value: executor
9 changes: 8 additions & 1 deletion charts/application/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ pdb:
##########################################################
serviceMonitor:
enabled: false
# name: "" # defaults to <applicationName>-svc-monitor

# Value of the `release` label; the Prometheus operator only selects matching ServiceMonitors.
release: prometheus
Expand Down Expand Up @@ -779,16 +780,22 @@ keda:
maxReplicaCount: null
pollingInterval: null
cooldownPeriod: null
fallback: {} # e.g. {failureThreshold: 3, replicas: 2}
advanced: {}
triggerAuthentication:
enabled: true
# name: "" # defaults to <applicationName>-aws-credentials
podIdentityProvider: aws
# spec: {} # full TriggerAuthentication spec, replaces podIdentity
# Rendered verbatim; metadata values may use templates. authenticationRef defaults
# to the TriggerAuthentication above.
# to the TriggerAuthentication above; `authenticationRef: false` omits it for a trigger.
# name / metricType / useCachedMetrics are emitted when set (scalingModifiers formulas
# reference triggers by name).
triggers: []
# - type: aws-sqs-queue
# name: sqs_backlog
# metricType: AverageValue
# useCachedMetrics: true
# metadata:
# queueURL: https://sqs.us-east-1.amazonaws.com/123456789012/my-queue
# queueLength: "100"
Expand Down
Loading