|
| 1 | +{{- if .Values.automaticScaleDown.enabled }} |
| 2 | +{{ $vclusterContext := (index .Subcharts "vcluster")}} |
| 3 | +apiVersion: http.keda.sh/v1alpha1 |
| 4 | +kind: HTTPScaledObject |
| 5 | +metadata: |
| 6 | + name: {{ .Release.Name }} |
| 7 | + annotations: |
| 8 | + # Workaround for idleReplicaCount - https://github.com/kedacore/http-add-on/pull/594 |
| 9 | + httpscaledobject.keda.sh/skip-scaledobject-creation: "true" |
| 10 | +spec: |
| 11 | + hosts: |
| 12 | + {{- if .Values.global.ingress.internal.enabled }} |
| 13 | + - {{ tpl (printf "%s.%s" .Values.global.ingress.internal.host.name .Values.global.ingress.internal.host.domain) . }} |
| 14 | + {{- else if .Values.global.ingress.public.enabled }} |
| 15 | + - {{ tpl (printf "%s.%s" .Values.global.ingress.public.host.name .Values.global.ingress.public.host.domain) . }} |
| 16 | + {{- else }} |
| 17 | + - {{ fail "Cannot enable autoScaledown if no ingress is enabled" }} |
| 18 | + {{- end }} |
| 19 | + scaleTargetRef: |
| 20 | + name: {{ .Release.Name }} |
| 21 | + kind: {{ include "vcluster.kind" $vclusterContext }} |
| 22 | + apiVersion: apps/v1 |
| 23 | + service: {{ .Release.Name }} |
| 24 | + port: 443 |
| 25 | + replicas: |
| 26 | + min: {{ $vclusterContext.Values.controlPlane.statefulSet.highAvailability.replicas }} |
| 27 | + max: {{ $vclusterContext.Values.controlPlane.statefulSet.highAvailability.replicas }} |
| 28 | + scaledownPeriod: {{ .Values.automaticScaleDown.periodSeconds }} |
| 29 | + scalingMetric: |
| 30 | + requestRate: |
| 31 | + granularity: 1s |
| 32 | + targetValue: 1 |
| 33 | + window: 1m |
| 34 | +--- |
| 35 | +# Workaround for idleReplicaCount - https://github.com/kedacore/http-add-on/pull/594 |
| 36 | +apiVersion: keda.sh/v1alpha1 |
| 37 | +kind: ScaledObject |
| 38 | +metadata: |
| 39 | + name: {{ .Release.Name }} |
| 40 | +spec: |
| 41 | + advanced: |
| 42 | + restoreToOriginalReplicaCount: true |
| 43 | + scalingModifiers: {} |
| 44 | + initialCooldownPeriod: {{ .Values.automaticScaleDown.initialCooldownPeriod }} |
| 45 | + cooldownPeriod: {{ .Values.automaticScaleDown.periodSeconds }} |
| 46 | + maxReplicaCount: {{ $vclusterContext.Values.controlPlane.statefulSet.highAvailability.replicas }} |
| 47 | + minReplicaCount: {{ $vclusterContext.Values.controlPlane.statefulSet.highAvailability.replicas }} |
| 48 | + idleReplicaCount: 0 |
| 49 | + pollingInterval: 15 |
| 50 | + scaleTargetRef: |
| 51 | + apiVersion: apps/v1 |
| 52 | + kind: {{ include "vcluster.kind" $vclusterContext }} |
| 53 | + name: {{ .Release.Name }} |
| 54 | + triggers: |
| 55 | + - metadata: |
| 56 | + httpScaledObject: {{ .Release.Name }} |
| 57 | + scalerAddress: {{ printf "%s:%d" .Values.automaticScaleDown.httpScaler.host (int64 .Values.automaticScaleDown.httpScaler.port) }} |
| 58 | + type: external-push |
| 59 | +{{- end }} |
0 commit comments