-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add horizontal pod autoscaler and pod disruption budgets (#656)
autoscaler will be added based on .Values.services.*.autoscaling config, and pod disruption budgets default to minAvailable 1 only if minimum replicas is greater than 1
- Loading branch information
1 parent
9ae1fce
commit 2564a05
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
src/_base/helm/app/templates/horizontal-pod-autoscaler.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{{- range $serviceName, $service := .Values.services -}} | ||
{{- with $service }} | ||
{{- $autoscaling := .autoscaling | default (dict) -}} | ||
{{- if and (not (hasPrefix "." $serviceName)) .enabled $autoscaling.enabled }} | ||
--- | ||
apiVersion: autoscaling/v2beta2 | ||
kind: HorizontalPodAutoscaler | ||
metadata: | ||
name: {{ print $.Release.Name "-" $serviceName }} | ||
labels: | ||
{{- include "chart.labels" $ | nindent 4 }} | ||
app.kubernetes.io/component: {{ $serviceName }} | ||
app.service: {{ print $.Release.Name "-" $serviceName }} | ||
annotations: | ||
argocd.argoproj.io/sync-wave: "15" | ||
spec: | ||
{{- with (omit $autoscaling "enabled" "metrics") }} | ||
{{- . | toYaml | nindent 2 }} | ||
{{- end }} | ||
metrics: | ||
{{- with $autoscaling.metrics }} | ||
{{- . | toYaml | nindent 4 }} | ||
{{- end }} | ||
{{- with $autoscaling.targetMemoryUtilizationPercentage }} | ||
- type: Resource | ||
resource: | ||
name: memory | ||
targetAverageUtilization: {{ . }} | ||
{{- end }} | ||
{{- with $autoscaling.targetCPUUtilizationPercentage }} | ||
- type: Resource | ||
resource: | ||
name: cpu | ||
target: | ||
type: Utilization | ||
averageUtilization: {{ . }} | ||
{{- end }} | ||
scaleTargetRef: | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
name: {{ print $.Release.Name "-" $serviceName }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{{- range $serviceName, $service := .Values.services -}} | ||
{{- with $service }} | ||
{{- if and (not (hasPrefix "." $serviceName)) .enabled }} | ||
{{- $autoscaling := .autoscaling | default (dict "minReplicas" 0) -}} | ||
{{- if or (gt (.replicas | default 1) 1) (and $autoscaling.enabled (gt $autoscaling.minReplicas 1)) }} | ||
--- | ||
apiVersion: policy/v1beta1 | ||
kind: PodDisruptionBudget | ||
metadata: | ||
name: {{ print $.Values.resourcePrefix $serviceName }} | ||
labels: | ||
{{- include "chart.labels" $ | nindent 4 }} | ||
app.kubernetes.io/component: {{ $serviceName}} | ||
app.service: {{ print $.Values.resourcePrefix $serviceName }} | ||
annotations: | ||
argocd.argoproj.io/sync-wave: "15" | ||
spec: | ||
minAvailable: {{- .minAvailable | default 1 }} | ||
selector: | ||
matchLabels: | ||
app.service: {{ print $.Values.resourcePrefix $serviceName }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} |