Skip to content

Commit

Permalink
[tempo-distributed] Enable autocaling for Compactor
Browse files Browse the repository at this point in the history
Signed-off-by: Tom M G <devbytom@gmail.com>
  • Loading branch information
7onn committed Dec 3, 2023
1 parent ec78147 commit 690158b
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 0 deletions.
45 changes: 45 additions & 0 deletions charts/tempo-distributed/templates/compactor/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{{- if and .Values.compactor.autoscaling.enabled .Values.compactor.autoscaling.hpa.enabled }}
{{- $apiVersion := include "tempo.hpa.apiVersion" . -}}
apiVersion: {{ $apiVersion }}
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "tempo.resourceName" (dict "ctx" . "component" "compactor") }}
labels:
{{- include "tempo.labels" (dict "ctx" . "component" "compactor") | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "tempo.resourceName" (dict "ctx" . "component" "compactor") }}
minReplicas: {{ .Values.compactor.autoscaling.minReplicas }}
maxReplicas: {{ .Values.compactor.autoscaling.maxReplicas }}
{{- with .Values.compactor.autoscaling.hpa.behavior }}
behavior:
{{- toYaml . | nindent 4 }}
{{- end }}
metrics:
{{- with .Values.compactor.autoscaling.hpa.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
{{- if (eq $apiVersion "autoscaling/v2") }}
target:
type: Utilization
averageUtilization: {{ . }}
{{- else }}
targetAverageUtilization: {{ . }}
{{- end }}
{{- end }}
{{- with .Values.compactor.autoscaling.hpa.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
{{- if (eq $apiVersion "autoscaling/v2") }}
target:
type: Utilization
averageUtilization: {{ . }}
{{- else }}
targetAverageUtilization: {{ . }}
{{- end }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{- if and .Values.compactor.autoscaling.enabled .Values.compactor.autoscaling.keda.enabled }}
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: {{ include "tempo.resourceName" (dict "ctx" . "component" "compactor") }}
labels:
{{- include "tempo.labels" (dict "ctx" . "component" "compactor") | nindent 4 }}
spec:
minReplicaCount: {{ .Values.compactor.autoscaling.minReplicas }}
maxReplicaCount: {{ .Values.compactor.autoscaling.maxReplicas }}
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "tempo.resourceName" (dict "ctx" . "component" "compactor") }}
triggers:
{{- range .Values.compactor.autoscaling.keda.triggers }}
- type: {{ .type | quote }}
metadata:
serverAddress: {{ .metadata.serverAddress }}
threshold: {{ .metadata.threshold }}
query: |
{{- .metadata.query | nindent 8 }}
{{- end }}
{{- end }}
36 changes: 36 additions & 0 deletions charts/tempo-distributed/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,42 @@ distributor:
compactor:
# -- Number of replicas for the compactor
replicas: 1

# -- Autoscaling configurations
autoscaling:
# -- Enable autoscaling for the compactor
enabled: false
# -- Minimum autoscaling replicas for the compactor
minReplicas: 1
# -- Maximum autoscaling replicas for the compactor
maxReplicas: 3
# -- Autoscaling via HPA object
hpa:
enabled: false
# -- Autoscaling behavior configuration for the compactor
behavior: {}
# -- Target CPU utilisation percentage for the compactor
targetCPUUtilizationPercentage: 100
# -- Target memory utilisation percentage for the compactor
targetMemoryUtilizationPercentage:
# -- Autoscaling via keda/ScaledObject
keda:
# requires https://keda.sh/
enabled: false
# -- List of autoscaling triggers for the compactor
triggers: []
# - type: prometheus
# metadata:
# serverAddress: "http://<prometheus-host>:9090"
# threshold: 250
# query: |-
# sum by (cluster, namespace, tenant) (
# tempodb_compaction_outstanding_blocks{container="compactor", namespace=~".*"}
# ) /
# ignoring(tenant) group_left count by (cluster, namespace)(
# tempo_build_info{container="compactor", namespace=~".*"}
# )

# -- hostAliases to add
hostAliases: []
# - ip: 1.2.3.4
Expand Down

0 comments on commit 690158b

Please sign in to comment.