Add autoscaler for applications (#525)

- Transition to min/max instances instead of total instances
This commit is contained in:
Erèbe - Romain Gerard
2021-12-14 16:39:06 +01:00
committed by GitHub
parent 52b8fd5549
commit 739e3d12e9
33 changed files with 224 additions and 73 deletions

View File

@@ -13,10 +13,10 @@ metadata:
annotations:
releaseTime: {% raw %}{{ dateInZone "2006-01-02 15:04:05Z" (now) "UTC"| quote }}{% endraw %}
spec:
replicas: {{ total_instances }}
replicas: {{ min_instances }}
strategy:
type: RollingUpdate
{% if total_instances == 1 %}
{% if max_instances == 1 %}
rollingUpdate:
maxSurge: 1
{% endif %}

View File

@@ -0,0 +1,19 @@
{%- if not is_storage and min_instances != max_instances %}
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: {{ sanitized_name }}
namespace: {{ namespace }}
labels:
envId: {{ environment_id }}
appId: {{ id }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ sanitized_name }}
minReplicas: {{ min_instances }}
maxReplicas: {{ max_instances }}
targetCPUUtilizationPercentage: 60
{%- endif %}

View File

@@ -13,7 +13,7 @@ metadata:
annotations:
releaseTime: {% raw %}{{ dateInZone "2006-01-02 15:04:05Z" (now) "UTC"| quote }}{% endraw %}
spec:
replicas: {{ total_instances }}
replicas: {{ min_instances }}
serviceName: {{ sanitized_name }}
selector:
matchLabels: