From 20020fb1057d5ed44349910234110482c3aa3bc4 Mon Sep 17 00:00:00 2001 From: Kelly Zhou <yzhou35@slb.com> Date: Fri, 5 Nov 2021 18:56:34 +0000 Subject: [PATCH] Setup hpa for partition service --- devops/azure/chart/helm-config.yaml | 4 ++ devops/azure/chart/templates/deployment.yaml | 3 ++ devops/azure/chart/templates/hpa.yaml | 51 ++++++++++++++++++++ devops/azure/chart/values.yaml | 4 ++ 4 files changed, 62 insertions(+) create mode 100644 devops/azure/chart/templates/hpa.yaml diff --git a/devops/azure/chart/helm-config.yaml b/devops/azure/chart/helm-config.yaml index 2be168271..cfcfdb375 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 9d69bc4b8..62c0be7e4 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 000000000..29591611b --- /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 9c987e7e6..dedff4994 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: [] -- GitLab