Skip to content

Commit

Permalink
feat: allow to configure autoscaling
Browse files Browse the repository at this point in the history
  • Loading branch information
rsicart authored and JAORMX committed Apr 15, 2024
1 parent 67555be commit 8d0cc7d
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ please refer to [the official krakend documentation](https://www.krakend.io/docs
| Key | Type | Default | Description |
|-----|------|---------|-------------|
| affinity | object | `{}` | The affinity to use for the krakend pod |
| autoscaling | object | `{"annotations":{},"behavior":{},"enabled":false,"maxReplicas":3,"minReplicas":1,"targetCPUUtilizationPercentage":50,"targetMemoryUtilizationPercentage":50}` | Configures HorizontalPodAutoscaler for your Deployment |
| deploymentType | string | `"deployment"` | The deployment type to use for the krakend service Valid values are `deployment` and `rollout` |
| extraVolumeMounts | array | `[]` | extraVolumeMounts allows you to mount extra volumes to the krakend pod |
| extraVolumes | array | `[]` | extraVolumes allows you to mount extra volumes to the krakend pod |
Expand Down
39 changes: 39 additions & 0 deletions templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{{- if and (eq .Values.deploymentType "deployment") .Values.autoscaling.enabled }}
apiVersion: {{ ternary "autoscaling/v2" "autoscaling/v2beta2" (.Capabilities.APIVersions.Has "autoscaling/v2") }}
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "krakend.fullname" . }}
labels:
{{- include "krakend.labels" . | nindent 4 }}
{{- with .Values.autoscaling.annotations }}
annotations: {{ toYaml . | nindent 4 }}
{{- end }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "krakend.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
{{- with .Values.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ . }}
{{- end }}
{{- with .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ . }}
{{- end }}
{{- with .Values.autoscaling.behavior }}
behavior:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
22 changes: 22 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -274,3 +274,25 @@ networkPolicies:
# namespace: "namespace2"
# -- Type of the network policy (ingress or egress)
# type: "egress"

# -- (object) Configures HorizontalPodAutoscaler for your Deployment
autoscaling:
enabled: false
annotations: {}
minReplicas: 1
maxReplicas: 3
targetCPUUtilizationPercentage: 50
targetMemoryUtilizationPercentage: 50
behavior: {}
# scaleDown:
# stabilizationWindowSeconds: 300
# policies:
# - type: Pods
# value: 1
# periodSeconds: 180
# scaleUp:
# stabilizationWindowSeconds: 300
# policies:
# - type: Pods
# value: 2
# periodSeconds: 60

0 comments on commit 8d0cc7d

Please sign in to comment.