Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify configuration of internal topics for autoscaling #198

Merged
merged 2 commits into from
Jan 26, 2024
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
27 changes: 14 additions & 13 deletions charts/streams-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,20 @@ Alternatively, a YAML file that specifies the values for the parameters can be p

### Auto-Scaling

| Parameter | Description | Default |
| -------------------------------- | -------------------------------------------------------------------------------------------------------- | ---------- |
| `autoscaling.enabled` | Whether to enable auto-scaling using [KEDA](https://keda.sh/docs/latest/scalers/apache-kafka/). | `false` |
| `autoscaling.consumerGroup` | Name of the consumer group used for checking the offset on the topic and processing the related lag. | |
| `autoscaling.lagThreshold` | Average target value to trigger scaling actions. | |
| `autoscaling.pollingInterval` | https://keda.sh/docs/2.10/concepts/scaling-deployments/#pollinginterval | `30` |
| `autoscaling.cooldownPeriod` | https://keda.sh/docs/2.10/concepts/scaling-deployments/#cooldownperiod | `300` |
| `autoscaling.offsetResetPolicy` | The offset reset policy for the consumer if the the consumer group is not yet subscribed to a partition. | `earliest` |
| `autoscaling.minReplicas` | https://keda.sh/docs/2.10/concepts/scaling-deployments/#minreplicacount | `0` |
| `autoscaling.maxReplicas` | https://keda.sh/docs/2.10/concepts/scaling-deployments/#maxreplicacount | `1` |
| `autoscaling.idleReplicas` | https://keda.sh/docs/2.10/concepts/scaling-deployments/#idlereplicacount | |
| `autoscaling.topics` | List of auto-generated Kafka Streams topics used by the streams app. | `[]` |
| `autoscaling.additionalTriggers` | List of additional KEDA triggers, see https://keda.sh/docs/latest/scalers/ | `[]` |
| Parameter | Description | Default |
|----------------------------------|--------------------------------------------------------------------------------------------------------------------|------------|
| `autoscaling.enabled` | Whether to enable auto-scaling using [KEDA](https://keda.sh/docs/latest/scalers/apache-kafka/). | `false` |
| `autoscaling.consumerGroup` | Name of the consumer group used for checking the offset on the topic and processing the related lag. | |
| `autoscaling.lagThreshold` | Average target value to trigger scaling actions. | |
| `autoscaling.pollingInterval` | https://keda.sh/docs/2.10/concepts/scaling-deployments/#pollinginterval | `30` |
| `autoscaling.cooldownPeriod` | https://keda.sh/docs/2.10/concepts/scaling-deployments/#cooldownperiod | `300` |
| `autoscaling.offsetResetPolicy` | The offset reset policy for the consumer if the the consumer group is not yet subscribed to a partition. | `earliest` |
| `autoscaling.minReplicas` | https://keda.sh/docs/2.10/concepts/scaling-deployments/#minreplicacount | `0` |
| `autoscaling.maxReplicas` | https://keda.sh/docs/2.10/concepts/scaling-deployments/#maxreplicacount | `1` |
| `autoscaling.idleReplicas` | https://keda.sh/docs/2.10/concepts/scaling-deployments/#idlereplicacount | |
| `autoscaling.internalTopics` | List of auto-generated Kafka Streams topics used by the streams app. Consumer group prefix is added automatically. | `[]` |
| `autoscaling.topics` | List of topics used by the streams app. | `[]` |
| `autoscaling.additionalTriggers` | List of additional KEDA triggers, see https://keda.sh/docs/latest/scalers/ | `[]` |

### JVM

Expand Down
13 changes: 11 additions & 2 deletions charts/streams-app/templates/scaled-object.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ spec:
idleReplicaCount: {{ .Values.autoscaling.idleReplicas }}
{{- end }}
triggers:
{{- if not (or .Values.streams.inputTopics .Values.autoscaling.topics .Values.streams.extraInputTopics .Values.autoscaling.additionalTriggers) }}
{{- fail "To use autoscaling, you must define one of .Values.streams.inputTopics, .Values.autoscaling.topics, .Values.streams.extraInputTopics or .Values.autoscaling.additionalTriggers" }}
{{- if not (or .Values.streams.inputTopics .Values.autoscaling.internalTopics .Values.autoscaling.topics .Values.streams.extraInputTopics .Values.autoscaling.additionalTriggers) }}
{{- fail "To use autoscaling, you must define one of .Values.streams.inputTopics, .Values.autoscaling.internalTopics, .Values.autoscaling.topics, .Values.streams.extraInputTopics or .Values.autoscaling.additionalTriggers" }}
{{- end}}
# todo: concat .Values.streams.inputTopics and .Values.autoscaling.topics to
# minimize number of loops when we don't need to support helm 2 anymore
Expand All @@ -40,6 +40,15 @@ spec:
lagThreshold: {{ $root.Values.autoscaling.lagThreshold | quote }}
offsetResetPolicy: {{ $root.Values.autoscaling.offsetResetPolicy }}
{{- end }}
{{- range .Values.autoscaling.internalTopics }}
- type: kafka
metadata:
bootstrapServers: {{ $root.Values.streams.brokers }}
consumerGroup: {{ $root.Values.autoscaling.consumerGroup }}
topic: {{ printf "%s-%s" $root.Values.autoscaling.consumerGroup . | quote }}
lagThreshold: {{ $root.Values.autoscaling.lagThreshold | quote }}
offsetResetPolicy: {{ $root.Values.autoscaling.offsetResetPolicy }}
{{- end }}
{{- range .Values.autoscaling.topics }}
- type: kafka
metadata:
Expand Down
Loading