From 68ba301fe17f96a43b144227bcce493dbdcf8fca Mon Sep 17 00:00:00 2001 From: Rajdeep Pal <113296626+Rajdeep1311@users.noreply.github.com> Date: Wed, 30 Jul 2025 13:37:41 +0530 Subject: [PATCH 1/5] Create hpa.yaml Signed-off-by: Rajdeep Pal --- charts/vineyard-operator/templates/hpa.yaml | 33 +++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 charts/vineyard-operator/templates/hpa.yaml diff --git a/charts/vineyard-operator/templates/hpa.yaml b/charts/vineyard-operator/templates/hpa.yaml new file mode 100644 index 000000000..e654dcf0c --- /dev/null +++ b/charts/vineyard-operator/templates/hpa.yaml @@ -0,0 +1,33 @@ +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: vineyard-memory-hpa + namespace: vineyard-system +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: vineyard-controller-manager + minReplicas: 2 + maxReplicas: 10 + metrics: + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: 50 # Target 50% memory usage + behavior: + scaleUp: + policies: + - type: Pods + value: 2 # Add 2 pods at once when scaling up + periodSeconds: 15 # Check frequently during scale-up + selectPolicy: Max + stabilizationWindowSeconds: 0 # React immediately to spikes + scaleDown: + policies: + - type: Percent + value: 50 # Remove up to 50% of pods at once + periodSeconds: 60 + stabilizationWindowSeconds: 300 # Wait 5 minutes before scaling down From 10d034a85ef37144029a84a0aec8ce6824ea88ab Mon Sep 17 00:00:00 2001 From: Rajdeep Pal Date: Wed, 30 Jul 2025 14:24:00 +0530 Subject: [PATCH 2/5] created HPA Signed-off-by: Rajdeep Pal --- charts/vineyard-operator/templates/hpa.yaml | 33 --------------------- 1 file changed, 33 deletions(-) diff --git a/charts/vineyard-operator/templates/hpa.yaml b/charts/vineyard-operator/templates/hpa.yaml index e654dcf0c..e69de29bb 100644 --- a/charts/vineyard-operator/templates/hpa.yaml +++ b/charts/vineyard-operator/templates/hpa.yaml @@ -1,33 +0,0 @@ -apiVersion: autoscaling/v2 -kind: HorizontalPodAutoscaler -metadata: - name: vineyard-memory-hpa - namespace: vineyard-system -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: vineyard-controller-manager - minReplicas: 2 - maxReplicas: 10 - metrics: - - type: Resource - resource: - name: memory - target: - type: Utilization - averageUtilization: 50 # Target 50% memory usage - behavior: - scaleUp: - policies: - - type: Pods - value: 2 # Add 2 pods at once when scaling up - periodSeconds: 15 # Check frequently during scale-up - selectPolicy: Max - stabilizationWindowSeconds: 0 # React immediately to spikes - scaleDown: - policies: - - type: Percent - value: 50 # Remove up to 50% of pods at once - periodSeconds: 60 - stabilizationWindowSeconds: 300 # Wait 5 minutes before scaling down From 804968d09bd48eced92a2d2cfdb987c00e10e873 Mon Sep 17 00:00:00 2001 From: Rajdeep Pal Date: Wed, 30 Jul 2025 14:53:26 +0530 Subject: [PATCH 3/5] created a yaml file for HPA Signed-off-by: Rajdeep Pal --- charts/vineyard-operator/templates/hpa.yaml | 33 +++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/charts/vineyard-operator/templates/hpa.yaml b/charts/vineyard-operator/templates/hpa.yaml index e69de29bb..e654dcf0c 100644 --- a/charts/vineyard-operator/templates/hpa.yaml +++ b/charts/vineyard-operator/templates/hpa.yaml @@ -0,0 +1,33 @@ +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: vineyard-memory-hpa + namespace: vineyard-system +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: vineyard-controller-manager + minReplicas: 2 + maxReplicas: 10 + metrics: + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: 50 # Target 50% memory usage + behavior: + scaleUp: + policies: + - type: Pods + value: 2 # Add 2 pods at once when scaling up + periodSeconds: 15 # Check frequently during scale-up + selectPolicy: Max + stabilizationWindowSeconds: 0 # React immediately to spikes + scaleDown: + policies: + - type: Percent + value: 50 # Remove up to 50% of pods at once + periodSeconds: 60 + stabilizationWindowSeconds: 300 # Wait 5 minutes before scaling down From 7c1b5d6b80e1e6657f19a9f966f31bf78318d729 Mon Sep 17 00:00:00 2001 From: Rajdeep Pal Date: Wed, 30 Jul 2025 19:57:07 +0530 Subject: [PATCH 4/5] Updated hpa.yaml and values.yaml Signed-off-by: Rajdeep Pal --- .../templates/hpa-vineyard.yaml | 33 +++++++++++++++++++ charts/vineyard-operator/templates/hpa.yaml | 25 +++++++------- charts/vineyard-operator/values.yaml | 15 +++++++++ 3 files changed, 61 insertions(+), 12 deletions(-) create mode 100644 charts/vineyard-operator/templates/hpa-vineyard.yaml diff --git a/charts/vineyard-operator/templates/hpa-vineyard.yaml b/charts/vineyard-operator/templates/hpa-vineyard.yaml new file mode 100644 index 000000000..e654dcf0c --- /dev/null +++ b/charts/vineyard-operator/templates/hpa-vineyard.yaml @@ -0,0 +1,33 @@ +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: vineyard-memory-hpa + namespace: vineyard-system +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: vineyard-controller-manager + minReplicas: 2 + maxReplicas: 10 + metrics: + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: 50 # Target 50% memory usage + behavior: + scaleUp: + policies: + - type: Pods + value: 2 # Add 2 pods at once when scaling up + periodSeconds: 15 # Check frequently during scale-up + selectPolicy: Max + stabilizationWindowSeconds: 0 # React immediately to spikes + scaleDown: + policies: + - type: Percent + value: 50 # Remove up to 50% of pods at once + periodSeconds: 60 + stabilizationWindowSeconds: 300 # Wait 5 minutes before scaling down diff --git a/charts/vineyard-operator/templates/hpa.yaml b/charts/vineyard-operator/templates/hpa.yaml index e654dcf0c..84662fc0b 100644 --- a/charts/vineyard-operator/templates/hpa.yaml +++ b/charts/vineyard-operator/templates/hpa.yaml @@ -1,33 +1,34 @@ apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: - name: vineyard-memory-hpa - namespace: vineyard-system + name: {{ include "vineyard-operator.fullname" . }}-hpa + labels: + {{- include "vineyard-operator.labels" . | nindent 4 }} spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment - name: vineyard-controller-manager - minReplicas: 2 - maxReplicas: 10 + name: {{ include "vineyard-operator.fullname" . }}-controller-manager + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} metrics: - type: Resource resource: name: memory target: type: Utilization - averageUtilization: 50 # Target 50% memory usage + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilization }} behavior: scaleUp: policies: - type: Pods - value: 2 # Add 2 pods at once when scaling up - periodSeconds: 15 # Check frequently during scale-up + value: {{ .Values.autoscaling.scaleUp.pods }} + periodSeconds: {{ .Values.autoscaling.scaleUp.periodSeconds }} selectPolicy: Max - stabilizationWindowSeconds: 0 # React immediately to spikes + stabilizationWindowSeconds: {{ .Values.autoscaling.scaleUp.stabilizationWindowSeconds }} scaleDown: policies: - type: Percent - value: 50 # Remove up to 50% of pods at once - periodSeconds: 60 - stabilizationWindowSeconds: 300 # Wait 5 minutes before scaling down + value: {{ .Values.autoscaling.scaleDown.percent }} + periodSeconds: {{ .Values.autoscaling.scaleDown.periodSeconds }} + stabilizationWindowSeconds: {{ .Values.autoscaling.scaleDown.stabilizationWindowSeconds }} diff --git a/charts/vineyard-operator/values.yaml b/charts/vineyard-operator/values.yaml index 946bf6c06..6d75b7a10 100644 --- a/charts/vineyard-operator/values.yaml +++ b/charts/vineyard-operator/values.yaml @@ -41,4 +41,19 @@ webhookService: protocol: TCP targetPort: 9443 type: ClusterIP +autoscaling: + enabled: true + minReplicas: 2 + maxReplicas: 10 + targetMemoryUtilization: 50 + + scaleUp: + pods: 2 + periodSeconds: 15 + stabilizationWindowSeconds: 0 + + scaleDown: + percent: 50 + periodSeconds: 60 + stabilizationWindowSeconds: 300 fullnameOverride: vineyard From 8d02f3c57a6cd2fbc777781710a72ef5d2a092cb Mon Sep 17 00:00:00 2001 From: Rajdeep Pal Date: Wed, 30 Jul 2025 20:04:48 +0530 Subject: [PATCH 5/5] Updated hpa.yaml and values.yaml Signed-off-by: Rajdeep Pal --- .../templates/hpa-vineyard.yaml | 33 ------------------- 1 file changed, 33 deletions(-) delete mode 100644 charts/vineyard-operator/templates/hpa-vineyard.yaml diff --git a/charts/vineyard-operator/templates/hpa-vineyard.yaml b/charts/vineyard-operator/templates/hpa-vineyard.yaml deleted file mode 100644 index e654dcf0c..000000000 --- a/charts/vineyard-operator/templates/hpa-vineyard.yaml +++ /dev/null @@ -1,33 +0,0 @@ -apiVersion: autoscaling/v2 -kind: HorizontalPodAutoscaler -metadata: - name: vineyard-memory-hpa - namespace: vineyard-system -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: vineyard-controller-manager - minReplicas: 2 - maxReplicas: 10 - metrics: - - type: Resource - resource: - name: memory - target: - type: Utilization - averageUtilization: 50 # Target 50% memory usage - behavior: - scaleUp: - policies: - - type: Pods - value: 2 # Add 2 pods at once when scaling up - periodSeconds: 15 # Check frequently during scale-up - selectPolicy: Max - stabilizationWindowSeconds: 0 # React immediately to spikes - scaleDown: - policies: - - type: Percent - value: 50 # Remove up to 50% of pods at once - periodSeconds: 60 - stabilizationWindowSeconds: 300 # Wait 5 minutes before scaling down