From cfa3eca7bdeb501763f0e23e9e177a5de90d6958 Mon Sep 17 00:00:00 2001 From: Scott Bishop Date: Wed, 12 Dec 2018 15:08:49 -0800 Subject: [PATCH 1/2] add horizontal pod auto scale at 80% cpu usage --- vizzy/templates/scaling.yaml | 17 +++++++++++++++++ vizzy/values.yaml | 1 + 2 files changed, 18 insertions(+) create mode 100644 vizzy/templates/scaling.yaml diff --git a/vizzy/templates/scaling.yaml b/vizzy/templates/scaling.yaml new file mode 100644 index 0000000..f91b2af --- /dev/null +++ b/vizzy/templates/scaling.yaml @@ -0,0 +1,17 @@ +apiVersion: autoscaling/v1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Chart.Name }} + labels: + app: {{ .Chart.Name }} + chart: {{ .Chart.Name }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + maxReplicas: {{ .Values.maxReplica }} + minReplicas: {{ .Values.replicaCount }} + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ .Chart.Name }} + targetCPUUtilizationPercentage: 80 \ No newline at end of file diff --git a/vizzy/values.yaml b/vizzy/values.yaml index 234468c..7d9a69d 100644 --- a/vizzy/values.yaml +++ b/vizzy/values.yaml @@ -3,6 +3,7 @@ # Declare variables to be passed into your templates. replicaCount: 5 +maxReplica: 15 image: repository: scottcbishop/vizzy tag: v3.1.1 From ffda7d4cd1914fba07483bdb4b6d3e83719ff3e1 Mon Sep 17 00:00:00 2001 From: Scott Bishop Date: Wed, 12 Dec 2018 16:51:30 -0800 Subject: [PATCH 2/2] Add configuration for autoscaler, ability to customize cpu percentage, update deployment apiVersion --- vizzy/templates/deployment.yaml | 2 +- vizzy/templates/scaling.yaml | 4 +++- vizzy/values.yaml | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/vizzy/templates/deployment.yaml b/vizzy/templates/deployment.yaml index aa3b256..b6b2893 100644 --- a/vizzy/templates/deployment.yaml +++ b/vizzy/templates/deployment.yaml @@ -1,4 +1,4 @@ -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: name: {{ .Chart.Name }} diff --git a/vizzy/templates/scaling.yaml b/vizzy/templates/scaling.yaml index f91b2af..7b82800 100644 --- a/vizzy/templates/scaling.yaml +++ b/vizzy/templates/scaling.yaml @@ -1,3 +1,4 @@ +{{- if .Values.horizontalPodAutoscaler.enabled -}} apiVersion: autoscaling/v1 kind: HorizontalPodAutoscaler metadata: @@ -14,4 +15,5 @@ spec: apiVersion: apps/v1 kind: Deployment name: {{ .Chart.Name }} - targetCPUUtilizationPercentage: 80 \ No newline at end of file + targetCPUUtilizationPercentage: {{ .Values.horizontalPodAutoscaler.targetCPUUtilizationPercentage }} +{{- end }} \ No newline at end of file diff --git a/vizzy/values.yaml b/vizzy/values.yaml index 7d9a69d..5ac3dae 100644 --- a/vizzy/values.yaml +++ b/vizzy/values.yaml @@ -39,6 +39,10 @@ service: nginxIngress: enabled: true +horizontalPodAutoscaler: + enabled: false + targetCPUUtilizationPercentage: 80 + # Chart dependency postgresql: enabled: true