Skip to content

Commit

Permalink
Merge pull request #1381 from porter-dev/ym/gpu_autoscaling
Browse files Browse the repository at this point in the history
feat: umbrella templating for gpu autoscaling
  • Loading branch information
stefanmcshane authored Aug 19, 2024
2 parents 6f66e53 + 53054ec commit 129fcca
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 1 deletion.
14 changes: 13 additions & 1 deletion applications/testdata/web.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
autoscaling:
enabled: false
enabled: true
behavior:
enabled: true
scaleDown:
stabilizationWindowSeconds: 3600
type: Pods
value: 2
periodSeconds: 60
scaleUp:
stabilizationWindowSeconds: 3600
type: Pods
value: 2
periodSeconds: 60
gpu: false
maxReplicas: 10
minReplicas: 1
Expand Down
20 changes: 20 additions & 0 deletions applications/web/templates/hpa-blue-green.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,26 @@ spec:
type: Utilization
averageUtilization: {{ . }}
{{- end }}
{{- if .Values.autoscaling.gpu }}
{{- with .Values.autoscaling.targetGPUUtilizationPercentage }}
- type: Pods
pods:
metric:
name: gpu_utilization
target:
type: AverageValue
averageValue: {{ . }}
{{- end }}
{{- with .Values.autoscaling.targetGPUMemoryUtilizationRatio }}
- type: Pods
pods:
metric:
name: gpu_memory_utilization_ratio
target:
type: AverageValue
averageValue: {{ . | div 100.0 }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
22 changes: 22 additions & 0 deletions applications/web/templates/hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ spec:
{{- if .Values.autoscaling.behavior.enabled }}
behavior:
scaleDown:
stabilizationWindowSeconds: {{ .Values.autoscaling.behavior.scaleDown.stabilizationWindowSeconds | default 60 }}
policies:
- type: {{ .Values.autoscaling.behavior.scaleDown.type }}
value: {{ .Values.autoscaling.behavior.scaleDown.value }}
periodSeconds: {{ .Values.autoscaling.behavior.scaleDown.periodSeconds }}
scaleUp:
stabilizationWindowSeconds: {{ .Values.autoscaling.behavior.scaleUp.stabilizationWindowSeconds | default 60 }}
policies:
- type: {{ .Values.autoscaling.behavior.scaleUp.type }}
value: {{ .Values.autoscaling.behavior.scaleUp.value }}
Expand Down Expand Up @@ -50,5 +52,25 @@ spec:
type: Utilization
averageUtilization: {{ . }}
{{- end }}
{{- if .Values.autoscaling.gpu }}
{{- with .Values.autoscaling.targetGPUUtilizationPercentage }}
- type: Pods
pods:
metric:
name: gpu_utilization
target:
type: AverageValue
averageValue: {{ . }}
{{- end }}
{{- with .Values.autoscaling.targetGPUMemoryUtilizationRatio }}
- type: Pods
pods:
metric:
name: gpu_memory_utilization_ratio
target:
type: AverageValue
averageValue: {{ . | div 100.0 }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
3 changes: 3 additions & 0 deletions applications/web/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,13 @@ resources:

autoscaling:
enabled: false
gpu: false
minReplicas: 1
maxReplicas: 10
targetCPUUtilizationPercentage: 50
targetMemoryUtilizationPercentage: 50
targetGPUUtilizationPercentage: 50
targetGPUMemoryUtilizationRatio: 50
behavior:
enabled: false
scaleDown:
Expand Down
20 changes: 20 additions & 0 deletions applications/worker/templates/hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,24 @@ spec:
type: Utilization
averageUtilization: {{ . }}
{{- end }}
{{- if .Values.autoscaling.gpu }}
{{- with .Values.autoscaling.targetGPUUtilizationPercentage }}
- type: Pods
pods:
metric:
name: gpu_utilization
target:
type: AverageValue
averageValue: {{ . }}
{{- end }}
{{- with .Values.autoscaling.targetGPUMemoryUtilizationRatio }}
- type: Pods
pods:
metric:
name: gpu_memory_utilization_ratio
target:
type: AverageValue
averageValue: {{ . | div 100.0 }}
{{- end }}
{{- end }}
{{- end }}

0 comments on commit 129fcca

Please sign in to comment.