diff --git a/charts/vineyard-operator/templates/hpa.yaml b/charts/vineyard-operator/templates/hpa.yaml new file mode 100644 index 000000000..84662fc0b --- /dev/null +++ b/charts/vineyard-operator/templates/hpa.yaml @@ -0,0 +1,34 @@ +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "vineyard-operator.fullname" . }}-hpa + labels: + {{- include "vineyard-operator.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + 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: {{ .Values.autoscaling.targetMemoryUtilization }} + behavior: + scaleUp: + policies: + - type: Pods + value: {{ .Values.autoscaling.scaleUp.pods }} + periodSeconds: {{ .Values.autoscaling.scaleUp.periodSeconds }} + selectPolicy: Max + stabilizationWindowSeconds: {{ .Values.autoscaling.scaleUp.stabilizationWindowSeconds }} + scaleDown: + policies: + - type: Percent + 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