From 41e883b91ecfaea2263cd9d965f96627327dde2d Mon Sep 17 00:00:00 2001 From: Viktor Farcic Date: Fri, 3 Jan 2020 21:43:12 +0100 Subject: [PATCH] Canary Signed-off-by: Viktor Farcic --- packs/C++/charts/templates/canary.yaml | 58 +++++++++++++++++++ packs/C++/charts/templates/deployment.yaml | 3 + packs/C++/charts/templates/hpa.yaml | 25 ++++++++ packs/C++/charts/templates/service.yaml | 2 +- packs/C++/charts/values.yaml | 30 ++++++++++ packs/D/charts/templates/canary.yaml | 58 +++++++++++++++++++ packs/D/charts/templates/deployment.yaml | 3 + packs/D/charts/templates/hpa.yaml | 25 ++++++++ packs/D/charts/templates/service.yaml | 2 +- packs/D/charts/values.yaml | 30 ++++++++++ packs/appserver/charts/templates/canary.yaml | 58 +++++++++++++++++++ .../charts/templates/deployment.yaml | 3 + packs/appserver/charts/templates/hpa.yaml | 25 ++++++++ packs/appserver/charts/templates/service.yaml | 2 +- packs/appserver/charts/values.yaml | 30 ++++++++++ packs/csharp/charts/templates/canary.yaml | 58 +++++++++++++++++++ packs/csharp/charts/templates/deployment.yaml | 3 + packs/csharp/charts/templates/hpa.yaml | 25 ++++++++ packs/csharp/charts/templates/service.yaml | 2 +- packs/csharp/charts/values.yaml | 30 ++++++++++ packs/cwp/charts/templates/canary.yaml | 58 +++++++++++++++++++ packs/cwp/charts/templates/deployment.yaml | 3 + packs/cwp/charts/templates/hpa.yaml | 25 ++++++++ packs/cwp/charts/templates/service.yaml | 2 +- packs/cwp/charts/values.yaml | 30 ++++++++++ packs/dropwizard/charts/templates/canary.yaml | 58 +++++++++++++++++++ .../charts/templates/deployment.yaml | 3 + packs/dropwizard/charts/templates/hpa.yaml | 25 ++++++++ .../dropwizard/charts/templates/service.yaml | 2 +- packs/dropwizard/charts/values.yaml | 30 ++++++++++ packs/go-mongodb/charts/templates/canary.yaml | 58 +++++++++++++++++++ .../charts/templates/deployment.yaml | 3 + packs/go-mongodb/charts/templates/hpa.yaml | 25 ++++++++ .../go-mongodb/charts/templates/service.yaml | 2 +- packs/go-mongodb/charts/values.yaml | 30 ++++++++++ packs/gradle/charts/templates/canary.yaml | 58 +++++++++++++++++++ packs/gradle/charts/templates/deployment.yaml | 3 + packs/gradle/charts/templates/hpa.yaml | 25 ++++++++ packs/gradle/charts/templates/service.yaml | 2 +- packs/gradle/charts/values.yaml | 30 ++++++++++ .../charts/templates/canary.yaml | 58 +++++++++++++++++++ .../charts/templates/deployment.yaml | 3 + .../charts/templates/hpa.yaml | 25 ++++++++ .../charts/templates/service.yaml | 2 +- packs/javascript-ui-nginx/charts/values.yaml | 30 ++++++++++ packs/javascript/charts/templates/canary.yaml | 58 +++++++++++++++++++ .../charts/templates/deployment.yaml | 3 + packs/javascript/charts/templates/hpa.yaml | 25 ++++++++ .../javascript/charts/templates/service.yaml | 2 +- packs/javascript/charts/values.yaml | 30 ++++++++++ packs/liberty/charts/templates/canary.yaml | 58 +++++++++++++++++++ .../liberty/charts/templates/deployment.yaml | 3 + packs/liberty/charts/templates/hpa.yaml | 25 ++++++++ packs/liberty/charts/templates/service.yaml | 2 +- packs/liberty/charts/values.yaml | 30 ++++++++++ .../maven-java11/charts/templates/canary.yaml | 58 +++++++++++++++++++ .../charts/templates/deployment.yaml | 3 + packs/maven-java11/charts/templates/hpa.yaml | 25 ++++++++ .../charts/templates/service.yaml | 2 +- packs/maven-java11/charts/values.yaml | 30 ++++++++++ .../charts/templates/canary.yaml | 58 +++++++++++++++++++ .../charts/templates/deployment.yaml | 3 + .../maven-node-ruby/charts/templates/hpa.yaml | 25 ++++++++ .../charts/templates/service.yaml | 2 +- packs/maven-node-ruby/charts/values.yaml | 30 ++++++++++ .../charts/templates/canary.yaml | 58 +++++++++++++++++++ .../charts/templates/deployment.yaml | 3 + packs/maven-quarkus/charts/templates/hpa.yaml | 25 ++++++++ .../charts/templates/service.yaml | 2 +- packs/maven-quarkus/charts/values.yaml | 30 ++++++++++ packs/maven/charts/templates/canary.yaml | 58 +++++++++++++++++++ packs/maven/charts/templates/deployment.yaml | 3 + packs/maven/charts/templates/hpa.yaml | 25 ++++++++ packs/maven/charts/templates/service.yaml | 2 +- packs/maven/charts/values.yaml | 30 ++++++++++ packs/php/charts/templates/canary.yaml | 58 +++++++++++++++++++ packs/php/charts/templates/deployment.yaml | 3 + packs/php/charts/templates/hpa.yaml | 25 ++++++++ packs/php/charts/templates/service.yaml | 2 +- packs/php/charts/values.yaml | 30 ++++++++++ packs/python/charts/templates/canary.yaml | 58 +++++++++++++++++++ packs/python/charts/templates/deployment.yaml | 3 + packs/python/charts/templates/hpa.yaml | 25 ++++++++ packs/python/charts/templates/service.yaml | 2 +- packs/python/charts/values.yaml | 30 ++++++++++ packs/ruby/charts/templates/canary.yaml | 58 +++++++++++++++++++ packs/ruby/charts/templates/deployment.yaml | 3 + packs/ruby/charts/templates/hpa.yaml | 25 ++++++++ packs/ruby/charts/templates/service.yaml | 2 +- packs/ruby/charts/values.yaml | 30 ++++++++++ packs/rust/charts/templates/canary.yaml | 58 +++++++++++++++++++ packs/rust/charts/templates/deployment.yaml | 3 + packs/rust/charts/templates/hpa.yaml | 25 ++++++++ packs/rust/charts/templates/service.yaml | 2 +- packs/rust/charts/values.yaml | 30 ++++++++++ packs/scala/charts/templates/canary.yaml | 58 +++++++++++++++++++ packs/scala/charts/templates/deployment.yaml | 3 + packs/scala/charts/templates/hpa.yaml | 25 ++++++++ packs/scala/charts/templates/service.yaml | 2 +- packs/scala/charts/values.yaml | 30 ++++++++++ packs/swift/chart/templates/canary.yaml | 58 +++++++++++++++++++ packs/swift/chart/templates/deployment.yaml | 3 + packs/swift/chart/templates/hpa.yaml | 25 ++++++++ packs/swift/chart/templates/service.yaml | 2 +- packs/swift/chart/values.yaml | 30 ++++++++++ packs/typescript/charts/templates/canary.yaml | 58 +++++++++++++++++++ .../charts/templates/deployment.yaml | 3 + packs/typescript/charts/templates/hpa.yaml | 25 ++++++++ .../typescript/charts/templates/service.yaml | 2 +- packs/typescript/charts/values.yaml | 30 ++++++++++ 110 files changed, 2574 insertions(+), 22 deletions(-) create mode 100644 packs/C++/charts/templates/canary.yaml create mode 100644 packs/C++/charts/templates/hpa.yaml create mode 100644 packs/D/charts/templates/canary.yaml create mode 100644 packs/D/charts/templates/hpa.yaml create mode 100644 packs/appserver/charts/templates/canary.yaml create mode 100644 packs/appserver/charts/templates/hpa.yaml create mode 100644 packs/csharp/charts/templates/canary.yaml create mode 100644 packs/csharp/charts/templates/hpa.yaml create mode 100644 packs/cwp/charts/templates/canary.yaml create mode 100644 packs/cwp/charts/templates/hpa.yaml create mode 100644 packs/dropwizard/charts/templates/canary.yaml create mode 100644 packs/dropwizard/charts/templates/hpa.yaml create mode 100644 packs/go-mongodb/charts/templates/canary.yaml create mode 100644 packs/go-mongodb/charts/templates/hpa.yaml create mode 100644 packs/gradle/charts/templates/canary.yaml create mode 100644 packs/gradle/charts/templates/hpa.yaml create mode 100644 packs/javascript-ui-nginx/charts/templates/canary.yaml create mode 100644 packs/javascript-ui-nginx/charts/templates/hpa.yaml create mode 100644 packs/javascript/charts/templates/canary.yaml create mode 100644 packs/javascript/charts/templates/hpa.yaml create mode 100644 packs/liberty/charts/templates/canary.yaml create mode 100644 packs/liberty/charts/templates/hpa.yaml create mode 100644 packs/maven-java11/charts/templates/canary.yaml create mode 100644 packs/maven-java11/charts/templates/hpa.yaml create mode 100644 packs/maven-node-ruby/charts/templates/canary.yaml create mode 100644 packs/maven-node-ruby/charts/templates/hpa.yaml create mode 100644 packs/maven-quarkus/charts/templates/canary.yaml create mode 100644 packs/maven-quarkus/charts/templates/hpa.yaml create mode 100644 packs/maven/charts/templates/canary.yaml create mode 100644 packs/maven/charts/templates/hpa.yaml create mode 100644 packs/php/charts/templates/canary.yaml create mode 100644 packs/php/charts/templates/hpa.yaml create mode 100644 packs/python/charts/templates/canary.yaml create mode 100644 packs/python/charts/templates/hpa.yaml create mode 100644 packs/ruby/charts/templates/canary.yaml create mode 100644 packs/ruby/charts/templates/hpa.yaml create mode 100644 packs/rust/charts/templates/canary.yaml create mode 100644 packs/rust/charts/templates/hpa.yaml create mode 100644 packs/scala/charts/templates/canary.yaml create mode 100644 packs/scala/charts/templates/hpa.yaml create mode 100644 packs/swift/chart/templates/canary.yaml create mode 100644 packs/swift/chart/templates/hpa.yaml create mode 100644 packs/typescript/charts/templates/canary.yaml create mode 100644 packs/typescript/charts/templates/hpa.yaml diff --git a/packs/C++/charts/templates/canary.yaml b/packs/C++/charts/templates/canary.yaml new file mode 100644 index 000000000..bd5e3f857 --- /dev/null +++ b/packs/C++/charts/templates/canary.yaml @@ -0,0 +1,58 @@ +{{- if .Values.canary.enabled }} +apiVersion: flagger.app/v1alpha3 +kind: Canary +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + provider: istio + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + progressDeadlineSeconds: {{ .Values.canary.progressDeadlineSeconds }} + {{- if .Values.hpa.enabled }} + autoscalerRef: + apiVersion: autoscaling/v2beta1 + kind: HorizontalPodAutoscaler + name: {{ template "fullname" . }} + {{- end }} + service: + port: {{ .Values.service.externalPort }} + targetPort: {{ .Values.service.internalPort }} + gateways: + - {{ template "fullname" . }} + hosts: + - {{ .Values.canary.host }} + canaryAnalysis: + interval: {{ .Values.canary.canaryAnalysis.interval }} + threshold: {{ .Values.canary.canaryAnalysis.threshold }} + maxWeight: {{ .Values.canary.canaryAnalysis.maxWeight }} + stepWeight: {{ .Values.canary.canaryAnalysis.stepWeight }} + metrics: + - name: request-success-rate + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.interval }} + - name: request-duration + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.interval }} + +--- + +apiVersion: networking.istio.io/v1alpha3 +kind: Gateway +metadata: + name: {{ template "fullname" . }} +spec: + selector: + istio: ingressgateway + servers: + - port: + number: {{ .Values.service.externalPort }} + name: http + protocol: HTTP + hosts: + - {{ .Values.canary.host }} +{{- end }} diff --git a/packs/C++/charts/templates/deployment.yaml b/packs/C++/charts/templates/deployment.yaml index 52ccdba6f..f4858abcc 100644 --- a/packs/C++/charts/templates/deployment.yaml +++ b/packs/C++/charts/templates/deployment.yaml @@ -8,7 +8,10 @@ metadata: draft: {{ default "draft-app" .Values.draft }} chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" spec: +{{- if .Values.hpa.enabled }} +{{- else }} replicas: {{ .Values.replicaCount }} +{{- end }} template: metadata: labels: diff --git a/packs/C++/charts/templates/hpa.yaml b/packs/C++/charts/templates/hpa.yaml new file mode 100644 index 000000000..1c03eb4c9 --- /dev/null +++ b/packs/C++/charts/templates/hpa.yaml @@ -0,0 +1,25 @@ +{{- if .Values.hpa.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + minReplicas: {{ .Values.hpa.minReplicas }} + maxReplicas: {{ .Values.hpa.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.hpa.cpuTargetAverageUtilization }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.hpa.memoryTargetAverageUtilization }} +{{- end }} \ No newline at end of file diff --git a/packs/C++/charts/templates/service.yaml b/packs/C++/charts/templates/service.yaml index 9321361e3..9a2a4c758 100644 --- a/packs/C++/charts/templates/service.yaml +++ b/packs/C++/charts/templates/service.yaml @@ -1,4 +1,4 @@ -{{- if .Values.knativeDeploy }} +{{- if or .Values.knativeDeploy .Values.canary.enabled }} {{- else }} apiVersion: v1 kind: Service diff --git a/packs/C++/charts/values.yaml b/packs/C++/charts/values.yaml index 90b4b08e1..114cade0c 100644 --- a/packs/C++/charts/values.yaml +++ b/packs/C++/charts/values.yaml @@ -13,6 +13,36 @@ env: # enable this flag to use knative serve to deploy the app knativeDeploy: false +# HorizontalPodAutoscaler +hpa: + enabled: false + minReplicas: 2 + maxReplicas: 6 + cpuTargetAverageUtilization: 80 + memoryTargetAverageUtilization: 80 + +# Canary deployments +# If enabled, Istio and Flagger need to be installed in the cluster +canary: + enabled: false + progressDeadlineSeconds: 60 + canaryAnalysis: + interval: "1m" + threshold: 5 + maxWeight: 60 + stepWeight: 20 + # WARNING: Canary deployments will fail and rollback if there is no traffic that will generate the below specified metrics. + metrics: + requestSuccessRate: + threshold: 99 + interval: "1m" + requestDuration: + threshold: 1000 + interval: "1m" + # The host is using Istio Gateway and is currently not auto-generated + # Please overwrite the `canary.host` in `values.yaml` in each environment repository (e.g., staging, production) + host: acme.com + service: name: REPLACE_ME_APP_NAME type: ClusterIP diff --git a/packs/D/charts/templates/canary.yaml b/packs/D/charts/templates/canary.yaml new file mode 100644 index 000000000..bd5e3f857 --- /dev/null +++ b/packs/D/charts/templates/canary.yaml @@ -0,0 +1,58 @@ +{{- if .Values.canary.enabled }} +apiVersion: flagger.app/v1alpha3 +kind: Canary +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + provider: istio + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + progressDeadlineSeconds: {{ .Values.canary.progressDeadlineSeconds }} + {{- if .Values.hpa.enabled }} + autoscalerRef: + apiVersion: autoscaling/v2beta1 + kind: HorizontalPodAutoscaler + name: {{ template "fullname" . }} + {{- end }} + service: + port: {{ .Values.service.externalPort }} + targetPort: {{ .Values.service.internalPort }} + gateways: + - {{ template "fullname" . }} + hosts: + - {{ .Values.canary.host }} + canaryAnalysis: + interval: {{ .Values.canary.canaryAnalysis.interval }} + threshold: {{ .Values.canary.canaryAnalysis.threshold }} + maxWeight: {{ .Values.canary.canaryAnalysis.maxWeight }} + stepWeight: {{ .Values.canary.canaryAnalysis.stepWeight }} + metrics: + - name: request-success-rate + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.interval }} + - name: request-duration + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.interval }} + +--- + +apiVersion: networking.istio.io/v1alpha3 +kind: Gateway +metadata: + name: {{ template "fullname" . }} +spec: + selector: + istio: ingressgateway + servers: + - port: + number: {{ .Values.service.externalPort }} + name: http + protocol: HTTP + hosts: + - {{ .Values.canary.host }} +{{- end }} diff --git a/packs/D/charts/templates/deployment.yaml b/packs/D/charts/templates/deployment.yaml index 52ccdba6f..f4858abcc 100644 --- a/packs/D/charts/templates/deployment.yaml +++ b/packs/D/charts/templates/deployment.yaml @@ -8,7 +8,10 @@ metadata: draft: {{ default "draft-app" .Values.draft }} chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" spec: +{{- if .Values.hpa.enabled }} +{{- else }} replicas: {{ .Values.replicaCount }} +{{- end }} template: metadata: labels: diff --git a/packs/D/charts/templates/hpa.yaml b/packs/D/charts/templates/hpa.yaml new file mode 100644 index 000000000..1c03eb4c9 --- /dev/null +++ b/packs/D/charts/templates/hpa.yaml @@ -0,0 +1,25 @@ +{{- if .Values.hpa.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + minReplicas: {{ .Values.hpa.minReplicas }} + maxReplicas: {{ .Values.hpa.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.hpa.cpuTargetAverageUtilization }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.hpa.memoryTargetAverageUtilization }} +{{- end }} \ No newline at end of file diff --git a/packs/D/charts/templates/service.yaml b/packs/D/charts/templates/service.yaml index 9321361e3..9a2a4c758 100644 --- a/packs/D/charts/templates/service.yaml +++ b/packs/D/charts/templates/service.yaml @@ -1,4 +1,4 @@ -{{- if .Values.knativeDeploy }} +{{- if or .Values.knativeDeploy .Values.canary.enabled }} {{- else }} apiVersion: v1 kind: Service diff --git a/packs/D/charts/values.yaml b/packs/D/charts/values.yaml index 90b4b08e1..114cade0c 100644 --- a/packs/D/charts/values.yaml +++ b/packs/D/charts/values.yaml @@ -13,6 +13,36 @@ env: # enable this flag to use knative serve to deploy the app knativeDeploy: false +# HorizontalPodAutoscaler +hpa: + enabled: false + minReplicas: 2 + maxReplicas: 6 + cpuTargetAverageUtilization: 80 + memoryTargetAverageUtilization: 80 + +# Canary deployments +# If enabled, Istio and Flagger need to be installed in the cluster +canary: + enabled: false + progressDeadlineSeconds: 60 + canaryAnalysis: + interval: "1m" + threshold: 5 + maxWeight: 60 + stepWeight: 20 + # WARNING: Canary deployments will fail and rollback if there is no traffic that will generate the below specified metrics. + metrics: + requestSuccessRate: + threshold: 99 + interval: "1m" + requestDuration: + threshold: 1000 + interval: "1m" + # The host is using Istio Gateway and is currently not auto-generated + # Please overwrite the `canary.host` in `values.yaml` in each environment repository (e.g., staging, production) + host: acme.com + service: name: REPLACE_ME_APP_NAME type: ClusterIP diff --git a/packs/appserver/charts/templates/canary.yaml b/packs/appserver/charts/templates/canary.yaml new file mode 100644 index 000000000..bd5e3f857 --- /dev/null +++ b/packs/appserver/charts/templates/canary.yaml @@ -0,0 +1,58 @@ +{{- if .Values.canary.enabled }} +apiVersion: flagger.app/v1alpha3 +kind: Canary +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + provider: istio + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + progressDeadlineSeconds: {{ .Values.canary.progressDeadlineSeconds }} + {{- if .Values.hpa.enabled }} + autoscalerRef: + apiVersion: autoscaling/v2beta1 + kind: HorizontalPodAutoscaler + name: {{ template "fullname" . }} + {{- end }} + service: + port: {{ .Values.service.externalPort }} + targetPort: {{ .Values.service.internalPort }} + gateways: + - {{ template "fullname" . }} + hosts: + - {{ .Values.canary.host }} + canaryAnalysis: + interval: {{ .Values.canary.canaryAnalysis.interval }} + threshold: {{ .Values.canary.canaryAnalysis.threshold }} + maxWeight: {{ .Values.canary.canaryAnalysis.maxWeight }} + stepWeight: {{ .Values.canary.canaryAnalysis.stepWeight }} + metrics: + - name: request-success-rate + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.interval }} + - name: request-duration + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.interval }} + +--- + +apiVersion: networking.istio.io/v1alpha3 +kind: Gateway +metadata: + name: {{ template "fullname" . }} +spec: + selector: + istio: ingressgateway + servers: + - port: + number: {{ .Values.service.externalPort }} + name: http + protocol: HTTP + hosts: + - {{ .Values.canary.host }} +{{- end }} diff --git a/packs/appserver/charts/templates/deployment.yaml b/packs/appserver/charts/templates/deployment.yaml index 52ccdba6f..f4858abcc 100644 --- a/packs/appserver/charts/templates/deployment.yaml +++ b/packs/appserver/charts/templates/deployment.yaml @@ -8,7 +8,10 @@ metadata: draft: {{ default "draft-app" .Values.draft }} chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" spec: +{{- if .Values.hpa.enabled }} +{{- else }} replicas: {{ .Values.replicaCount }} +{{- end }} template: metadata: labels: diff --git a/packs/appserver/charts/templates/hpa.yaml b/packs/appserver/charts/templates/hpa.yaml new file mode 100644 index 000000000..1c03eb4c9 --- /dev/null +++ b/packs/appserver/charts/templates/hpa.yaml @@ -0,0 +1,25 @@ +{{- if .Values.hpa.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + minReplicas: {{ .Values.hpa.minReplicas }} + maxReplicas: {{ .Values.hpa.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.hpa.cpuTargetAverageUtilization }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.hpa.memoryTargetAverageUtilization }} +{{- end }} \ No newline at end of file diff --git a/packs/appserver/charts/templates/service.yaml b/packs/appserver/charts/templates/service.yaml index 9321361e3..9a2a4c758 100644 --- a/packs/appserver/charts/templates/service.yaml +++ b/packs/appserver/charts/templates/service.yaml @@ -1,4 +1,4 @@ -{{- if .Values.knativeDeploy }} +{{- if or .Values.knativeDeploy .Values.canary.enabled }} {{- else }} apiVersion: v1 kind: Service diff --git a/packs/appserver/charts/values.yaml b/packs/appserver/charts/values.yaml index 4d7d16363..d8e3f3b61 100644 --- a/packs/appserver/charts/values.yaml +++ b/packs/appserver/charts/values.yaml @@ -13,6 +13,36 @@ env: # enable this flag to use knative serve to deploy the app knativeDeploy: false +# HorizontalPodAutoscaler +hpa: + enabled: false + minReplicas: 2 + maxReplicas: 6 + cpuTargetAverageUtilization: 80 + memoryTargetAverageUtilization: 80 + +# Canary deployments +# If enabled, Istio and Flagger need to be installed in the cluster +canary: + enabled: false + progressDeadlineSeconds: 60 + canaryAnalysis: + interval: "1m" + threshold: 5 + maxWeight: 60 + stepWeight: 20 + # WARNING: Canary deployments will fail and rollback if there is no traffic that will generate the below specified metrics. + metrics: + requestSuccessRate: + threshold: 99 + interval: "1m" + requestDuration: + threshold: 1000 + interval: "1m" + # The host is using Istio Gateway and is currently not auto-generated + # Please overwrite the `canary.host` in `values.yaml` in each environment repository (e.g., staging, production) + host: acme.com + service: name: REPLACE_ME_APP_NAME type: ClusterIP diff --git a/packs/csharp/charts/templates/canary.yaml b/packs/csharp/charts/templates/canary.yaml new file mode 100644 index 000000000..bd5e3f857 --- /dev/null +++ b/packs/csharp/charts/templates/canary.yaml @@ -0,0 +1,58 @@ +{{- if .Values.canary.enabled }} +apiVersion: flagger.app/v1alpha3 +kind: Canary +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + provider: istio + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + progressDeadlineSeconds: {{ .Values.canary.progressDeadlineSeconds }} + {{- if .Values.hpa.enabled }} + autoscalerRef: + apiVersion: autoscaling/v2beta1 + kind: HorizontalPodAutoscaler + name: {{ template "fullname" . }} + {{- end }} + service: + port: {{ .Values.service.externalPort }} + targetPort: {{ .Values.service.internalPort }} + gateways: + - {{ template "fullname" . }} + hosts: + - {{ .Values.canary.host }} + canaryAnalysis: + interval: {{ .Values.canary.canaryAnalysis.interval }} + threshold: {{ .Values.canary.canaryAnalysis.threshold }} + maxWeight: {{ .Values.canary.canaryAnalysis.maxWeight }} + stepWeight: {{ .Values.canary.canaryAnalysis.stepWeight }} + metrics: + - name: request-success-rate + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.interval }} + - name: request-duration + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.interval }} + +--- + +apiVersion: networking.istio.io/v1alpha3 +kind: Gateway +metadata: + name: {{ template "fullname" . }} +spec: + selector: + istio: ingressgateway + servers: + - port: + number: {{ .Values.service.externalPort }} + name: http + protocol: HTTP + hosts: + - {{ .Values.canary.host }} +{{- end }} diff --git a/packs/csharp/charts/templates/deployment.yaml b/packs/csharp/charts/templates/deployment.yaml index 650c551ba..028797583 100644 --- a/packs/csharp/charts/templates/deployment.yaml +++ b/packs/csharp/charts/templates/deployment.yaml @@ -8,7 +8,10 @@ metadata: draft: {{ default "draft-app" .Values.draft }} chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" spec: +{{- if .Values.hpa.enabled }} +{{- else }} replicas: {{ .Values.replicaCount }} +{{- end }} template: metadata: labels: diff --git a/packs/csharp/charts/templates/hpa.yaml b/packs/csharp/charts/templates/hpa.yaml new file mode 100644 index 000000000..1c03eb4c9 --- /dev/null +++ b/packs/csharp/charts/templates/hpa.yaml @@ -0,0 +1,25 @@ +{{- if .Values.hpa.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + minReplicas: {{ .Values.hpa.minReplicas }} + maxReplicas: {{ .Values.hpa.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.hpa.cpuTargetAverageUtilization }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.hpa.memoryTargetAverageUtilization }} +{{- end }} \ No newline at end of file diff --git a/packs/csharp/charts/templates/service.yaml b/packs/csharp/charts/templates/service.yaml index 9321361e3..9a2a4c758 100644 --- a/packs/csharp/charts/templates/service.yaml +++ b/packs/csharp/charts/templates/service.yaml @@ -1,4 +1,4 @@ -{{- if .Values.knativeDeploy }} +{{- if or .Values.knativeDeploy .Values.canary.enabled }} {{- else }} apiVersion: v1 kind: Service diff --git a/packs/csharp/charts/values.yaml b/packs/csharp/charts/values.yaml index 2a5d36443..abd6b4bb9 100644 --- a/packs/csharp/charts/values.yaml +++ b/packs/csharp/charts/values.yaml @@ -13,6 +13,36 @@ env: # enable this flag to use knative serve to deploy the app knativeDeploy: false +# HorizontalPodAutoscaler +hpa: + enabled: false + minReplicas: 2 + maxReplicas: 6 + cpuTargetAverageUtilization: 80 + memoryTargetAverageUtilization: 80 + +# Canary deployments +# If enabled, Istio and Flagger need to be installed in the cluster +canary: + enabled: false + progressDeadlineSeconds: 60 + canaryAnalysis: + interval: "1m" + threshold: 5 + maxWeight: 60 + stepWeight: 20 + # WARNING: Canary deployments will fail and rollback if there is no traffic that will generate the below specified metrics. + metrics: + requestSuccessRate: + threshold: 99 + interval: "1m" + requestDuration: + threshold: 1000 + interval: "1m" + # The host is using Istio Gateway and is currently not auto-generated + # Please overwrite the `canary.host` in `values.yaml` in each environment repository (e.g., staging, production) + host: acme.com + service: name: REPLACE_ME_APP_NAME type: ClusterIP diff --git a/packs/cwp/charts/templates/canary.yaml b/packs/cwp/charts/templates/canary.yaml new file mode 100644 index 000000000..bd5e3f857 --- /dev/null +++ b/packs/cwp/charts/templates/canary.yaml @@ -0,0 +1,58 @@ +{{- if .Values.canary.enabled }} +apiVersion: flagger.app/v1alpha3 +kind: Canary +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + provider: istio + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + progressDeadlineSeconds: {{ .Values.canary.progressDeadlineSeconds }} + {{- if .Values.hpa.enabled }} + autoscalerRef: + apiVersion: autoscaling/v2beta1 + kind: HorizontalPodAutoscaler + name: {{ template "fullname" . }} + {{- end }} + service: + port: {{ .Values.service.externalPort }} + targetPort: {{ .Values.service.internalPort }} + gateways: + - {{ template "fullname" . }} + hosts: + - {{ .Values.canary.host }} + canaryAnalysis: + interval: {{ .Values.canary.canaryAnalysis.interval }} + threshold: {{ .Values.canary.canaryAnalysis.threshold }} + maxWeight: {{ .Values.canary.canaryAnalysis.maxWeight }} + stepWeight: {{ .Values.canary.canaryAnalysis.stepWeight }} + metrics: + - name: request-success-rate + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.interval }} + - name: request-duration + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.interval }} + +--- + +apiVersion: networking.istio.io/v1alpha3 +kind: Gateway +metadata: + name: {{ template "fullname" . }} +spec: + selector: + istio: ingressgateway + servers: + - port: + number: {{ .Values.service.externalPort }} + name: http + protocol: HTTP + hosts: + - {{ .Values.canary.host }} +{{- end }} diff --git a/packs/cwp/charts/templates/deployment.yaml b/packs/cwp/charts/templates/deployment.yaml index 52ccdba6f..f4858abcc 100644 --- a/packs/cwp/charts/templates/deployment.yaml +++ b/packs/cwp/charts/templates/deployment.yaml @@ -8,7 +8,10 @@ metadata: draft: {{ default "draft-app" .Values.draft }} chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" spec: +{{- if .Values.hpa.enabled }} +{{- else }} replicas: {{ .Values.replicaCount }} +{{- end }} template: metadata: labels: diff --git a/packs/cwp/charts/templates/hpa.yaml b/packs/cwp/charts/templates/hpa.yaml new file mode 100644 index 000000000..1c03eb4c9 --- /dev/null +++ b/packs/cwp/charts/templates/hpa.yaml @@ -0,0 +1,25 @@ +{{- if .Values.hpa.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + minReplicas: {{ .Values.hpa.minReplicas }} + maxReplicas: {{ .Values.hpa.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.hpa.cpuTargetAverageUtilization }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.hpa.memoryTargetAverageUtilization }} +{{- end }} \ No newline at end of file diff --git a/packs/cwp/charts/templates/service.yaml b/packs/cwp/charts/templates/service.yaml index 9321361e3..9a2a4c758 100644 --- a/packs/cwp/charts/templates/service.yaml +++ b/packs/cwp/charts/templates/service.yaml @@ -1,4 +1,4 @@ -{{- if .Values.knativeDeploy }} +{{- if or .Values.knativeDeploy .Values.canary.enabled }} {{- else }} apiVersion: v1 kind: Service diff --git a/packs/cwp/charts/values.yaml b/packs/cwp/charts/values.yaml index e0d2ac1bd..ec07cd0f6 100644 --- a/packs/cwp/charts/values.yaml +++ b/packs/cwp/charts/values.yaml @@ -13,6 +13,36 @@ env: # enable this flag to use knative serve to deploy the app knativeDeploy: false +# HorizontalPodAutoscaler +hpa: + enabled: false + minReplicas: 2 + maxReplicas: 6 + cpuTargetAverageUtilization: 80 + memoryTargetAverageUtilization: 80 + +# Canary deployments +# If enabled, Istio and Flagger need to be installed in the cluster +canary: + enabled: false + progressDeadlineSeconds: 60 + canaryAnalysis: + interval: "1m" + threshold: 5 + maxWeight: 60 + stepWeight: 20 + # WARNING: Canary deployments will fail and rollback if there is no traffic that will generate the below specified metrics. + metrics: + requestSuccessRate: + threshold: 99 + interval: "1m" + requestDuration: + threshold: 1000 + interval: "1m" + # The host is using Istio Gateway and is currently not auto-generated + # Please overwrite the `canary.host` in `values.yaml` in each environment repository (e.g., staging, production) + host: acme.com + service: name: REPLACE_ME_APP_NAME type: ClusterIP diff --git a/packs/dropwizard/charts/templates/canary.yaml b/packs/dropwizard/charts/templates/canary.yaml new file mode 100644 index 000000000..bd5e3f857 --- /dev/null +++ b/packs/dropwizard/charts/templates/canary.yaml @@ -0,0 +1,58 @@ +{{- if .Values.canary.enabled }} +apiVersion: flagger.app/v1alpha3 +kind: Canary +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + provider: istio + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + progressDeadlineSeconds: {{ .Values.canary.progressDeadlineSeconds }} + {{- if .Values.hpa.enabled }} + autoscalerRef: + apiVersion: autoscaling/v2beta1 + kind: HorizontalPodAutoscaler + name: {{ template "fullname" . }} + {{- end }} + service: + port: {{ .Values.service.externalPort }} + targetPort: {{ .Values.service.internalPort }} + gateways: + - {{ template "fullname" . }} + hosts: + - {{ .Values.canary.host }} + canaryAnalysis: + interval: {{ .Values.canary.canaryAnalysis.interval }} + threshold: {{ .Values.canary.canaryAnalysis.threshold }} + maxWeight: {{ .Values.canary.canaryAnalysis.maxWeight }} + stepWeight: {{ .Values.canary.canaryAnalysis.stepWeight }} + metrics: + - name: request-success-rate + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.interval }} + - name: request-duration + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.interval }} + +--- + +apiVersion: networking.istio.io/v1alpha3 +kind: Gateway +metadata: + name: {{ template "fullname" . }} +spec: + selector: + istio: ingressgateway + servers: + - port: + number: {{ .Values.service.externalPort }} + name: http + protocol: HTTP + hosts: + - {{ .Values.canary.host }} +{{- end }} diff --git a/packs/dropwizard/charts/templates/deployment.yaml b/packs/dropwizard/charts/templates/deployment.yaml index 03e574e6d..79fa75c94 100644 --- a/packs/dropwizard/charts/templates/deployment.yaml +++ b/packs/dropwizard/charts/templates/deployment.yaml @@ -8,7 +8,10 @@ metadata: draft: {{ default "draft-app" .Values.draft }} chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" spec: +{{- if .Values.hpa.enabled }} +{{- else }} replicas: {{ .Values.replicaCount }} +{{- end }} template: metadata: labels: diff --git a/packs/dropwizard/charts/templates/hpa.yaml b/packs/dropwizard/charts/templates/hpa.yaml new file mode 100644 index 000000000..1c03eb4c9 --- /dev/null +++ b/packs/dropwizard/charts/templates/hpa.yaml @@ -0,0 +1,25 @@ +{{- if .Values.hpa.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + minReplicas: {{ .Values.hpa.minReplicas }} + maxReplicas: {{ .Values.hpa.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.hpa.cpuTargetAverageUtilization }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.hpa.memoryTargetAverageUtilization }} +{{- end }} \ No newline at end of file diff --git a/packs/dropwizard/charts/templates/service.yaml b/packs/dropwizard/charts/templates/service.yaml index 4151c84a7..e5de06ed4 100644 --- a/packs/dropwizard/charts/templates/service.yaml +++ b/packs/dropwizard/charts/templates/service.yaml @@ -1,4 +1,4 @@ -{{- if .Values.knativeDeploy }} +{{- if or .Values.knativeDeploy .Values.canary.enabled }} {{- else }} apiVersion: v1 kind: Service diff --git a/packs/dropwizard/charts/values.yaml b/packs/dropwizard/charts/values.yaml index 8dc3d63b1..8209a5450 100644 --- a/packs/dropwizard/charts/values.yaml +++ b/packs/dropwizard/charts/values.yaml @@ -13,6 +13,36 @@ env: # enable this flag to use knative serve to deploy the app knativeDeploy: false +# HorizontalPodAutoscaler +hpa: + enabled: false + minReplicas: 2 + maxReplicas: 6 + cpuTargetAverageUtilization: 80 + memoryTargetAverageUtilization: 80 + +# Canary deployments +# If enabled, Istio and Flagger need to be installed in the cluster +canary: + enabled: false + progressDeadlineSeconds: 60 + canaryAnalysis: + interval: "1m" + threshold: 5 + maxWeight: 60 + stepWeight: 20 + # WARNING: Canary deployments will fail and rollback if there is no traffic that will generate the below specified metrics. + metrics: + requestSuccessRate: + threshold: 99 + interval: "1m" + requestDuration: + threshold: 1000 + interval: "1m" + # The host is using Istio Gateway and is currently not auto-generated + # Please overwrite the `canary.host` in `values.yaml` in each environment repository (e.g., staging, production) + host: acme.com + service: name: REPLACE_ME_APP_NAME type: ClusterIP diff --git a/packs/go-mongodb/charts/templates/canary.yaml b/packs/go-mongodb/charts/templates/canary.yaml new file mode 100644 index 000000000..bd5e3f857 --- /dev/null +++ b/packs/go-mongodb/charts/templates/canary.yaml @@ -0,0 +1,58 @@ +{{- if .Values.canary.enabled }} +apiVersion: flagger.app/v1alpha3 +kind: Canary +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + provider: istio + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + progressDeadlineSeconds: {{ .Values.canary.progressDeadlineSeconds }} + {{- if .Values.hpa.enabled }} + autoscalerRef: + apiVersion: autoscaling/v2beta1 + kind: HorizontalPodAutoscaler + name: {{ template "fullname" . }} + {{- end }} + service: + port: {{ .Values.service.externalPort }} + targetPort: {{ .Values.service.internalPort }} + gateways: + - {{ template "fullname" . }} + hosts: + - {{ .Values.canary.host }} + canaryAnalysis: + interval: {{ .Values.canary.canaryAnalysis.interval }} + threshold: {{ .Values.canary.canaryAnalysis.threshold }} + maxWeight: {{ .Values.canary.canaryAnalysis.maxWeight }} + stepWeight: {{ .Values.canary.canaryAnalysis.stepWeight }} + metrics: + - name: request-success-rate + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.interval }} + - name: request-duration + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.interval }} + +--- + +apiVersion: networking.istio.io/v1alpha3 +kind: Gateway +metadata: + name: {{ template "fullname" . }} +spec: + selector: + istio: ingressgateway + servers: + - port: + number: {{ .Values.service.externalPort }} + name: http + protocol: HTTP + hosts: + - {{ .Values.canary.host }} +{{- end }} diff --git a/packs/go-mongodb/charts/templates/deployment.yaml b/packs/go-mongodb/charts/templates/deployment.yaml index 65a13ef37..ce8815b0e 100644 --- a/packs/go-mongodb/charts/templates/deployment.yaml +++ b/packs/go-mongodb/charts/templates/deployment.yaml @@ -8,7 +8,10 @@ metadata: draft: {{ default "draft-app" .Values.draft }} chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" spec: +{{- if .Values.hpa.enabled }} +{{- else }} replicas: {{ .Values.replicaCount }} +{{- end }} template: metadata: labels: diff --git a/packs/go-mongodb/charts/templates/hpa.yaml b/packs/go-mongodb/charts/templates/hpa.yaml new file mode 100644 index 000000000..1c03eb4c9 --- /dev/null +++ b/packs/go-mongodb/charts/templates/hpa.yaml @@ -0,0 +1,25 @@ +{{- if .Values.hpa.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + minReplicas: {{ .Values.hpa.minReplicas }} + maxReplicas: {{ .Values.hpa.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.hpa.cpuTargetAverageUtilization }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.hpa.memoryTargetAverageUtilization }} +{{- end }} \ No newline at end of file diff --git a/packs/go-mongodb/charts/templates/service.yaml b/packs/go-mongodb/charts/templates/service.yaml index 9321361e3..9a2a4c758 100644 --- a/packs/go-mongodb/charts/templates/service.yaml +++ b/packs/go-mongodb/charts/templates/service.yaml @@ -1,4 +1,4 @@ -{{- if .Values.knativeDeploy }} +{{- if or .Values.knativeDeploy .Values.canary.enabled }} {{- else }} apiVersion: v1 kind: Service diff --git a/packs/go-mongodb/charts/values.yaml b/packs/go-mongodb/charts/values.yaml index 7750e3962..09f64fe0f 100644 --- a/packs/go-mongodb/charts/values.yaml +++ b/packs/go-mongodb/charts/values.yaml @@ -13,6 +13,36 @@ env: # enable this flag to use knative serve to deploy the app knativeDeploy: false +# HorizontalPodAutoscaler +hpa: + enabled: false + minReplicas: 2 + maxReplicas: 6 + cpuTargetAverageUtilization: 80 + memoryTargetAverageUtilization: 80 + +# Canary deployments +# If enabled, Istio and Flagger need to be installed in the cluster +canary: + enabled: false + progressDeadlineSeconds: 60 + canaryAnalysis: + interval: "1m" + threshold: 5 + maxWeight: 60 + stepWeight: 20 + # WARNING: Canary deployments will fail and rollback if there is no traffic that will generate the below specified metrics. + metrics: + requestSuccessRate: + threshold: 99 + interval: "1m" + requestDuration: + threshold: 1000 + interval: "1m" + # The host is using Istio Gateway and is currently not auto-generated + # Please overwrite the `canary.host` in `values.yaml` in each environment repository (e.g., staging, production) + host: acme.com + service: name: REPLACE_ME_APP_NAME type: ClusterIP diff --git a/packs/gradle/charts/templates/canary.yaml b/packs/gradle/charts/templates/canary.yaml new file mode 100644 index 000000000..bd5e3f857 --- /dev/null +++ b/packs/gradle/charts/templates/canary.yaml @@ -0,0 +1,58 @@ +{{- if .Values.canary.enabled }} +apiVersion: flagger.app/v1alpha3 +kind: Canary +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + provider: istio + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + progressDeadlineSeconds: {{ .Values.canary.progressDeadlineSeconds }} + {{- if .Values.hpa.enabled }} + autoscalerRef: + apiVersion: autoscaling/v2beta1 + kind: HorizontalPodAutoscaler + name: {{ template "fullname" . }} + {{- end }} + service: + port: {{ .Values.service.externalPort }} + targetPort: {{ .Values.service.internalPort }} + gateways: + - {{ template "fullname" . }} + hosts: + - {{ .Values.canary.host }} + canaryAnalysis: + interval: {{ .Values.canary.canaryAnalysis.interval }} + threshold: {{ .Values.canary.canaryAnalysis.threshold }} + maxWeight: {{ .Values.canary.canaryAnalysis.maxWeight }} + stepWeight: {{ .Values.canary.canaryAnalysis.stepWeight }} + metrics: + - name: request-success-rate + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.interval }} + - name: request-duration + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.interval }} + +--- + +apiVersion: networking.istio.io/v1alpha3 +kind: Gateway +metadata: + name: {{ template "fullname" . }} +spec: + selector: + istio: ingressgateway + servers: + - port: + number: {{ .Values.service.externalPort }} + name: http + protocol: HTTP + hosts: + - {{ .Values.canary.host }} +{{- end }} diff --git a/packs/gradle/charts/templates/deployment.yaml b/packs/gradle/charts/templates/deployment.yaml index 52ccdba6f..f4858abcc 100644 --- a/packs/gradle/charts/templates/deployment.yaml +++ b/packs/gradle/charts/templates/deployment.yaml @@ -8,7 +8,10 @@ metadata: draft: {{ default "draft-app" .Values.draft }} chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" spec: +{{- if .Values.hpa.enabled }} +{{- else }} replicas: {{ .Values.replicaCount }} +{{- end }} template: metadata: labels: diff --git a/packs/gradle/charts/templates/hpa.yaml b/packs/gradle/charts/templates/hpa.yaml new file mode 100644 index 000000000..1c03eb4c9 --- /dev/null +++ b/packs/gradle/charts/templates/hpa.yaml @@ -0,0 +1,25 @@ +{{- if .Values.hpa.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + minReplicas: {{ .Values.hpa.minReplicas }} + maxReplicas: {{ .Values.hpa.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.hpa.cpuTargetAverageUtilization }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.hpa.memoryTargetAverageUtilization }} +{{- end }} \ No newline at end of file diff --git a/packs/gradle/charts/templates/service.yaml b/packs/gradle/charts/templates/service.yaml index 9321361e3..9a2a4c758 100644 --- a/packs/gradle/charts/templates/service.yaml +++ b/packs/gradle/charts/templates/service.yaml @@ -1,4 +1,4 @@ -{{- if .Values.knativeDeploy }} +{{- if or .Values.knativeDeploy .Values.canary.enabled }} {{- else }} apiVersion: v1 kind: Service diff --git a/packs/gradle/charts/values.yaml b/packs/gradle/charts/values.yaml index ff06465e6..6e5197416 100644 --- a/packs/gradle/charts/values.yaml +++ b/packs/gradle/charts/values.yaml @@ -13,6 +13,36 @@ env: # enable this flag to use knative serve to deploy the app knativeDeploy: false +# HorizontalPodAutoscaler +hpa: + enabled: false + minReplicas: 2 + maxReplicas: 6 + cpuTargetAverageUtilization: 80 + memoryTargetAverageUtilization: 80 + +# Canary deployments +# If enabled, Istio and Flagger need to be installed in the cluster +canary: + enabled: false + progressDeadlineSeconds: 60 + canaryAnalysis: + interval: "1m" + threshold: 5 + maxWeight: 60 + stepWeight: 20 + # WARNING: Canary deployments will fail and rollback if there is no traffic that will generate the below specified metrics. + metrics: + requestSuccessRate: + threshold: 99 + interval: "1m" + requestDuration: + threshold: 1000 + interval: "1m" + # The host is using Istio Gateway and is currently not auto-generated + # Please overwrite the `canary.host` in `values.yaml` in each environment repository (e.g., staging, production) + host: acme.com + service: name: REPLACE_ME_APP_NAME type: ClusterIP diff --git a/packs/javascript-ui-nginx/charts/templates/canary.yaml b/packs/javascript-ui-nginx/charts/templates/canary.yaml new file mode 100644 index 000000000..bd5e3f857 --- /dev/null +++ b/packs/javascript-ui-nginx/charts/templates/canary.yaml @@ -0,0 +1,58 @@ +{{- if .Values.canary.enabled }} +apiVersion: flagger.app/v1alpha3 +kind: Canary +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + provider: istio + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + progressDeadlineSeconds: {{ .Values.canary.progressDeadlineSeconds }} + {{- if .Values.hpa.enabled }} + autoscalerRef: + apiVersion: autoscaling/v2beta1 + kind: HorizontalPodAutoscaler + name: {{ template "fullname" . }} + {{- end }} + service: + port: {{ .Values.service.externalPort }} + targetPort: {{ .Values.service.internalPort }} + gateways: + - {{ template "fullname" . }} + hosts: + - {{ .Values.canary.host }} + canaryAnalysis: + interval: {{ .Values.canary.canaryAnalysis.interval }} + threshold: {{ .Values.canary.canaryAnalysis.threshold }} + maxWeight: {{ .Values.canary.canaryAnalysis.maxWeight }} + stepWeight: {{ .Values.canary.canaryAnalysis.stepWeight }} + metrics: + - name: request-success-rate + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.interval }} + - name: request-duration + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.interval }} + +--- + +apiVersion: networking.istio.io/v1alpha3 +kind: Gateway +metadata: + name: {{ template "fullname" . }} +spec: + selector: + istio: ingressgateway + servers: + - port: + number: {{ .Values.service.externalPort }} + name: http + protocol: HTTP + hosts: + - {{ .Values.canary.host }} +{{- end }} diff --git a/packs/javascript-ui-nginx/charts/templates/deployment.yaml b/packs/javascript-ui-nginx/charts/templates/deployment.yaml index 2e833afe7..587450872 100644 --- a/packs/javascript-ui-nginx/charts/templates/deployment.yaml +++ b/packs/javascript-ui-nginx/charts/templates/deployment.yaml @@ -8,7 +8,10 @@ metadata: draft: {{ default "draft-app" .Values.draft }} chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" spec: +{{- if .Values.hpa.enabled }} +{{- else }} replicas: {{ .Values.replicaCount }} +{{- end }} template: metadata: labels: diff --git a/packs/javascript-ui-nginx/charts/templates/hpa.yaml b/packs/javascript-ui-nginx/charts/templates/hpa.yaml new file mode 100644 index 000000000..1c03eb4c9 --- /dev/null +++ b/packs/javascript-ui-nginx/charts/templates/hpa.yaml @@ -0,0 +1,25 @@ +{{- if .Values.hpa.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + minReplicas: {{ .Values.hpa.minReplicas }} + maxReplicas: {{ .Values.hpa.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.hpa.cpuTargetAverageUtilization }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.hpa.memoryTargetAverageUtilization }} +{{- end }} \ No newline at end of file diff --git a/packs/javascript-ui-nginx/charts/templates/service.yaml b/packs/javascript-ui-nginx/charts/templates/service.yaml index 9321361e3..9a2a4c758 100644 --- a/packs/javascript-ui-nginx/charts/templates/service.yaml +++ b/packs/javascript-ui-nginx/charts/templates/service.yaml @@ -1,4 +1,4 @@ -{{- if .Values.knativeDeploy }} +{{- if or .Values.knativeDeploy .Values.canary.enabled }} {{- else }} apiVersion: v1 kind: Service diff --git a/packs/javascript-ui-nginx/charts/values.yaml b/packs/javascript-ui-nginx/charts/values.yaml index 3c6af0766..33ef46856 100644 --- a/packs/javascript-ui-nginx/charts/values.yaml +++ b/packs/javascript-ui-nginx/charts/values.yaml @@ -13,6 +13,36 @@ env: # enable this flag to use knative serve to deploy the app knativeDeploy: false +# HorizontalPodAutoscaler +hpa: + enabled: false + minReplicas: 2 + maxReplicas: 6 + cpuTargetAverageUtilization: 80 + memoryTargetAverageUtilization: 80 + +# Canary deployments +# If enabled, Istio and Flagger need to be installed in the cluster +canary: + enabled: false + progressDeadlineSeconds: 60 + canaryAnalysis: + interval: "1m" + threshold: 5 + maxWeight: 60 + stepWeight: 20 + # WARNING: Canary deployments will fail and rollback if there is no traffic that will generate the below specified metrics. + metrics: + requestSuccessRate: + threshold: 99 + interval: "1m" + requestDuration: + threshold: 1000 + interval: "1m" + # The host is using Istio Gateway and is currently not auto-generated + # Please overwrite the `canary.host` in `values.yaml` in each environment repository (e.g., staging, production) + host: acme.com + service: name: REPLACE_ME_APP_NAME type: ClusterIP diff --git a/packs/javascript/charts/templates/canary.yaml b/packs/javascript/charts/templates/canary.yaml new file mode 100644 index 000000000..bd5e3f857 --- /dev/null +++ b/packs/javascript/charts/templates/canary.yaml @@ -0,0 +1,58 @@ +{{- if .Values.canary.enabled }} +apiVersion: flagger.app/v1alpha3 +kind: Canary +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + provider: istio + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + progressDeadlineSeconds: {{ .Values.canary.progressDeadlineSeconds }} + {{- if .Values.hpa.enabled }} + autoscalerRef: + apiVersion: autoscaling/v2beta1 + kind: HorizontalPodAutoscaler + name: {{ template "fullname" . }} + {{- end }} + service: + port: {{ .Values.service.externalPort }} + targetPort: {{ .Values.service.internalPort }} + gateways: + - {{ template "fullname" . }} + hosts: + - {{ .Values.canary.host }} + canaryAnalysis: + interval: {{ .Values.canary.canaryAnalysis.interval }} + threshold: {{ .Values.canary.canaryAnalysis.threshold }} + maxWeight: {{ .Values.canary.canaryAnalysis.maxWeight }} + stepWeight: {{ .Values.canary.canaryAnalysis.stepWeight }} + metrics: + - name: request-success-rate + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.interval }} + - name: request-duration + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.interval }} + +--- + +apiVersion: networking.istio.io/v1alpha3 +kind: Gateway +metadata: + name: {{ template "fullname" . }} +spec: + selector: + istio: ingressgateway + servers: + - port: + number: {{ .Values.service.externalPort }} + name: http + protocol: HTTP + hosts: + - {{ .Values.canary.host }} +{{- end }} diff --git a/packs/javascript/charts/templates/deployment.yaml b/packs/javascript/charts/templates/deployment.yaml index 118ea4810..7a789135a 100644 --- a/packs/javascript/charts/templates/deployment.yaml +++ b/packs/javascript/charts/templates/deployment.yaml @@ -8,7 +8,10 @@ metadata: draft: {{ default "draft-app" .Values.draft }} chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" spec: +{{- if .Values.hpa.enabled }} +{{- else }} replicas: {{ .Values.replicaCount }} +{{- end }} template: metadata: labels: diff --git a/packs/javascript/charts/templates/hpa.yaml b/packs/javascript/charts/templates/hpa.yaml new file mode 100644 index 000000000..1c03eb4c9 --- /dev/null +++ b/packs/javascript/charts/templates/hpa.yaml @@ -0,0 +1,25 @@ +{{- if .Values.hpa.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + minReplicas: {{ .Values.hpa.minReplicas }} + maxReplicas: {{ .Values.hpa.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.hpa.cpuTargetAverageUtilization }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.hpa.memoryTargetAverageUtilization }} +{{- end }} \ No newline at end of file diff --git a/packs/javascript/charts/templates/service.yaml b/packs/javascript/charts/templates/service.yaml index 9321361e3..9a2a4c758 100644 --- a/packs/javascript/charts/templates/service.yaml +++ b/packs/javascript/charts/templates/service.yaml @@ -1,4 +1,4 @@ -{{- if .Values.knativeDeploy }} +{{- if or .Values.knativeDeploy .Values.canary.enabled }} {{- else }} apiVersion: v1 kind: Service diff --git a/packs/javascript/charts/values.yaml b/packs/javascript/charts/values.yaml index 3facb40ba..382479218 100644 --- a/packs/javascript/charts/values.yaml +++ b/packs/javascript/charts/values.yaml @@ -13,6 +13,36 @@ env: # enable this flag to use knative serve to deploy the app knativeDeploy: false +# HorizontalPodAutoscaler +hpa: + enabled: false + minReplicas: 2 + maxReplicas: 6 + cpuTargetAverageUtilization: 80 + memoryTargetAverageUtilization: 80 + +# Canary deployments +# If enabled, Istio and Flagger need to be installed in the cluster +canary: + enabled: false + progressDeadlineSeconds: 60 + canaryAnalysis: + interval: "1m" + threshold: 5 + maxWeight: 60 + stepWeight: 20 + # WARNING: Canary deployments will fail and rollback if there is no traffic that will generate the below specified metrics. + metrics: + requestSuccessRate: + threshold: 99 + interval: "1m" + requestDuration: + threshold: 1000 + interval: "1m" + # The host is using Istio Gateway and is currently not auto-generated + # Please overwrite the `canary.host` in `values.yaml` in each environment repository (e.g., staging, production) + host: acme.com + service: name: REPLACE_ME_APP_NAME type: ClusterIP diff --git a/packs/liberty/charts/templates/canary.yaml b/packs/liberty/charts/templates/canary.yaml new file mode 100644 index 000000000..bd5e3f857 --- /dev/null +++ b/packs/liberty/charts/templates/canary.yaml @@ -0,0 +1,58 @@ +{{- if .Values.canary.enabled }} +apiVersion: flagger.app/v1alpha3 +kind: Canary +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + provider: istio + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + progressDeadlineSeconds: {{ .Values.canary.progressDeadlineSeconds }} + {{- if .Values.hpa.enabled }} + autoscalerRef: + apiVersion: autoscaling/v2beta1 + kind: HorizontalPodAutoscaler + name: {{ template "fullname" . }} + {{- end }} + service: + port: {{ .Values.service.externalPort }} + targetPort: {{ .Values.service.internalPort }} + gateways: + - {{ template "fullname" . }} + hosts: + - {{ .Values.canary.host }} + canaryAnalysis: + interval: {{ .Values.canary.canaryAnalysis.interval }} + threshold: {{ .Values.canary.canaryAnalysis.threshold }} + maxWeight: {{ .Values.canary.canaryAnalysis.maxWeight }} + stepWeight: {{ .Values.canary.canaryAnalysis.stepWeight }} + metrics: + - name: request-success-rate + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.interval }} + - name: request-duration + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.interval }} + +--- + +apiVersion: networking.istio.io/v1alpha3 +kind: Gateway +metadata: + name: {{ template "fullname" . }} +spec: + selector: + istio: ingressgateway + servers: + - port: + number: {{ .Values.service.externalPort }} + name: http + protocol: HTTP + hosts: + - {{ .Values.canary.host }} +{{- end }} diff --git a/packs/liberty/charts/templates/deployment.yaml b/packs/liberty/charts/templates/deployment.yaml index 52ccdba6f..f4858abcc 100644 --- a/packs/liberty/charts/templates/deployment.yaml +++ b/packs/liberty/charts/templates/deployment.yaml @@ -8,7 +8,10 @@ metadata: draft: {{ default "draft-app" .Values.draft }} chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" spec: +{{- if .Values.hpa.enabled }} +{{- else }} replicas: {{ .Values.replicaCount }} +{{- end }} template: metadata: labels: diff --git a/packs/liberty/charts/templates/hpa.yaml b/packs/liberty/charts/templates/hpa.yaml new file mode 100644 index 000000000..1c03eb4c9 --- /dev/null +++ b/packs/liberty/charts/templates/hpa.yaml @@ -0,0 +1,25 @@ +{{- if .Values.hpa.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + minReplicas: {{ .Values.hpa.minReplicas }} + maxReplicas: {{ .Values.hpa.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.hpa.cpuTargetAverageUtilization }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.hpa.memoryTargetAverageUtilization }} +{{- end }} \ No newline at end of file diff --git a/packs/liberty/charts/templates/service.yaml b/packs/liberty/charts/templates/service.yaml index 9321361e3..9a2a4c758 100644 --- a/packs/liberty/charts/templates/service.yaml +++ b/packs/liberty/charts/templates/service.yaml @@ -1,4 +1,4 @@ -{{- if .Values.knativeDeploy }} +{{- if or .Values.knativeDeploy .Values.canary.enabled }} {{- else }} apiVersion: v1 kind: Service diff --git a/packs/liberty/charts/values.yaml b/packs/liberty/charts/values.yaml index fece395db..805a61a02 100644 --- a/packs/liberty/charts/values.yaml +++ b/packs/liberty/charts/values.yaml @@ -13,6 +13,36 @@ env: # enable this flag to use knative serve to deploy the app knativeDeploy: false +# HorizontalPodAutoscaler +hpa: + enabled: false + minReplicas: 2 + maxReplicas: 6 + cpuTargetAverageUtilization: 80 + memoryTargetAverageUtilization: 80 + +# Canary deployments +# If enabled, Istio and Flagger need to be installed in the cluster +canary: + enabled: false + progressDeadlineSeconds: 60 + canaryAnalysis: + interval: "1m" + threshold: 5 + maxWeight: 60 + stepWeight: 20 + # WARNING: Canary deployments will fail and rollback if there is no traffic that will generate the below specified metrics. + metrics: + requestSuccessRate: + threshold: 99 + interval: "1m" + requestDuration: + threshold: 1000 + interval: "1m" + # The host is using Istio Gateway and is currently not auto-generated + # Please overwrite the `canary.host` in `values.yaml` in each environment repository (e.g., staging, production) + host: acme.com + service: name: REPLACE_ME_APP_NAME type: ClusterIP diff --git a/packs/maven-java11/charts/templates/canary.yaml b/packs/maven-java11/charts/templates/canary.yaml new file mode 100644 index 000000000..bd5e3f857 --- /dev/null +++ b/packs/maven-java11/charts/templates/canary.yaml @@ -0,0 +1,58 @@ +{{- if .Values.canary.enabled }} +apiVersion: flagger.app/v1alpha3 +kind: Canary +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + provider: istio + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + progressDeadlineSeconds: {{ .Values.canary.progressDeadlineSeconds }} + {{- if .Values.hpa.enabled }} + autoscalerRef: + apiVersion: autoscaling/v2beta1 + kind: HorizontalPodAutoscaler + name: {{ template "fullname" . }} + {{- end }} + service: + port: {{ .Values.service.externalPort }} + targetPort: {{ .Values.service.internalPort }} + gateways: + - {{ template "fullname" . }} + hosts: + - {{ .Values.canary.host }} + canaryAnalysis: + interval: {{ .Values.canary.canaryAnalysis.interval }} + threshold: {{ .Values.canary.canaryAnalysis.threshold }} + maxWeight: {{ .Values.canary.canaryAnalysis.maxWeight }} + stepWeight: {{ .Values.canary.canaryAnalysis.stepWeight }} + metrics: + - name: request-success-rate + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.interval }} + - name: request-duration + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.interval }} + +--- + +apiVersion: networking.istio.io/v1alpha3 +kind: Gateway +metadata: + name: {{ template "fullname" . }} +spec: + selector: + istio: ingressgateway + servers: + - port: + number: {{ .Values.service.externalPort }} + name: http + protocol: HTTP + hosts: + - {{ .Values.canary.host }} +{{- end }} diff --git a/packs/maven-java11/charts/templates/deployment.yaml b/packs/maven-java11/charts/templates/deployment.yaml index 52ccdba6f..f4858abcc 100644 --- a/packs/maven-java11/charts/templates/deployment.yaml +++ b/packs/maven-java11/charts/templates/deployment.yaml @@ -8,7 +8,10 @@ metadata: draft: {{ default "draft-app" .Values.draft }} chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" spec: +{{- if .Values.hpa.enabled }} +{{- else }} replicas: {{ .Values.replicaCount }} +{{- end }} template: metadata: labels: diff --git a/packs/maven-java11/charts/templates/hpa.yaml b/packs/maven-java11/charts/templates/hpa.yaml new file mode 100644 index 000000000..1c03eb4c9 --- /dev/null +++ b/packs/maven-java11/charts/templates/hpa.yaml @@ -0,0 +1,25 @@ +{{- if .Values.hpa.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + minReplicas: {{ .Values.hpa.minReplicas }} + maxReplicas: {{ .Values.hpa.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.hpa.cpuTargetAverageUtilization }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.hpa.memoryTargetAverageUtilization }} +{{- end }} \ No newline at end of file diff --git a/packs/maven-java11/charts/templates/service.yaml b/packs/maven-java11/charts/templates/service.yaml index 9321361e3..9a2a4c758 100644 --- a/packs/maven-java11/charts/templates/service.yaml +++ b/packs/maven-java11/charts/templates/service.yaml @@ -1,4 +1,4 @@ -{{- if .Values.knativeDeploy }} +{{- if or .Values.knativeDeploy .Values.canary.enabled }} {{- else }} apiVersion: v1 kind: Service diff --git a/packs/maven-java11/charts/values.yaml b/packs/maven-java11/charts/values.yaml index 4d7d16363..d8e3f3b61 100644 --- a/packs/maven-java11/charts/values.yaml +++ b/packs/maven-java11/charts/values.yaml @@ -13,6 +13,36 @@ env: # enable this flag to use knative serve to deploy the app knativeDeploy: false +# HorizontalPodAutoscaler +hpa: + enabled: false + minReplicas: 2 + maxReplicas: 6 + cpuTargetAverageUtilization: 80 + memoryTargetAverageUtilization: 80 + +# Canary deployments +# If enabled, Istio and Flagger need to be installed in the cluster +canary: + enabled: false + progressDeadlineSeconds: 60 + canaryAnalysis: + interval: "1m" + threshold: 5 + maxWeight: 60 + stepWeight: 20 + # WARNING: Canary deployments will fail and rollback if there is no traffic that will generate the below specified metrics. + metrics: + requestSuccessRate: + threshold: 99 + interval: "1m" + requestDuration: + threshold: 1000 + interval: "1m" + # The host is using Istio Gateway and is currently not auto-generated + # Please overwrite the `canary.host` in `values.yaml` in each environment repository (e.g., staging, production) + host: acme.com + service: name: REPLACE_ME_APP_NAME type: ClusterIP diff --git a/packs/maven-node-ruby/charts/templates/canary.yaml b/packs/maven-node-ruby/charts/templates/canary.yaml new file mode 100644 index 000000000..bd5e3f857 --- /dev/null +++ b/packs/maven-node-ruby/charts/templates/canary.yaml @@ -0,0 +1,58 @@ +{{- if .Values.canary.enabled }} +apiVersion: flagger.app/v1alpha3 +kind: Canary +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + provider: istio + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + progressDeadlineSeconds: {{ .Values.canary.progressDeadlineSeconds }} + {{- if .Values.hpa.enabled }} + autoscalerRef: + apiVersion: autoscaling/v2beta1 + kind: HorizontalPodAutoscaler + name: {{ template "fullname" . }} + {{- end }} + service: + port: {{ .Values.service.externalPort }} + targetPort: {{ .Values.service.internalPort }} + gateways: + - {{ template "fullname" . }} + hosts: + - {{ .Values.canary.host }} + canaryAnalysis: + interval: {{ .Values.canary.canaryAnalysis.interval }} + threshold: {{ .Values.canary.canaryAnalysis.threshold }} + maxWeight: {{ .Values.canary.canaryAnalysis.maxWeight }} + stepWeight: {{ .Values.canary.canaryAnalysis.stepWeight }} + metrics: + - name: request-success-rate + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.interval }} + - name: request-duration + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.interval }} + +--- + +apiVersion: networking.istio.io/v1alpha3 +kind: Gateway +metadata: + name: {{ template "fullname" . }} +spec: + selector: + istio: ingressgateway + servers: + - port: + number: {{ .Values.service.externalPort }} + name: http + protocol: HTTP + hosts: + - {{ .Values.canary.host }} +{{- end }} diff --git a/packs/maven-node-ruby/charts/templates/deployment.yaml b/packs/maven-node-ruby/charts/templates/deployment.yaml index 58af0d202..d86478cb8 100644 --- a/packs/maven-node-ruby/charts/templates/deployment.yaml +++ b/packs/maven-node-ruby/charts/templates/deployment.yaml @@ -8,7 +8,10 @@ metadata: draft: {{ default "draft-app" .Values.draft }} chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" spec: +{{- if .Values.hpa.enabled }} +{{- else }} replicas: {{ .Values.replicaCount }} +{{- end }} template: metadata: labels: diff --git a/packs/maven-node-ruby/charts/templates/hpa.yaml b/packs/maven-node-ruby/charts/templates/hpa.yaml new file mode 100644 index 000000000..1c03eb4c9 --- /dev/null +++ b/packs/maven-node-ruby/charts/templates/hpa.yaml @@ -0,0 +1,25 @@ +{{- if .Values.hpa.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + minReplicas: {{ .Values.hpa.minReplicas }} + maxReplicas: {{ .Values.hpa.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.hpa.cpuTargetAverageUtilization }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.hpa.memoryTargetAverageUtilization }} +{{- end }} \ No newline at end of file diff --git a/packs/maven-node-ruby/charts/templates/service.yaml b/packs/maven-node-ruby/charts/templates/service.yaml index 9321361e3..9a2a4c758 100644 --- a/packs/maven-node-ruby/charts/templates/service.yaml +++ b/packs/maven-node-ruby/charts/templates/service.yaml @@ -1,4 +1,4 @@ -{{- if .Values.knativeDeploy }} +{{- if or .Values.knativeDeploy .Values.canary.enabled }} {{- else }} apiVersion: v1 kind: Service diff --git a/packs/maven-node-ruby/charts/values.yaml b/packs/maven-node-ruby/charts/values.yaml index 00f260968..d89e9b550 100644 --- a/packs/maven-node-ruby/charts/values.yaml +++ b/packs/maven-node-ruby/charts/values.yaml @@ -13,6 +13,36 @@ env: # enable this flag to use knative serve to deploy the app knativeDeploy: false +# HorizontalPodAutoscaler +hpa: + enabled: false + minReplicas: 2 + maxReplicas: 6 + cpuTargetAverageUtilization: 80 + memoryTargetAverageUtilization: 80 + +# Canary deployments +# If enabled, Istio and Flagger need to be installed in the cluster +canary: + enabled: false + progressDeadlineSeconds: 60 + canaryAnalysis: + interval: "1m" + threshold: 5 + maxWeight: 60 + stepWeight: 20 + # WARNING: Canary deployments will fail and rollback if there is no traffic that will generate the below specified metrics. + metrics: + requestSuccessRate: + threshold: 99 + interval: "1m" + requestDuration: + threshold: 1000 + interval: "1m" + # The host is using Istio Gateway and is currently not auto-generated + # Please overwrite the `canary.host` in `values.yaml` in each environment repository (e.g., staging, production) + host: acme.com + service: name: REPLACE_ME_APP_NAME type: ClusterIP diff --git a/packs/maven-quarkus/charts/templates/canary.yaml b/packs/maven-quarkus/charts/templates/canary.yaml new file mode 100644 index 000000000..bd5e3f857 --- /dev/null +++ b/packs/maven-quarkus/charts/templates/canary.yaml @@ -0,0 +1,58 @@ +{{- if .Values.canary.enabled }} +apiVersion: flagger.app/v1alpha3 +kind: Canary +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + provider: istio + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + progressDeadlineSeconds: {{ .Values.canary.progressDeadlineSeconds }} + {{- if .Values.hpa.enabled }} + autoscalerRef: + apiVersion: autoscaling/v2beta1 + kind: HorizontalPodAutoscaler + name: {{ template "fullname" . }} + {{- end }} + service: + port: {{ .Values.service.externalPort }} + targetPort: {{ .Values.service.internalPort }} + gateways: + - {{ template "fullname" . }} + hosts: + - {{ .Values.canary.host }} + canaryAnalysis: + interval: {{ .Values.canary.canaryAnalysis.interval }} + threshold: {{ .Values.canary.canaryAnalysis.threshold }} + maxWeight: {{ .Values.canary.canaryAnalysis.maxWeight }} + stepWeight: {{ .Values.canary.canaryAnalysis.stepWeight }} + metrics: + - name: request-success-rate + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.interval }} + - name: request-duration + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.interval }} + +--- + +apiVersion: networking.istio.io/v1alpha3 +kind: Gateway +metadata: + name: {{ template "fullname" . }} +spec: + selector: + istio: ingressgateway + servers: + - port: + number: {{ .Values.service.externalPort }} + name: http + protocol: HTTP + hosts: + - {{ .Values.canary.host }} +{{- end }} diff --git a/packs/maven-quarkus/charts/templates/deployment.yaml b/packs/maven-quarkus/charts/templates/deployment.yaml index 58af0d202..d86478cb8 100644 --- a/packs/maven-quarkus/charts/templates/deployment.yaml +++ b/packs/maven-quarkus/charts/templates/deployment.yaml @@ -8,7 +8,10 @@ metadata: draft: {{ default "draft-app" .Values.draft }} chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" spec: +{{- if .Values.hpa.enabled }} +{{- else }} replicas: {{ .Values.replicaCount }} +{{- end }} template: metadata: labels: diff --git a/packs/maven-quarkus/charts/templates/hpa.yaml b/packs/maven-quarkus/charts/templates/hpa.yaml new file mode 100644 index 000000000..1c03eb4c9 --- /dev/null +++ b/packs/maven-quarkus/charts/templates/hpa.yaml @@ -0,0 +1,25 @@ +{{- if .Values.hpa.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + minReplicas: {{ .Values.hpa.minReplicas }} + maxReplicas: {{ .Values.hpa.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.hpa.cpuTargetAverageUtilization }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.hpa.memoryTargetAverageUtilization }} +{{- end }} \ No newline at end of file diff --git a/packs/maven-quarkus/charts/templates/service.yaml b/packs/maven-quarkus/charts/templates/service.yaml index 9321361e3..9a2a4c758 100644 --- a/packs/maven-quarkus/charts/templates/service.yaml +++ b/packs/maven-quarkus/charts/templates/service.yaml @@ -1,4 +1,4 @@ -{{- if .Values.knativeDeploy }} +{{- if or .Values.knativeDeploy .Values.canary.enabled }} {{- else }} apiVersion: v1 kind: Service diff --git a/packs/maven-quarkus/charts/values.yaml b/packs/maven-quarkus/charts/values.yaml index 00f260968..d89e9b550 100644 --- a/packs/maven-quarkus/charts/values.yaml +++ b/packs/maven-quarkus/charts/values.yaml @@ -13,6 +13,36 @@ env: # enable this flag to use knative serve to deploy the app knativeDeploy: false +# HorizontalPodAutoscaler +hpa: + enabled: false + minReplicas: 2 + maxReplicas: 6 + cpuTargetAverageUtilization: 80 + memoryTargetAverageUtilization: 80 + +# Canary deployments +# If enabled, Istio and Flagger need to be installed in the cluster +canary: + enabled: false + progressDeadlineSeconds: 60 + canaryAnalysis: + interval: "1m" + threshold: 5 + maxWeight: 60 + stepWeight: 20 + # WARNING: Canary deployments will fail and rollback if there is no traffic that will generate the below specified metrics. + metrics: + requestSuccessRate: + threshold: 99 + interval: "1m" + requestDuration: + threshold: 1000 + interval: "1m" + # The host is using Istio Gateway and is currently not auto-generated + # Please overwrite the `canary.host` in `values.yaml` in each environment repository (e.g., staging, production) + host: acme.com + service: name: REPLACE_ME_APP_NAME type: ClusterIP diff --git a/packs/maven/charts/templates/canary.yaml b/packs/maven/charts/templates/canary.yaml new file mode 100644 index 000000000..bd5e3f857 --- /dev/null +++ b/packs/maven/charts/templates/canary.yaml @@ -0,0 +1,58 @@ +{{- if .Values.canary.enabled }} +apiVersion: flagger.app/v1alpha3 +kind: Canary +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + provider: istio + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + progressDeadlineSeconds: {{ .Values.canary.progressDeadlineSeconds }} + {{- if .Values.hpa.enabled }} + autoscalerRef: + apiVersion: autoscaling/v2beta1 + kind: HorizontalPodAutoscaler + name: {{ template "fullname" . }} + {{- end }} + service: + port: {{ .Values.service.externalPort }} + targetPort: {{ .Values.service.internalPort }} + gateways: + - {{ template "fullname" . }} + hosts: + - {{ .Values.canary.host }} + canaryAnalysis: + interval: {{ .Values.canary.canaryAnalysis.interval }} + threshold: {{ .Values.canary.canaryAnalysis.threshold }} + maxWeight: {{ .Values.canary.canaryAnalysis.maxWeight }} + stepWeight: {{ .Values.canary.canaryAnalysis.stepWeight }} + metrics: + - name: request-success-rate + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.interval }} + - name: request-duration + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.interval }} + +--- + +apiVersion: networking.istio.io/v1alpha3 +kind: Gateway +metadata: + name: {{ template "fullname" . }} +spec: + selector: + istio: ingressgateway + servers: + - port: + number: {{ .Values.service.externalPort }} + name: http + protocol: HTTP + hosts: + - {{ .Values.canary.host }} +{{- end }} diff --git a/packs/maven/charts/templates/deployment.yaml b/packs/maven/charts/templates/deployment.yaml index 52ccdba6f..f4858abcc 100644 --- a/packs/maven/charts/templates/deployment.yaml +++ b/packs/maven/charts/templates/deployment.yaml @@ -8,7 +8,10 @@ metadata: draft: {{ default "draft-app" .Values.draft }} chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" spec: +{{- if .Values.hpa.enabled }} +{{- else }} replicas: {{ .Values.replicaCount }} +{{- end }} template: metadata: labels: diff --git a/packs/maven/charts/templates/hpa.yaml b/packs/maven/charts/templates/hpa.yaml new file mode 100644 index 000000000..1c03eb4c9 --- /dev/null +++ b/packs/maven/charts/templates/hpa.yaml @@ -0,0 +1,25 @@ +{{- if .Values.hpa.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + minReplicas: {{ .Values.hpa.minReplicas }} + maxReplicas: {{ .Values.hpa.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.hpa.cpuTargetAverageUtilization }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.hpa.memoryTargetAverageUtilization }} +{{- end }} \ No newline at end of file diff --git a/packs/maven/charts/templates/service.yaml b/packs/maven/charts/templates/service.yaml index 9321361e3..9a2a4c758 100644 --- a/packs/maven/charts/templates/service.yaml +++ b/packs/maven/charts/templates/service.yaml @@ -1,4 +1,4 @@ -{{- if .Values.knativeDeploy }} +{{- if or .Values.knativeDeploy .Values.canary.enabled }} {{- else }} apiVersion: v1 kind: Service diff --git a/packs/maven/charts/values.yaml b/packs/maven/charts/values.yaml index 4d7d16363..d8e3f3b61 100644 --- a/packs/maven/charts/values.yaml +++ b/packs/maven/charts/values.yaml @@ -13,6 +13,36 @@ env: # enable this flag to use knative serve to deploy the app knativeDeploy: false +# HorizontalPodAutoscaler +hpa: + enabled: false + minReplicas: 2 + maxReplicas: 6 + cpuTargetAverageUtilization: 80 + memoryTargetAverageUtilization: 80 + +# Canary deployments +# If enabled, Istio and Flagger need to be installed in the cluster +canary: + enabled: false + progressDeadlineSeconds: 60 + canaryAnalysis: + interval: "1m" + threshold: 5 + maxWeight: 60 + stepWeight: 20 + # WARNING: Canary deployments will fail and rollback if there is no traffic that will generate the below specified metrics. + metrics: + requestSuccessRate: + threshold: 99 + interval: "1m" + requestDuration: + threshold: 1000 + interval: "1m" + # The host is using Istio Gateway and is currently not auto-generated + # Please overwrite the `canary.host` in `values.yaml` in each environment repository (e.g., staging, production) + host: acme.com + service: name: REPLACE_ME_APP_NAME type: ClusterIP diff --git a/packs/php/charts/templates/canary.yaml b/packs/php/charts/templates/canary.yaml new file mode 100644 index 000000000..bd5e3f857 --- /dev/null +++ b/packs/php/charts/templates/canary.yaml @@ -0,0 +1,58 @@ +{{- if .Values.canary.enabled }} +apiVersion: flagger.app/v1alpha3 +kind: Canary +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + provider: istio + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + progressDeadlineSeconds: {{ .Values.canary.progressDeadlineSeconds }} + {{- if .Values.hpa.enabled }} + autoscalerRef: + apiVersion: autoscaling/v2beta1 + kind: HorizontalPodAutoscaler + name: {{ template "fullname" . }} + {{- end }} + service: + port: {{ .Values.service.externalPort }} + targetPort: {{ .Values.service.internalPort }} + gateways: + - {{ template "fullname" . }} + hosts: + - {{ .Values.canary.host }} + canaryAnalysis: + interval: {{ .Values.canary.canaryAnalysis.interval }} + threshold: {{ .Values.canary.canaryAnalysis.threshold }} + maxWeight: {{ .Values.canary.canaryAnalysis.maxWeight }} + stepWeight: {{ .Values.canary.canaryAnalysis.stepWeight }} + metrics: + - name: request-success-rate + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.interval }} + - name: request-duration + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.interval }} + +--- + +apiVersion: networking.istio.io/v1alpha3 +kind: Gateway +metadata: + name: {{ template "fullname" . }} +spec: + selector: + istio: ingressgateway + servers: + - port: + number: {{ .Values.service.externalPort }} + name: http + protocol: HTTP + hosts: + - {{ .Values.canary.host }} +{{- end }} diff --git a/packs/php/charts/templates/deployment.yaml b/packs/php/charts/templates/deployment.yaml index 118ea4810..7a789135a 100644 --- a/packs/php/charts/templates/deployment.yaml +++ b/packs/php/charts/templates/deployment.yaml @@ -8,7 +8,10 @@ metadata: draft: {{ default "draft-app" .Values.draft }} chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" spec: +{{- if .Values.hpa.enabled }} +{{- else }} replicas: {{ .Values.replicaCount }} +{{- end }} template: metadata: labels: diff --git a/packs/php/charts/templates/hpa.yaml b/packs/php/charts/templates/hpa.yaml new file mode 100644 index 000000000..1c03eb4c9 --- /dev/null +++ b/packs/php/charts/templates/hpa.yaml @@ -0,0 +1,25 @@ +{{- if .Values.hpa.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + minReplicas: {{ .Values.hpa.minReplicas }} + maxReplicas: {{ .Values.hpa.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.hpa.cpuTargetAverageUtilization }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.hpa.memoryTargetAverageUtilization }} +{{- end }} \ No newline at end of file diff --git a/packs/php/charts/templates/service.yaml b/packs/php/charts/templates/service.yaml index 9321361e3..9a2a4c758 100644 --- a/packs/php/charts/templates/service.yaml +++ b/packs/php/charts/templates/service.yaml @@ -1,4 +1,4 @@ -{{- if .Values.knativeDeploy }} +{{- if or .Values.knativeDeploy .Values.canary.enabled }} {{- else }} apiVersion: v1 kind: Service diff --git a/packs/php/charts/values.yaml b/packs/php/charts/values.yaml index 8880c8882..58f7880c7 100644 --- a/packs/php/charts/values.yaml +++ b/packs/php/charts/values.yaml @@ -13,6 +13,36 @@ env: # enable this flag to use knative serve to deploy the app knativeDeploy: false +# HorizontalPodAutoscaler +hpa: + enabled: false + minReplicas: 2 + maxReplicas: 6 + cpuTargetAverageUtilization: 80 + memoryTargetAverageUtilization: 80 + +# Canary deployments +# If enabled, Istio and Flagger need to be installed in the cluster +canary: + enabled: false + progressDeadlineSeconds: 60 + canaryAnalysis: + interval: "1m" + threshold: 5 + maxWeight: 60 + stepWeight: 20 + # WARNING: Canary deployments will fail and rollback if there is no traffic that will generate the below specified metrics. + metrics: + requestSuccessRate: + threshold: 99 + interval: "1m" + requestDuration: + threshold: 1000 + interval: "1m" + # The host is using Istio Gateway and is currently not auto-generated + # Please overwrite the `canary.host` in `values.yaml` in each environment repository (e.g., staging, production) + host: acme.com + service: name: REPLACE_ME_APP_NAME type: ClusterIP diff --git a/packs/python/charts/templates/canary.yaml b/packs/python/charts/templates/canary.yaml new file mode 100644 index 000000000..bd5e3f857 --- /dev/null +++ b/packs/python/charts/templates/canary.yaml @@ -0,0 +1,58 @@ +{{- if .Values.canary.enabled }} +apiVersion: flagger.app/v1alpha3 +kind: Canary +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + provider: istio + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + progressDeadlineSeconds: {{ .Values.canary.progressDeadlineSeconds }} + {{- if .Values.hpa.enabled }} + autoscalerRef: + apiVersion: autoscaling/v2beta1 + kind: HorizontalPodAutoscaler + name: {{ template "fullname" . }} + {{- end }} + service: + port: {{ .Values.service.externalPort }} + targetPort: {{ .Values.service.internalPort }} + gateways: + - {{ template "fullname" . }} + hosts: + - {{ .Values.canary.host }} + canaryAnalysis: + interval: {{ .Values.canary.canaryAnalysis.interval }} + threshold: {{ .Values.canary.canaryAnalysis.threshold }} + maxWeight: {{ .Values.canary.canaryAnalysis.maxWeight }} + stepWeight: {{ .Values.canary.canaryAnalysis.stepWeight }} + metrics: + - name: request-success-rate + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.interval }} + - name: request-duration + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.interval }} + +--- + +apiVersion: networking.istio.io/v1alpha3 +kind: Gateway +metadata: + name: {{ template "fullname" . }} +spec: + selector: + istio: ingressgateway + servers: + - port: + number: {{ .Values.service.externalPort }} + name: http + protocol: HTTP + hosts: + - {{ .Values.canary.host }} +{{- end }} diff --git a/packs/python/charts/templates/deployment.yaml b/packs/python/charts/templates/deployment.yaml index 650c551ba..028797583 100644 --- a/packs/python/charts/templates/deployment.yaml +++ b/packs/python/charts/templates/deployment.yaml @@ -8,7 +8,10 @@ metadata: draft: {{ default "draft-app" .Values.draft }} chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" spec: +{{- if .Values.hpa.enabled }} +{{- else }} replicas: {{ .Values.replicaCount }} +{{- end }} template: metadata: labels: diff --git a/packs/python/charts/templates/hpa.yaml b/packs/python/charts/templates/hpa.yaml new file mode 100644 index 000000000..1c03eb4c9 --- /dev/null +++ b/packs/python/charts/templates/hpa.yaml @@ -0,0 +1,25 @@ +{{- if .Values.hpa.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + minReplicas: {{ .Values.hpa.minReplicas }} + maxReplicas: {{ .Values.hpa.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.hpa.cpuTargetAverageUtilization }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.hpa.memoryTargetAverageUtilization }} +{{- end }} \ No newline at end of file diff --git a/packs/python/charts/templates/service.yaml b/packs/python/charts/templates/service.yaml index 9321361e3..9a2a4c758 100644 --- a/packs/python/charts/templates/service.yaml +++ b/packs/python/charts/templates/service.yaml @@ -1,4 +1,4 @@ -{{- if .Values.knativeDeploy }} +{{- if or .Values.knativeDeploy .Values.canary.enabled }} {{- else }} apiVersion: v1 kind: Service diff --git a/packs/python/charts/values.yaml b/packs/python/charts/values.yaml index 5f4fbbc5c..13d7a51b4 100644 --- a/packs/python/charts/values.yaml +++ b/packs/python/charts/values.yaml @@ -13,6 +13,36 @@ env: # enable this flag to use knative serve to deploy the app knativeDeploy: false +# HorizontalPodAutoscaler +hpa: + enabled: false + minReplicas: 2 + maxReplicas: 6 + cpuTargetAverageUtilization: 80 + memoryTargetAverageUtilization: 80 + +# Canary deployments +# If enabled, Istio and Flagger need to be installed in the cluster +canary: + enabled: false + progressDeadlineSeconds: 60 + canaryAnalysis: + interval: "1m" + threshold: 5 + maxWeight: 60 + stepWeight: 20 + # WARNING: Canary deployments will fail and rollback if there is no traffic that will generate the below specified metrics. + metrics: + requestSuccessRate: + threshold: 99 + interval: "1m" + requestDuration: + threshold: 1000 + interval: "1m" + # The host is using Istio Gateway and is currently not auto-generated + # Please overwrite the `canary.host` in `values.yaml` in each environment repository (e.g., staging, production) + host: acme.com + service: name: REPLACE_ME_APP_NAME type: ClusterIP diff --git a/packs/ruby/charts/templates/canary.yaml b/packs/ruby/charts/templates/canary.yaml new file mode 100644 index 000000000..bd5e3f857 --- /dev/null +++ b/packs/ruby/charts/templates/canary.yaml @@ -0,0 +1,58 @@ +{{- if .Values.canary.enabled }} +apiVersion: flagger.app/v1alpha3 +kind: Canary +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + provider: istio + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + progressDeadlineSeconds: {{ .Values.canary.progressDeadlineSeconds }} + {{- if .Values.hpa.enabled }} + autoscalerRef: + apiVersion: autoscaling/v2beta1 + kind: HorizontalPodAutoscaler + name: {{ template "fullname" . }} + {{- end }} + service: + port: {{ .Values.service.externalPort }} + targetPort: {{ .Values.service.internalPort }} + gateways: + - {{ template "fullname" . }} + hosts: + - {{ .Values.canary.host }} + canaryAnalysis: + interval: {{ .Values.canary.canaryAnalysis.interval }} + threshold: {{ .Values.canary.canaryAnalysis.threshold }} + maxWeight: {{ .Values.canary.canaryAnalysis.maxWeight }} + stepWeight: {{ .Values.canary.canaryAnalysis.stepWeight }} + metrics: + - name: request-success-rate + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.interval }} + - name: request-duration + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.interval }} + +--- + +apiVersion: networking.istio.io/v1alpha3 +kind: Gateway +metadata: + name: {{ template "fullname" . }} +spec: + selector: + istio: ingressgateway + servers: + - port: + number: {{ .Values.service.externalPort }} + name: http + protocol: HTTP + hosts: + - {{ .Values.canary.host }} +{{- end }} diff --git a/packs/ruby/charts/templates/deployment.yaml b/packs/ruby/charts/templates/deployment.yaml index 52ccdba6f..f4858abcc 100644 --- a/packs/ruby/charts/templates/deployment.yaml +++ b/packs/ruby/charts/templates/deployment.yaml @@ -8,7 +8,10 @@ metadata: draft: {{ default "draft-app" .Values.draft }} chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" spec: +{{- if .Values.hpa.enabled }} +{{- else }} replicas: {{ .Values.replicaCount }} +{{- end }} template: metadata: labels: diff --git a/packs/ruby/charts/templates/hpa.yaml b/packs/ruby/charts/templates/hpa.yaml new file mode 100644 index 000000000..1c03eb4c9 --- /dev/null +++ b/packs/ruby/charts/templates/hpa.yaml @@ -0,0 +1,25 @@ +{{- if .Values.hpa.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + minReplicas: {{ .Values.hpa.minReplicas }} + maxReplicas: {{ .Values.hpa.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.hpa.cpuTargetAverageUtilization }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.hpa.memoryTargetAverageUtilization }} +{{- end }} \ No newline at end of file diff --git a/packs/ruby/charts/templates/service.yaml b/packs/ruby/charts/templates/service.yaml index 9321361e3..9a2a4c758 100644 --- a/packs/ruby/charts/templates/service.yaml +++ b/packs/ruby/charts/templates/service.yaml @@ -1,4 +1,4 @@ -{{- if .Values.knativeDeploy }} +{{- if or .Values.knativeDeploy .Values.canary.enabled }} {{- else }} apiVersion: v1 kind: Service diff --git a/packs/ruby/charts/values.yaml b/packs/ruby/charts/values.yaml index 4a851c1d1..4122bb124 100644 --- a/packs/ruby/charts/values.yaml +++ b/packs/ruby/charts/values.yaml @@ -13,6 +13,36 @@ env: # enable this flag to use knative serve to deploy the app knativeDeploy: false +# HorizontalPodAutoscaler +hpa: + enabled: false + minReplicas: 2 + maxReplicas: 6 + cpuTargetAverageUtilization: 80 + memoryTargetAverageUtilization: 80 + +# Canary deployments +# If enabled, Istio and Flagger need to be installed in the cluster +canary: + enabled: false + progressDeadlineSeconds: 60 + canaryAnalysis: + interval: "1m" + threshold: 5 + maxWeight: 60 + stepWeight: 20 + # WARNING: Canary deployments will fail and rollback if there is no traffic that will generate the below specified metrics. + metrics: + requestSuccessRate: + threshold: 99 + interval: "1m" + requestDuration: + threshold: 1000 + interval: "1m" + # The host is using Istio Gateway and is currently not auto-generated + # Please overwrite the `canary.host` in `values.yaml` in each environment repository (e.g., staging, production) + host: acme.com + service: name: REPLACE_ME_APP_NAME type: ClusterIP diff --git a/packs/rust/charts/templates/canary.yaml b/packs/rust/charts/templates/canary.yaml new file mode 100644 index 000000000..bd5e3f857 --- /dev/null +++ b/packs/rust/charts/templates/canary.yaml @@ -0,0 +1,58 @@ +{{- if .Values.canary.enabled }} +apiVersion: flagger.app/v1alpha3 +kind: Canary +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + provider: istio + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + progressDeadlineSeconds: {{ .Values.canary.progressDeadlineSeconds }} + {{- if .Values.hpa.enabled }} + autoscalerRef: + apiVersion: autoscaling/v2beta1 + kind: HorizontalPodAutoscaler + name: {{ template "fullname" . }} + {{- end }} + service: + port: {{ .Values.service.externalPort }} + targetPort: {{ .Values.service.internalPort }} + gateways: + - {{ template "fullname" . }} + hosts: + - {{ .Values.canary.host }} + canaryAnalysis: + interval: {{ .Values.canary.canaryAnalysis.interval }} + threshold: {{ .Values.canary.canaryAnalysis.threshold }} + maxWeight: {{ .Values.canary.canaryAnalysis.maxWeight }} + stepWeight: {{ .Values.canary.canaryAnalysis.stepWeight }} + metrics: + - name: request-success-rate + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.interval }} + - name: request-duration + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.interval }} + +--- + +apiVersion: networking.istio.io/v1alpha3 +kind: Gateway +metadata: + name: {{ template "fullname" . }} +spec: + selector: + istio: ingressgateway + servers: + - port: + number: {{ .Values.service.externalPort }} + name: http + protocol: HTTP + hosts: + - {{ .Values.canary.host }} +{{- end }} diff --git a/packs/rust/charts/templates/deployment.yaml b/packs/rust/charts/templates/deployment.yaml index 52ccdba6f..f4858abcc 100644 --- a/packs/rust/charts/templates/deployment.yaml +++ b/packs/rust/charts/templates/deployment.yaml @@ -8,7 +8,10 @@ metadata: draft: {{ default "draft-app" .Values.draft }} chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" spec: +{{- if .Values.hpa.enabled }} +{{- else }} replicas: {{ .Values.replicaCount }} +{{- end }} template: metadata: labels: diff --git a/packs/rust/charts/templates/hpa.yaml b/packs/rust/charts/templates/hpa.yaml new file mode 100644 index 000000000..1c03eb4c9 --- /dev/null +++ b/packs/rust/charts/templates/hpa.yaml @@ -0,0 +1,25 @@ +{{- if .Values.hpa.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + minReplicas: {{ .Values.hpa.minReplicas }} + maxReplicas: {{ .Values.hpa.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.hpa.cpuTargetAverageUtilization }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.hpa.memoryTargetAverageUtilization }} +{{- end }} \ No newline at end of file diff --git a/packs/rust/charts/templates/service.yaml b/packs/rust/charts/templates/service.yaml index 9321361e3..9a2a4c758 100644 --- a/packs/rust/charts/templates/service.yaml +++ b/packs/rust/charts/templates/service.yaml @@ -1,4 +1,4 @@ -{{- if .Values.knativeDeploy }} +{{- if or .Values.knativeDeploy .Values.canary.enabled }} {{- else }} apiVersion: v1 kind: Service diff --git a/packs/rust/charts/values.yaml b/packs/rust/charts/values.yaml index 90b4b08e1..114cade0c 100644 --- a/packs/rust/charts/values.yaml +++ b/packs/rust/charts/values.yaml @@ -13,6 +13,36 @@ env: # enable this flag to use knative serve to deploy the app knativeDeploy: false +# HorizontalPodAutoscaler +hpa: + enabled: false + minReplicas: 2 + maxReplicas: 6 + cpuTargetAverageUtilization: 80 + memoryTargetAverageUtilization: 80 + +# Canary deployments +# If enabled, Istio and Flagger need to be installed in the cluster +canary: + enabled: false + progressDeadlineSeconds: 60 + canaryAnalysis: + interval: "1m" + threshold: 5 + maxWeight: 60 + stepWeight: 20 + # WARNING: Canary deployments will fail and rollback if there is no traffic that will generate the below specified metrics. + metrics: + requestSuccessRate: + threshold: 99 + interval: "1m" + requestDuration: + threshold: 1000 + interval: "1m" + # The host is using Istio Gateway and is currently not auto-generated + # Please overwrite the `canary.host` in `values.yaml` in each environment repository (e.g., staging, production) + host: acme.com + service: name: REPLACE_ME_APP_NAME type: ClusterIP diff --git a/packs/scala/charts/templates/canary.yaml b/packs/scala/charts/templates/canary.yaml new file mode 100644 index 000000000..bd5e3f857 --- /dev/null +++ b/packs/scala/charts/templates/canary.yaml @@ -0,0 +1,58 @@ +{{- if .Values.canary.enabled }} +apiVersion: flagger.app/v1alpha3 +kind: Canary +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + provider: istio + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + progressDeadlineSeconds: {{ .Values.canary.progressDeadlineSeconds }} + {{- if .Values.hpa.enabled }} + autoscalerRef: + apiVersion: autoscaling/v2beta1 + kind: HorizontalPodAutoscaler + name: {{ template "fullname" . }} + {{- end }} + service: + port: {{ .Values.service.externalPort }} + targetPort: {{ .Values.service.internalPort }} + gateways: + - {{ template "fullname" . }} + hosts: + - {{ .Values.canary.host }} + canaryAnalysis: + interval: {{ .Values.canary.canaryAnalysis.interval }} + threshold: {{ .Values.canary.canaryAnalysis.threshold }} + maxWeight: {{ .Values.canary.canaryAnalysis.maxWeight }} + stepWeight: {{ .Values.canary.canaryAnalysis.stepWeight }} + metrics: + - name: request-success-rate + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.interval }} + - name: request-duration + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.interval }} + +--- + +apiVersion: networking.istio.io/v1alpha3 +kind: Gateway +metadata: + name: {{ template "fullname" . }} +spec: + selector: + istio: ingressgateway + servers: + - port: + number: {{ .Values.service.externalPort }} + name: http + protocol: HTTP + hosts: + - {{ .Values.canary.host }} +{{- end }} diff --git a/packs/scala/charts/templates/deployment.yaml b/packs/scala/charts/templates/deployment.yaml index 52ccdba6f..f4858abcc 100644 --- a/packs/scala/charts/templates/deployment.yaml +++ b/packs/scala/charts/templates/deployment.yaml @@ -8,7 +8,10 @@ metadata: draft: {{ default "draft-app" .Values.draft }} chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" spec: +{{- if .Values.hpa.enabled }} +{{- else }} replicas: {{ .Values.replicaCount }} +{{- end }} template: metadata: labels: diff --git a/packs/scala/charts/templates/hpa.yaml b/packs/scala/charts/templates/hpa.yaml new file mode 100644 index 000000000..1c03eb4c9 --- /dev/null +++ b/packs/scala/charts/templates/hpa.yaml @@ -0,0 +1,25 @@ +{{- if .Values.hpa.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + minReplicas: {{ .Values.hpa.minReplicas }} + maxReplicas: {{ .Values.hpa.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.hpa.cpuTargetAverageUtilization }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.hpa.memoryTargetAverageUtilization }} +{{- end }} \ No newline at end of file diff --git a/packs/scala/charts/templates/service.yaml b/packs/scala/charts/templates/service.yaml index 2b53298c5..f42727561 100644 --- a/packs/scala/charts/templates/service.yaml +++ b/packs/scala/charts/templates/service.yaml @@ -1,4 +1,4 @@ -{{- if .Values.knativeDeploy }} +{{- if or .Values.knativeDeploy .Values.canary.enabled }} {{- else }} apiVersion: v1 kind: Service diff --git a/packs/scala/charts/values.yaml b/packs/scala/charts/values.yaml index 22e6480e4..830d03ca1 100644 --- a/packs/scala/charts/values.yaml +++ b/packs/scala/charts/values.yaml @@ -13,6 +13,36 @@ env: # enable this flag to use knative serve to deploy the app knativeDeploy: false +# HorizontalPodAutoscaler +hpa: + enabled: false + minReplicas: 2 + maxReplicas: 6 + cpuTargetAverageUtilization: 80 + memoryTargetAverageUtilization: 80 + +# Canary deployments +# If enabled, Istio and Flagger need to be installed in the cluster +canary: + enabled: false + progressDeadlineSeconds: 60 + canaryAnalysis: + interval: "1m" + threshold: 5 + maxWeight: 60 + stepWeight: 20 + # WARNING: Canary deployments will fail and rollback if there is no traffic that will generate the below specified metrics. + metrics: + requestSuccessRate: + threshold: 99 + interval: "1m" + requestDuration: + threshold: 1000 + interval: "1m" + # The host is using Istio Gateway and is currently not auto-generated + # Please overwrite the `canary.host` in `values.yaml` in each environment repository (e.g., staging, production) + host: acme.com + service: name: REPLACE_ME_APP_NAME type: ClusterIP diff --git a/packs/swift/chart/templates/canary.yaml b/packs/swift/chart/templates/canary.yaml new file mode 100644 index 000000000..bd5e3f857 --- /dev/null +++ b/packs/swift/chart/templates/canary.yaml @@ -0,0 +1,58 @@ +{{- if .Values.canary.enabled }} +apiVersion: flagger.app/v1alpha3 +kind: Canary +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + provider: istio + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + progressDeadlineSeconds: {{ .Values.canary.progressDeadlineSeconds }} + {{- if .Values.hpa.enabled }} + autoscalerRef: + apiVersion: autoscaling/v2beta1 + kind: HorizontalPodAutoscaler + name: {{ template "fullname" . }} + {{- end }} + service: + port: {{ .Values.service.externalPort }} + targetPort: {{ .Values.service.internalPort }} + gateways: + - {{ template "fullname" . }} + hosts: + - {{ .Values.canary.host }} + canaryAnalysis: + interval: {{ .Values.canary.canaryAnalysis.interval }} + threshold: {{ .Values.canary.canaryAnalysis.threshold }} + maxWeight: {{ .Values.canary.canaryAnalysis.maxWeight }} + stepWeight: {{ .Values.canary.canaryAnalysis.stepWeight }} + metrics: + - name: request-success-rate + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.interval }} + - name: request-duration + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.interval }} + +--- + +apiVersion: networking.istio.io/v1alpha3 +kind: Gateway +metadata: + name: {{ template "fullname" . }} +spec: + selector: + istio: ingressgateway + servers: + - port: + number: {{ .Values.service.externalPort }} + name: http + protocol: HTTP + hosts: + - {{ .Values.canary.host }} +{{- end }} diff --git a/packs/swift/chart/templates/deployment.yaml b/packs/swift/chart/templates/deployment.yaml index bdc83c69a..91e5533ad 100644 --- a/packs/swift/chart/templates/deployment.yaml +++ b/packs/swift/chart/templates/deployment.yaml @@ -8,7 +8,10 @@ metadata: chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" draft: {{ default "draft-app" .Values.draft }} spec: +{{- if .Values.hpa.enabled }} +{{- else }} replicas: {{ .Values.replicaCount }} +{{- end }} template: metadata: labels: diff --git a/packs/swift/chart/templates/hpa.yaml b/packs/swift/chart/templates/hpa.yaml new file mode 100644 index 000000000..1c03eb4c9 --- /dev/null +++ b/packs/swift/chart/templates/hpa.yaml @@ -0,0 +1,25 @@ +{{- if .Values.hpa.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + minReplicas: {{ .Values.hpa.minReplicas }} + maxReplicas: {{ .Values.hpa.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.hpa.cpuTargetAverageUtilization }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.hpa.memoryTargetAverageUtilization }} +{{- end }} \ No newline at end of file diff --git a/packs/swift/chart/templates/service.yaml b/packs/swift/chart/templates/service.yaml index 2e2bb79ce..4f3dbe9ff 100644 --- a/packs/swift/chart/templates/service.yaml +++ b/packs/swift/chart/templates/service.yaml @@ -1,4 +1,4 @@ -{{- if .Values.knativeDeploy }} +{{- if or .Values.knativeDeploy .Values.canary.enabled }} {{- else }} apiVersion: v1 kind: Service diff --git a/packs/swift/chart/values.yaml b/packs/swift/chart/values.yaml index 15464f34f..55ca4a812 100644 --- a/packs/swift/chart/values.yaml +++ b/packs/swift/chart/values.yaml @@ -13,6 +13,36 @@ env: # enable this flag to use knative serve to deploy the app knativeDeploy: false +# HorizontalPodAutoscaler +hpa: + enabled: false + minReplicas: 2 + maxReplicas: 6 + cpuTargetAverageUtilization: 80 + memoryTargetAverageUtilization: 80 + +# Canary deployments +# If enabled, Istio and Flagger need to be installed in the cluster +canary: + enabled: false + progressDeadlineSeconds: 60 + canaryAnalysis: + interval: "1m" + threshold: 5 + maxWeight: 60 + stepWeight: 20 + # WARNING: Canary deployments will fail and rollback if there is no traffic that will generate the below specified metrics. + metrics: + requestSuccessRate: + threshold: 99 + interval: "1m" + requestDuration: + threshold: 1000 + interval: "1m" + # The host is using Istio Gateway and is currently not auto-generated + # Please overwrite the `canary.host` in `values.yaml` in each environment repository (e.g., staging, production) + host: acme.com + service: name: REPLACE_ME_APP_NAME type: ClusterIP diff --git a/packs/typescript/charts/templates/canary.yaml b/packs/typescript/charts/templates/canary.yaml new file mode 100644 index 000000000..bd5e3f857 --- /dev/null +++ b/packs/typescript/charts/templates/canary.yaml @@ -0,0 +1,58 @@ +{{- if .Values.canary.enabled }} +apiVersion: flagger.app/v1alpha3 +kind: Canary +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + provider: istio + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + progressDeadlineSeconds: {{ .Values.canary.progressDeadlineSeconds }} + {{- if .Values.hpa.enabled }} + autoscalerRef: + apiVersion: autoscaling/v2beta1 + kind: HorizontalPodAutoscaler + name: {{ template "fullname" . }} + {{- end }} + service: + port: {{ .Values.service.externalPort }} + targetPort: {{ .Values.service.internalPort }} + gateways: + - {{ template "fullname" . }} + hosts: + - {{ .Values.canary.host }} + canaryAnalysis: + interval: {{ .Values.canary.canaryAnalysis.interval }} + threshold: {{ .Values.canary.canaryAnalysis.threshold }} + maxWeight: {{ .Values.canary.canaryAnalysis.maxWeight }} + stepWeight: {{ .Values.canary.canaryAnalysis.stepWeight }} + metrics: + - name: request-success-rate + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.interval }} + - name: request-duration + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.interval }} + +--- + +apiVersion: networking.istio.io/v1alpha3 +kind: Gateway +metadata: + name: {{ template "fullname" . }} +spec: + selector: + istio: ingressgateway + servers: + - port: + number: {{ .Values.service.externalPort }} + name: http + protocol: HTTP + hosts: + - {{ .Values.canary.host }} +{{- end }} diff --git a/packs/typescript/charts/templates/deployment.yaml b/packs/typescript/charts/templates/deployment.yaml index 52ccdba6f..f4858abcc 100644 --- a/packs/typescript/charts/templates/deployment.yaml +++ b/packs/typescript/charts/templates/deployment.yaml @@ -8,7 +8,10 @@ metadata: draft: {{ default "draft-app" .Values.draft }} chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" spec: +{{- if .Values.hpa.enabled }} +{{- else }} replicas: {{ .Values.replicaCount }} +{{- end }} template: metadata: labels: diff --git a/packs/typescript/charts/templates/hpa.yaml b/packs/typescript/charts/templates/hpa.yaml new file mode 100644 index 000000000..1c03eb4c9 --- /dev/null +++ b/packs/typescript/charts/templates/hpa.yaml @@ -0,0 +1,25 @@ +{{- if .Values.hpa.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + minReplicas: {{ .Values.hpa.minReplicas }} + maxReplicas: {{ .Values.hpa.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.hpa.cpuTargetAverageUtilization }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.hpa.memoryTargetAverageUtilization }} +{{- end }} \ No newline at end of file diff --git a/packs/typescript/charts/templates/service.yaml b/packs/typescript/charts/templates/service.yaml index 9321361e3..9a2a4c758 100644 --- a/packs/typescript/charts/templates/service.yaml +++ b/packs/typescript/charts/templates/service.yaml @@ -1,4 +1,4 @@ -{{- if .Values.knativeDeploy }} +{{- if or .Values.knativeDeploy .Values.canary.enabled }} {{- else }} apiVersion: v1 kind: Service diff --git a/packs/typescript/charts/values.yaml b/packs/typescript/charts/values.yaml index 3facb40ba..382479218 100644 --- a/packs/typescript/charts/values.yaml +++ b/packs/typescript/charts/values.yaml @@ -13,6 +13,36 @@ env: # enable this flag to use knative serve to deploy the app knativeDeploy: false +# HorizontalPodAutoscaler +hpa: + enabled: false + minReplicas: 2 + maxReplicas: 6 + cpuTargetAverageUtilization: 80 + memoryTargetAverageUtilization: 80 + +# Canary deployments +# If enabled, Istio and Flagger need to be installed in the cluster +canary: + enabled: false + progressDeadlineSeconds: 60 + canaryAnalysis: + interval: "1m" + threshold: 5 + maxWeight: 60 + stepWeight: 20 + # WARNING: Canary deployments will fail and rollback if there is no traffic that will generate the below specified metrics. + metrics: + requestSuccessRate: + threshold: 99 + interval: "1m" + requestDuration: + threshold: 1000 + interval: "1m" + # The host is using Istio Gateway and is currently not auto-generated + # Please overwrite the `canary.host` in `values.yaml` in each environment repository (e.g., staging, production) + host: acme.com + service: name: REPLACE_ME_APP_NAME type: ClusterIP