Skip to content

Commit

Permalink
fix(HPA): fix kratos HPA by using the correct autoscaling v1 cpu util…
Browse files Browse the repository at this point in the history
…ization config (#346)

* fix (hpa): use the correct autoscaling/v1 cpu utilization config and add support for autoscaling/v2beta2 config

* use helm capabilities for selecting the hpa config depending on the available version

* add autoscaling to installation values, separate hpa-v1, hpa-v2 into separate files

* fix typo with enable autoscaling

* fix typo with memory utilization config in autoscaling

* disable autoscaling from installation values
  • Loading branch information
abdoofathy95 committed Oct 19, 2021
1 parent 60bfbdf commit 40af988
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .circleci/values/kratos.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
autoscaling:
enabled: false
kratos:
autoMigrate: true
identitySchemas:
Expand Down
18 changes: 18 additions & 0 deletions helm/charts/kratos/templates/hpa-v1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{- if and (.Values.autoscaling.enabled) (not (.Capabilities.APIVersions.Has "autoscaling/v2beta2")) }}
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "kratos.fullname" . }}
labels:
{{- include "kratos.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "kratos.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
targetCPUUtilizationPercentage: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.autoscaling.enabled }}
{{- if and (.Values.autoscaling.enabled) (.Capabilities.APIVersions.Has "autoscaling/v2beta2") }}
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
Expand All @@ -14,15 +14,19 @@ spec:
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}

0 comments on commit 40af988

Please sign in to comment.