diff --git a/templates/deployment.yaml b/templates/deployment.yaml index c269b20..fb5e74a 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -23,6 +23,14 @@ spec: - name: {{ .Chart.Name }} image: "{{ .Values.image.repository }}/{{ .Values.image.name }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} + #TODO: Need to add requests and limits for every container + # resources: + # requests: + # memory: "1Gi" + # cpu: "1000m" + # limits: + # memory: "1Gi" + # cpu: "1000m" ports: - name: http containerPort: {{ .Values.service.port }} diff --git a/templates/hpa.yaml b/templates/hpa.yaml new file mode 100644 index 0000000..eec6269 --- /dev/null +++ b/templates/hpa.yaml @@ -0,0 +1,19 @@ +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Release.Name }}-hpa + namespace: {{ .Values.namespace }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ .Release.Name }}-deployment + minReplicas: {{ .Values.hpa.minReplicas }} + maxReplicas: {{ .Values.hpa.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.hpa.metrics.averageUtilization }} diff --git a/values.yaml b/values.yaml index 1bf170a..f900e77 100644 --- a/values.yaml +++ b/values.yaml @@ -22,6 +22,13 @@ imagePullSecrets: namespace: webapp +hpa: + metrics: + averageUtilization: 20 + + minReplicas: 1 + maxReplicas: 7 + deployStrat: rolling: RollingUpdate maxSurge: 1