Skip to content

Commit

Permalink
proxy: hpa
Browse files Browse the repository at this point in the history
  • Loading branch information
conradludgate committed May 10, 2024
1 parent 175d939 commit 5bc0761
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 2 deletions.
4 changes: 3 additions & 1 deletion charts/neon-proxy/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ metadata:
spec:
strategy:
{{- toYaml .Values.deploymentStrategy | nindent 4 }}
replicas: {{ .Values.replicaCount }}
{{- with .Values.replicaCount }}
replicas: {{ . }}
{{- end }}
selector:
matchLabels:
{{- include "neon-proxy.selectorLabels" . | nindent 6 }}
Expand Down
51 changes: 51 additions & 0 deletions charts/neon-proxy/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{{ with .Values.hpa }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: php-apache
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "neon-proxy.fullname" . }}
labels:
{{- include "neon-proxy.labels" . | nindent 4 }}
minReplicas: {{ .minReplicas }}
maxReplicas: {{ .maxReplicas }}
metrics:
# With this metric the HPA controller will keep the average utilization of the pods in the scaling target at 50%.
# Utilization is the ratio between the current usage of resource to the requested resources of the pod
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .cpuUtilisation }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ .memoryUtilisation }}
behavior:
scaleDown:
# wait one day before scaling down
stabilizationWindowSeconds: 86400
policies:
# only scale down 10% of pods in a 5 minute window
- type: Percent
value: 10
periodSeconds: 300
# only scale down 1 pod every minute
- type: Pods
value: 1
periodSeconds: 60
selectPolicy: Min
scaleUp:
stabilizationWindowSeconds: 0
policies:
# double the number of pods every minute
- type: Percent
value: 100
periodSeconds: 60
{{ end }}
8 changes: 7 additions & 1 deletion charts/neon-proxy/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicaCount: 1
# replicaCount: 1

hpa:
minReplicas: 1
maxReplicas: 10
cpuUtilisation: 50
memoryUtilisation: 50

# -- strategy override for deployment
deploymentStrategy:
Expand Down

0 comments on commit 5bc0761

Please sign in to comment.