diff --git a/devops/azure/chart/helm-config.yaml b/devops/azure/chart/helm-config.yaml index 2be1682717f591beab15bcaab8ab7d365fa5feaf..cfcfdb375897fd6285e0196bcc93a13ff056dbbb 100644 --- a/devops/azure/chart/helm-config.yaml +++ b/devops/azure/chart/helm-config.yaml @@ -3,6 +3,8 @@ global: # Service(s) Replica Count replicaCount: 2 + maxReplicaCount: 20 + minReplicaCount: 4 nodepool: services isAutoscalingEnabled: false @@ -23,3 +25,5 @@ featureFlag: resourceLimits: enabledEnvs: - demo + hpa: + enabledEnvs: [] diff --git a/devops/azure/chart/templates/deployment.yaml b/devops/azure/chart/templates/deployment.yaml index 9d69bc4b8487c7d7c4050e800c380bcc76556d00..62c0be7e4a980d4affbf2ca44138f5b6401e99a1 100644 --- a/devops/azure/chart/templates/deployment.yaml +++ b/devops/azure/chart/templates/deployment.yaml @@ -18,7 +18,10 @@ metadata: name: {{ .Release.Name }} namespace: osdu spec: + {{- if has .Values.env .Values.featureFlag.hpa.enabledEnvs }} + {{- else }} replicas: {{ .Values.global.replicaCount }} + {{- end }} selector: matchLabels: app: {{ .Chart.Name }} diff --git a/devops/azure/chart/templates/hpa.yaml b/devops/azure/chart/templates/hpa.yaml new file mode 100644 index 0000000000000000000000000000000000000000..29591611b8db6055ff6c36342e4be239f4dc8656 --- /dev/null +++ b/devops/azure/chart/templates/hpa.yaml @@ -0,0 +1,51 @@ +# Copyright © Microsoft Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +{{- if has .Values.env .Values.featureFlag.hpa.enabledEnvs }} +apiVersion: autoscaling/v2beta2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Chart.Name }} + namespace: osdu +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ .Chart.Name }} + minReplicas: {{ .Values.global.minReplicaCount }} + maxReplicas: {{ .Values.global.maxReplicaCount }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 50 + behavior: + scaleDown: + stabilizationWindowSeconds: 150 + policies: + - type: Pods + value: 2 + periodSeconds: 30 + scaleUp: + stabilizationWindowSeconds: 10 + selectPolicy: Max + policies: + - type: Pods + value: 6 + periodSeconds: 10 + - type: Percent + value: 50 + periodSeconds: 10 +{{- end }} \ No newline at end of file diff --git a/devops/azure/chart/values.yaml b/devops/azure/chart/values.yaml index 9c987e7e65b5187ddf59a93ec4ba947223173f41..dedff49947ecc41623bc569a3ea6555ca7451213 100644 --- a/devops/azure/chart/values.yaml +++ b/devops/azure/chart/values.yaml @@ -14,6 +14,8 @@ global: replicaCount: 1 + maxReplicaCount: 1 + minReplicaCount: 1 nodepool: services isAutoscalingEnabled: false @@ -30,3 +32,5 @@ featureFlag: resourceLimits: enabledEnvs: - demo + hpa: + enabledEnvs: []