Skip to content

Commit

Permalink
feat(oathkeeper): Allow user to scale more precisely with ContainerRe…
Browse files Browse the repository at this point in the history
…source in hpa
  • Loading branch information
noony committed Dec 17, 2024
1 parent 63d0f2c commit 90dc453
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
15 changes: 15 additions & 0 deletions hacks/values/oathkeeper.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,21 @@ deployment:
behavior:
scaleDown:
stabilizationWindowSeconds: 60
extraMetrics:
- type: ContainerResource
containerResource:
name: cpu
container: sidecar
target:
type: Utilization
averageUtilization: 80
- type: ContainerResource
containerResource:
name: memory
container: sidecar
target:
type: Utilization
averageUtilization: 80
strategy:
type: RollingUpdate
rollingUpdate:
Expand Down
18 changes: 18 additions & 0 deletions helm/charts/oathkeeper/templates/hpa-controller.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{- if .Values.deployment.autoscaling.enabled }}
{{- $kubeVersion := .Capabilities.KubeVersion.GitVersion -}}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
Expand All @@ -20,17 +21,34 @@ spec:
maxReplicas: {{ .Values.deployment.autoscaling.maxReplicas }}
metrics:
{{- with .Values.deployment.autoscaling.targetMemory }}
{{- if and (and (not (empty $kubeVersion)) (semverCompare ">=1.30-0" $kubeVersion) (not (empty $.Values.deployment.autoscaling.extraMetrics))) }}
- type: ContainerResource
containerResource:
name: memory
container: {{ $.Chart.Name }}
{{- else }}
- type: Resource
resource:
name: memory
{{- end }}
target:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.deployment.autoscaling.targetCPU}}
{{- if and (and (not (empty $kubeVersion)) (semverCompare ">=1.30-0" $kubeVersion) (not (empty $.Values.deployment.autoscaling.extraMetrics))) }}
- type: ContainerResource
containerResource:
name: cpu
container: {{ $.Chart.Name }}
{{- else }}
- type: Resource
resource:
name: cpu
{{- end }}
target:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if and (and (not (empty $kubeVersion)) (semverCompare ">=1.30-0" $kubeVersion) (not (empty $.Values.deployment.autoscaling.extraMetrics))) }}
{{- toYaml .Values.deployment.autoscaling.extraMetrics | nindent 2}}
{{- end }}
{{- end }}
3 changes: 3 additions & 0 deletions helm/charts/oathkeeper/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,9 @@ deployment:
# -- Set custom behavior
# https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#configurable-scaling-behavior
behavior: {}
# -- Add extraContainer container resource metrics
# https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#container-resource-metrics
extraMetrics: []

# -- Configure node affinity
affinity: {}
Expand Down

0 comments on commit 90dc453

Please sign in to comment.