Skip to content

Commit 55c9150

Browse files
authored
feat(cf-common): add AnalysisTemplate template (#21)
* feat(cf-common): add AnalysisTemplate template * feat(cf-common): add AnalysisTemplate template * feat(cf-common): add AnalysisTemplate template * feat(cf-common): add AnalysisTemplate template * feat(cf-common): add AnalysisTemplate template
1 parent 11618d8 commit 55c9150

File tree

6 files changed

+87
-13
lines changed

6 files changed

+87
-13
lines changed

charts/cf-common/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
appVersion: v0.0.0
33
description: Codefresh library chart
44
name: cf-common
5-
version: 0.0.19
5+
version: 0.0.20
66
type: library
77
keywords:
88
- codefresh

charts/cf-common/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Codefresh library chart
44

5-
![Version: 0.0.19](https://img.shields.io/badge/Version-0.0.19-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) ![AppVersion: v0.0.0](https://img.shields.io/badge/AppVersion-v0.0.0-informational?style=flat-square)
5+
![Version: 0.0.20](https://img.shields.io/badge/Version-0.0.20-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) ![AppVersion: v0.0.0](https://img.shields.io/badge/AppVersion-v0.0.0-informational?style=flat-square)
66

77
## Installing the Chart
88

@@ -18,7 +18,7 @@ Include this chart as a dependency in your `Chart.yaml` e.g.
1818
# Chart.yaml
1919
dependencies:
2020
- name: cf-common
21-
version: 0.0.19
21+
version: 0.0.20
2222
repository: https://chartmuseum.codefresh.io/cf-common
2323
```
2424
@@ -88,7 +88,7 @@ dependencies:
8888
| controller.rollout.strategy | string | `nil` | Rollout update strategy - can be Canary or BlueGreen. |
8989
| controller.type | string | `""` | Define the controller type (`deployment`/`rollout`/`job`) |
9090
| extraResources | list | `[]` | Array of extra objects to deploy with the release |
91-
| global | object | `{"controller":{"deployment":{"rollingUpdate":{"maxSurge":null,"maxUnavailable":null},"strategy":null},"rollout":{"analysis":{"successfulRunHistoryLimit":null,"unsuccessfulRunHistoryLimit":null},"canary":{"maxSurge":null,"maxUnavailable":null,"steps":[{"setWeight":null},{"pause":{"duration":null}},{"setWeight":null},{"pause":{"duration":null}}]},"strategy":null},"type":""},"env":{},"imagePullSecrets":[],"imageRegistry":""}` | Global parameters |
91+
| global | object | `{"controller":{"deployment":{"rollingUpdate":{"maxSurge":null,"maxUnavailable":null},"strategy":null},"rollout":{"analysis":{"successfulRunHistoryLimit":null,"unsuccessfulRunHistoryLimit":null},"analysisTemplate":{"args":null,"enabled":null,"metrics":[{"failureCondition":null,"failureLimit":null,"name":null,"provider":{"newRelic":{"profile":null,"query":null}},"successCondition":null}]},"canary":{"maxSurge":null,"maxUnavailable":null,"steps":[{"setWeight":null},{"pause":{"duration":null}},{"setWeight":null},{"pause":{"duration":null}}]},"strategy":null},"type":""},"env":{},"imagePullSecrets":[],"imageRegistry":""}` | Global parameters |
9292
| global.controller.deployment.rollingUpdate.maxSurge | string | `nil` | Set RollingUpdate max surge (absolute number or percentage) |
9393
| global.controller.deployment.rollingUpdate.maxUnavailable | string | `nil` | Set RollingUpdate max unavailable (absolute number or percentage) |
9494
| global.controller.deployment.strategy | string | `nil` | Set deployment upgrade strategy (`RollingUpdate`/`Recreate`) |
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{{- define "cf-common.controller.analysis-template" -}}
2+
3+
{{- $fullName:= include "cf-common.names.fullname" . }}
4+
5+
---
6+
apiVersion: argoproj.io/v1alpha1
7+
kind: AnalysisTemplate
8+
metadata:
9+
name: error-rate-{{ $fullName }}
10+
spec:
11+
{{- with .Values.controller.rollout.analysisTemplate }}
12+
args: {{- include "cf-common.tplrender" (dict "Values" .args "context" $) | nindent 4 }}
13+
metrics: {{- .metrics | toYaml | nindent 4 }}
14+
{{- end }}
15+
16+
{{- end }}

charts/cf-common/templates/controller/_controller.tpl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ Usage:
1212

1313
{{- if eq .Values.controller.type "rollout" }}
1414
{{ include "cf-common.controller.rollout" . | nindent 0 }}
15+
{{- if .Values.controller.rollout.analysisTemplate.enabled }}
16+
{{ include "cf-common.controller.analysis-template" . | nindent 0 }}
17+
{{- end }}
1518
{{- else if eq .Values.controller.type "deployment" }}
1619
{{ include "cf-common.controller.deployment" . | nindent 0 }}
1720
{{- else if eq .Values.controller.type "job" }}
@@ -40,4 +43,4 @@ Usage:
4043
{{- end -}}
4144
{{- $_ := set .Values "controller" $controllerDict -}}
4245

43-
{{- end }}
46+
{{- end }}

charts/cf-common/templates/controller/_rollout.tpl

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,19 @@ spec:
3737
{{- end }}
3838
strategy:
3939
{{- if eq $strategy "Canary" }}
40-
{{- with .Values.controller.rollout.canary }}
41-
canary:
42-
maxUnavailable: {{ .maxUnavailable }}
43-
maxSurge: {{ .maxSurge }}
44-
stableMetadata: {{ .stableMetadata| toYaml | nindent 8 }}
45-
canaryMetadata: {{ .canaryMetadata| toYaml | nindent 8 }}
46-
steps: {{ .steps | toYaml | nindent 6 }}
47-
{{- end}}
40+
{{- with .Values.controller.rollout }}
41+
canary:
42+
maxUnavailable: {{ .canary.maxUnavailable }}
43+
maxSurge: {{ .canary.maxSurge }}
44+
stableMetadata: {{ .canary.stableMetadata| toYaml | nindent 8 }}
45+
canaryMetadata: {{ .canary.canaryMetadata| toYaml | nindent 8 }}
46+
steps: {{ .canary.steps | toYaml | nindent 6 }}
47+
{{- if .analysisTemplate.enabled }}
48+
- analysis:
49+
templates:
50+
- templateName: error-rate-{{ $fullName }}
51+
{{- end }}
52+
{{- end }}
4853
{{- end }}
4954
template:
5055
metadata:

charts/cf-common/values.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,31 @@ global:
2323
maxSurge:
2424
# Global Rollout parameters
2525
rollout:
26+
# Analysis template parameters to run in the background during a rollout update.
27+
analysisTemplate:
28+
# Enable analysis template
29+
enabled:
30+
# Array of arguments to pass
31+
args:
32+
# The metrics which the analysis should perform
33+
metrics:
34+
# The name of the metric
35+
- name:
36+
# The maximum number of failed run an analysis is allowed.
37+
failureLimit:
38+
# Determines if a measurement is considered failed
39+
failureCondition:
40+
# Determines if a measurement is considered successful
41+
successCondition:
42+
# The external metrics system to use to verify the analysis
43+
provider:
44+
# Defines NewRelic as the external metrics system
45+
newRelic:
46+
# The name of the secret holding NewRelic account configuration
47+
profile:
48+
# A raw NewRelic NRQL query to perform
49+
query:
50+
# Analysis history configuration
2651
analysis:
2752
# Limits the number of successful analysis runs and experiments to be stored in a history
2853
successfulRunHistoryLimit:
@@ -74,6 +99,31 @@ controller:
7499
maxSurge:
75100
# Rollout parameters (overrides for global.rollout values)
76101
rollout:
102+
# Analysis template parameters to run in the background during a rollout update.
103+
analysisTemplate:
104+
# Enable analysis template
105+
enabled:
106+
# Array of arguments to pass
107+
args:
108+
# The metrics which the analysis should perform
109+
metrics:
110+
# The name of the metric
111+
- name:
112+
# The maximum number of failed run an analysis is allowed.
113+
failureLimit:
114+
# Determines if a measurement is considered failed
115+
failureCondition:
116+
# Determines if a measurement is considered successful
117+
successCondition:
118+
# The external metrics system to use to verify the analysis
119+
provider:
120+
# Defines NewRelic as the external metrics system
121+
newRelic:
122+
# The name of the secret holding NewRelic account configuration
123+
profile:
124+
# A raw NewRelic NRQL query to perform
125+
query:
126+
# Analysis history configuration
77127
analysis:
78128
# -- Limits the number of successful analysis runs and experiments to be stored in a history
79129
successfulRunHistoryLimit:

0 commit comments

Comments
 (0)