From 690158b8be342baf80b8cf7603992d868ae3a228 Mon Sep 17 00:00:00 2001 From: Tom M G Date: Sun, 3 Dec 2023 15:59:04 +0100 Subject: [PATCH] [tempo-distributed] Enable autocaling for Compactor Signed-off-by: Tom M G --- .../templates/compactor/hpa.yaml | 45 +++++++++++++++++++ .../compactor/keda-scaledObject.yaml | 24 ++++++++++ charts/tempo-distributed/values.yaml | 36 +++++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 charts/tempo-distributed/templates/compactor/hpa.yaml create mode 100644 charts/tempo-distributed/templates/compactor/keda-scaledObject.yaml diff --git a/charts/tempo-distributed/templates/compactor/hpa.yaml b/charts/tempo-distributed/templates/compactor/hpa.yaml new file mode 100644 index 0000000000..0df8ac6307 --- /dev/null +++ b/charts/tempo-distributed/templates/compactor/hpa.yaml @@ -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 }} diff --git a/charts/tempo-distributed/templates/compactor/keda-scaledObject.yaml b/charts/tempo-distributed/templates/compactor/keda-scaledObject.yaml new file mode 100644 index 0000000000..ef42b4f553 --- /dev/null +++ b/charts/tempo-distributed/templates/compactor/keda-scaledObject.yaml @@ -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 }} diff --git a/charts/tempo-distributed/values.yaml b/charts/tempo-distributed/values.yaml index 7306f6dff7..93e026f0c2 100644 --- a/charts/tempo-distributed/values.yaml +++ b/charts/tempo-distributed/values.yaml @@ -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://: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