From 1ef4460d44273022bb04d412b6c567f3338b1abb Mon Sep 17 00:00:00 2001 From: Angelo Bradley <92221369+AngeloB-AIS@users.noreply.github.com> Date: Fri, 27 Sep 2024 19:16:04 -0400 Subject: [PATCH] feature: added templates for horizontal pod autoscaling (#43) * updated configmap name in all files * feature: updated postgres name * feature: updated server name, debugged changes * feature: updated ui name and debugged * feature: fixed worker name * feature: fixed temporal naming * feature: removed unnecessary acme challenge resources * revert namespace back to just multiwoven * change env name from suffix to prefix: configmap * change env name from suffix to prefix: ingress * change env name from suffix to prefix: postgresql deployment/service * change env name from suffix to prefix: postgresql pvc * change env name from suffix to prefix: server * change env name from suffix to prefix: ui * change env name from suffix to prefix: worker * change env name from suffix to prefix: temporal * change env name from suffix to prefix: temporal in ingress template * feature: added templates for horizontal pod autoscaling * feature: parameterize hpa values * fix: make hpa optional and better organized hpa values in values.yaml * feature: add hpa scaling behavior controls * feature: add labels for better management and organization * fix: decreased memory threshold for worker and server hpa * feature: parameterized temporalHost and postgresql default values * fix: added app env to workflow deployment names * feature: added hpa flags to helm upgrade command in workflow * fix: added tab for set flags to workflow * fix: fixed newline flag * fix: fixed hpa conditional statement and added app env prefix to target ref * fix: fixed value reference in server and ui templates * fix: fixed worker hpa target ref name * fix: removed hpa set flags from workflow * fix: remove appEnv prefix * fix: remove appEnv from workflow file * fix: add forward slack to workflow file * fix: remove appEnv from values file * fix: removed community from temporal hostname * fix: removed unused hpa values from values file * fix: update chart version * fix: upgraded default memory limits based on hpa output * fix: adjusting baseline values for efficient hpa --- charts/multiwoven/Chart.yaml | 4 +- .../templates/multiwoven-server-hpa.yaml | 47 ++++++++ .../templates/multiwoven-ui-hpa.yaml | 47 ++++++++ .../templates/multiwoven-worker-hpa.yaml | 47 ++++++++ charts/multiwoven/values.yaml | 112 ++++++++++++++++-- 5 files changed, 246 insertions(+), 11 deletions(-) create mode 100644 charts/multiwoven/templates/multiwoven-server-hpa.yaml create mode 100644 charts/multiwoven/templates/multiwoven-ui-hpa.yaml create mode 100644 charts/multiwoven/templates/multiwoven-worker-hpa.yaml diff --git a/charts/multiwoven/Chart.yaml b/charts/multiwoven/Chart.yaml index 13cebc3..f2488f8 100644 --- a/charts/multiwoven/Chart.yaml +++ b/charts/multiwoven/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: multiwoven description: Open-source reverse ETL, an alternative to Hightouch, Census etc. 🔥 type: application -version: 0.26.0 -appVersion: "0.26.0" +version: 0.27.0 +appVersion: "0.27.0" maintainers: - name: subintp - name: RafaelOAiSquared diff --git a/charts/multiwoven/templates/multiwoven-server-hpa.yaml b/charts/multiwoven/templates/multiwoven-server-hpa.yaml new file mode 100644 index 0000000..e604f01 --- /dev/null +++ b/charts/multiwoven/templates/multiwoven-server-hpa.yaml @@ -0,0 +1,47 @@ +{{ if .Values.hpa.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "chart.fullname" . }}-server-hpa + namespace: {{ .Values.kubernetesNamespace }} + labels: + {{- include "chart.labels" . | nindent 4 }} + app.kubernetes.io/component: server-hpa +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "chart.fullname" . }}-server + minReplicas: {{ .Values.hpa.multiwovenServer.minReplicas }} + maxReplicas: {{ .Values.hpa.multiwovenServer.maxReplicas }} + behavior: + scaleDown: + stabilizationWindowSeconds: {{ .Values.hpa.multiwovenServer.behavior.scaleDown.stabilizationWindowSeconds }} + policies: + - type: {{ .Values.hpa.multiwovenServer.behavior.scaleDown.policies.percentPolicy.type }} + value: {{ .Values.hpa.multiwovenServer.behavior.scaleDown.policies.percentPolicy.value }} + periodSeconds: {{ .Values.hpa.multiwovenServer.behavior.scaleDown.policies.percentPolicy.periodSeconds }} + scaleUp: + stabilizationWindowSeconds: {{ .Values.hpa.multiwovenServer.behavior.scaleUp.stabilizationWindowSeconds }} + policies: + - type: {{ .Values.hpa.multiwovenServer.behavior.scaleUp.policies.percentPolicy.type }} + value: {{ .Values.hpa.multiwovenServer.behavior.scaleUp.policies.percentPolicy.value }} + periodSeconds: {{ .Values.hpa.multiwovenServer.behavior.scaleUp.policies.percentPolicy.periodSeconds }} + - type: {{ .Values.hpa.multiwovenServer.behavior.scaleUp.policies.podPolicy.type }} + value: {{ .Values.hpa.multiwovenServer.behavior.scaleUp.policies.podPolicy.value }} + periodSeconds: {{ .Values.hpa.multiwovenServer.behavior.scaleUp.policies.podPolicy.periodSeconds }} + selectPolicy: {{ .Values.hpa.multiwovenServer.behavior.scaleUp.policies.selectPolicy }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.hpa.multiwovenServer.cpuAverageUtilizationPercentageThreshold }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.hpa.multiwovenServer.memoryAverageUtilizationPercentageThreshold }} +{{ end }} \ No newline at end of file diff --git a/charts/multiwoven/templates/multiwoven-ui-hpa.yaml b/charts/multiwoven/templates/multiwoven-ui-hpa.yaml new file mode 100644 index 0000000..113bb13 --- /dev/null +++ b/charts/multiwoven/templates/multiwoven-ui-hpa.yaml @@ -0,0 +1,47 @@ +{{ if .Values.hpa.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "chart.fullname" . }}-ui-hpa + namespace: {{ .Values.kubernetesNamespace }} + labels: + {{- include "chart.labels" . | nindent 4 }} + app.kubernetes.io/component: ui-hpa +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "chart.fullname" . }}-ui + minReplicas: {{ .Values.hpa.multiwovenUI.minReplicas }} + maxReplicas: {{ .Values.hpa.multiwovenUI.maxReplicas }} + behavior: + scaleDown: + stabilizationWindowSeconds: {{ .Values.hpa.multiwovenUI.behavior.scaleDown.stabilizationWindowSeconds }} + policies: + - type: {{ .Values.hpa.multiwovenUI.behavior.scaleDown.policies.percentPolicy.type }} + value: {{ .Values.hpa.multiwovenUI.behavior.scaleDown.policies.percentPolicy.value }} + periodSeconds: {{ .Values.hpa.multiwovenUI.behavior.scaleDown.policies.percentPolicy.periodSeconds }} + scaleUp: + stabilizationWindowSeconds: {{ .Values.hpa.multiwovenUI.behavior.scaleUp.stabilizationWindowSeconds }} + policies: + - type: {{ .Values.hpa.multiwovenUI.behavior.scaleUp.policies.percentPolicy.type }} + value: {{ .Values.hpa.multiwovenUI.behavior.scaleUp.policies.percentPolicy.value }} + periodSeconds: {{ .Values.hpa.multiwovenUI.behavior.scaleUp.policies.percentPolicy.periodSeconds }} + - type: {{ .Values.hpa.multiwovenUI.behavior.scaleUp.policies.podPolicy.type }} + value: {{ .Values.hpa.multiwovenUI.behavior.scaleUp.policies.podPolicy.value }} + periodSeconds: {{ .Values.hpa.multiwovenUI.behavior.scaleUp.policies.podPolicy.periodSeconds }} + selectPolicy: {{ .Values.hpa.multiwovenUI.behavior.scaleUp.policies.selectPolicy }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.hpa.multiwovenUI.cpuAverageUtilizationPercentageThreshold }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.hpa.multiwovenUI.memoryAverageUtilizationPercentageThreshold }} +{{ end }} \ No newline at end of file diff --git a/charts/multiwoven/templates/multiwoven-worker-hpa.yaml b/charts/multiwoven/templates/multiwoven-worker-hpa.yaml new file mode 100644 index 0000000..d2a250d --- /dev/null +++ b/charts/multiwoven/templates/multiwoven-worker-hpa.yaml @@ -0,0 +1,47 @@ +{{ if .Values.hpa.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "chart.fullname" . }}-worker-hpa + namespace: {{ .Values.kubernetesNamespace }} + labels: + {{- include "chart.labels" . | nindent 4 }} + app.kubernetes.io/component: worker-hpa +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "chart.fullname" . }}-worker + minReplicas: {{ .Values.hpa.multiwovenWorker.minReplicas }} + maxReplicas: {{ .Values.hpa.multiwovenWorker.maxReplicas }} + behavior: + scaleDown: + stabilizationWindowSeconds: {{ .Values.hpa.multiwovenWorker.behavior.scaleDown.stabilizationWindowSeconds }} + policies: + - type: {{ .Values.hpa.multiwovenWorker.behavior.scaleDown.policies.percentPolicy.type }} + value: {{ .Values.hpa.multiwovenWorker.behavior.scaleDown.policies.percentPolicy.value }} + periodSeconds: {{ .Values.hpa.multiwovenWorker.behavior.scaleDown.policies.percentPolicy.periodSeconds }} + scaleUp: + stabilizationWindowSeconds: {{ .Values.hpa.multiwovenWorker.behavior.scaleUp.stabilizationWindowSeconds }} + policies: + - type: {{ .Values.hpa.multiwovenWorker.behavior.scaleUp.policies.percentPolicy.type }} + value: {{ .Values.hpa.multiwovenWorker.behavior.scaleUp.policies.percentPolicy.value }} + periodSeconds: {{ .Values.hpa.multiwovenWorker.behavior.scaleUp.policies.percentPolicy.periodSeconds }} + - type: {{ .Values.hpa.multiwovenWorker.behavior.scaleUp.policies.podPolicy.type }} + value: {{ .Values.hpa.multiwovenWorker.behavior.scaleUp.policies.podPolicy.value }} + periodSeconds: {{ .Values.hpa.multiwovenWorker.behavior.scaleUp.policies.podPolicy.periodSeconds }} + selectPolicy: {{ .Values.hpa.multiwovenWorker.behavior.scaleUp.policies.selectPolicy }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.hpa.multiwovenWorker.cpuAverageUtilizationPercentageThreshold }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.hpa.multiwovenWorker.memoryAverageUtilizationPercentageThreshold }} +{{ end }} \ No newline at end of file diff --git a/charts/multiwoven/values.yaml b/charts/multiwoven/values.yaml index 9a71011..93075b5 100644 --- a/charts/multiwoven/values.yaml +++ b/charts/multiwoven/values.yaml @@ -61,6 +61,100 @@ multiwovenConfig: viteBrandColor: "" viteBrandHoverColor: "" viteFavIconUrl: "" + +hpa: + enabled: true + multiwovenUI: + minReplicas: 1 + maxReplicas: 10 + cpuAverageUtilizationPercentageThreshold: 80 + memoryAverageUtilizationPercentageThreshold: 75 + behavior: + scaleDown: + stabilizationWindowSeconds: 300 + policies: + percentPolicy: + type: Percent + value: 100 + periodSeconds: 15 + podPolicy: + type: Percent + value: 100 + periodSeconds: 15 + selectPolicy: Max + scaleUp: + stabilizationWindowSeconds: 45 + policies: + percentPolicy: + type: Percent + value: 100 + periodSeconds: 15 + podPolicy: + type: Pods + value: 4 + periodSeconds: 15 + selectPolicy: Max + multiwovenServer: + minReplicas: 1 + maxReplicas: 10 + cpuAverageUtilizationPercentageThreshold: 80 + memoryAverageUtilizationPercentageThreshold: 60 + behavior: + scaleDown: + stabilizationWindowSeconds: 300 + policies: + percentPolicy: + type: Percent + value: 100 + periodSeconds: 15 + podPolicy: + type: Percent + value: 100 + periodSeconds: 15 + selectPolicy: Max + scaleUp: + stabilizationWindowSeconds: 45 + policies: + percentPolicy: + type: Percent + value: 100 + periodSeconds: 15 + podPolicy: + type: Pods + value: 4 + periodSeconds: 15 + selectPolicy: Max + multiwovenWorker: + minReplicas: 1 + maxReplicas: 10 + cpuAverageUtilizationPercentageThreshold: 80 + memoryAverageUtilizationPercentageThreshold: 50 + behavior: + scaleDown: + stabilizationWindowSeconds: 300 + policies: + percentPolicy: + type: Percent + value: 100 + periodSeconds: 15 + podPolicy: + type: Percent + value: 100 + periodSeconds: 15 + selectPolicy: Max + scaleUp: + stabilizationWindowSeconds: 45 + policies: + percentPolicy: + type: Percent + value: 100 + periodSeconds: 15 + podPolicy: + type: Pods + value: 4 + periodSeconds: 15 + selectPolicy: Max + multiwovenPostgresql: enabled: true multiwovenPostgresql: @@ -88,10 +182,10 @@ multiwovenServer: resources: limits: cpu: "2" - memory: 2Gi + memory: "3Gi" requests: cpu: "1" - memory: 1Gi + memory: "1Gi" ports: - name: "3000" port: 3000 @@ -105,11 +199,11 @@ multiwovenUI: tag: latest resources: limits: - cpu: "2" - memory: 2Gi + cpu: "200m" + memory: "512Mi" requests: - cpu: "1" - memory: 1Gi + cpu: "100m" + memory: "256Mi" ports: - name: "8000" port: 8000 @@ -130,10 +224,10 @@ multiwovenWorker: resources: limits: cpu: "1" - memory: 1Gi + memory: 2Gi requests: - cpu: 500m - memory: 512Mi + cpu: "500m" + memory: 1Gi replicas: 1 pvc: pvc: