Skip to content

Commit e392cf4

Browse files
authored
fix(cf-common): controller and rollout global values (#14)
* fix(cf-common): controller and rollout global values * fix(cf-common): controller and rollout global values * fix(cf-common): controller and rollout global values * fix(cf-common): controller and rollout global values * fix(cf-common): controller and rollout global values * fix(cf-common): controller and rollout global values * fix(cf-common): controller and rollout global values * fix(cf-common): controller and rollout global values * fix(cf-common): controller and rollout global values * fix(cf-common): controller and rollout global values * fix(cf-common): controller and rollout global values
1 parent 04042da commit e392cf4

File tree

5 files changed

+72
-46
lines changed

5 files changed

+72
-46
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.13
5+
version: 0.0.14
66
type: library
77
keywords:
88
- codefresh

charts/cf-common/README.md

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

33
Codefresh library chart
44

5-
![Version: 0.0.13](https://img.shields.io/badge/Version-0.0.13-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.14](https://img.shields.io/badge/Version-0.0.14-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.13
21+
version: 0.0.14
2222
repository: https://chartmuseum.codefresh.io/cf-common
2323
```
2424
@@ -69,9 +69,13 @@ dependencies:
6969
| controller.labels | object | `{}` | Set labels on controller |
7070
| controller.replicas | string | `nil` | Set number of pods |
7171
| controller.revisionHistoryLimit | string | `nil` | Set ReplicaSet revision history limit |
72-
| controller.type | string | `nil` | Define the controller type (`deployment`) |
72+
| controller.type | string | `""` | Define the controller type (`deployment` \ `rollout`) |
7373
| extraResources | list | `[]` | Array of extra objects to deploy with the release |
74-
| global | object | `{"env":{},"imagePullSecrets":[],"imageRegistry":"","rollout":{"analysis":{"successfulRunHistoryLimit":null,"unsuccessfulRunHistoryLimit":null},"canary":{"maxSurge":null,"maxUnavailable":null,"steps":[{"setWeight":null},{"pause":{"duration":null}},{"setWeight":null},{"pause":{"duration":null}}]},"strategy":null}}` | Global parameters |
74+
| 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 |
75+
| global.controller.deployment.rollingUpdate.maxSurge | string | `nil` | Set RollingUpdate max surge (absolute number or percentage) |
76+
| global.controller.deployment.rollingUpdate.maxUnavailable | string | `nil` | Set RollingUpdate max unavailable (absolute number or percentage) |
77+
| global.controller.deployment.strategy | string | `nil` | Set deployment upgrade strategy (`RollingUpdate`/`Recreate`) |
78+
| global.controller.type | string | `""` | Define the controller type (`deployment` \ `rollout`) |
7579
| global.env | object | `{}` | Global Env vars. NO precedence over `.Values.container.env` |
7680
| global.imagePullSecrets | list | `[]` | Global Docker registry secret names as array |
7781
| global.imageRegistry | string | `""` | Global Docker image registry |

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,22 @@ Usage:
88
{{- define "cf-common.controller" -}}
99

1010
{{- if .Values.controller.enabled -}}
11-
{{- if eq .Values.controller.type "deployment" }}
12-
{{ include "cf-common.controller.deployment" . | nindent 0 }}
13-
{{- else if eq .Values.controller.type "rollout" }}
11+
12+
{{- $controllerDict := .Values.controller -}}
13+
{{- if .Values.global -}}
14+
{{- if .Values.global.controller -}}
15+
{{- $controllerDict = merge $controllerDict .Values.global.controller -}}
16+
{{- end -}}
17+
{{- end -}}
18+
{{- $_ := set .Values "controller" $controllerDict -}}
19+
20+
{{- if eq $controllerDict.type "rollout" }}
1421
{{ include "cf-common.controller.rollout" . | nindent 0 }}
22+
{{- else if eq $controllerDict.type "deployment" }}
23+
{{ include "cf-common.controller.deployment" . | nindent 0 }}
1524
{{- else }}
1625
{{ fail (printf "ERROR: %s is invalid controller type!" .Values.controller.type) }}
1726
{{- end }}
1827
{{- end -}}
1928

20-
2129
{{- end -}}

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Usage:
55
*/}}
66
{{- define "cf-common.controller.rollout" -}}
77

8-
{{- $strategy := default .Values.global.rollout.strategy .Values.controller.rollout.strategy -}}
8+
{{- $strategy := .Values.controller.rollout.strategy -}}
99
{{- $fullName:= include "cf-common.names.fullname" . }}
1010

1111
{{- if and (ne $strategy "Canary") (ne $strategy "BlueGreen") -}}
@@ -33,17 +33,17 @@ spec:
3333
selector:
3434
matchLabels: {{ include "cf-common.labels.matchLabels" . | nindent 6 }}
3535
{{- with .Values.controller.rollout }}
36-
analysis: {{ default $.Values.global.rollout.analysis .analysis | toYaml | nindent 4 }}
36+
analysis: {{ .analysis | toYaml | nindent 4 }}
3737
{{- end }}
3838
strategy:
3939
{{- if eq $strategy "Canary" }}
4040
{{- with .Values.controller.rollout.canary }}
4141
canary:
42-
maxUnavailable: {{ default $.Values.global.rollout.canary.maxUnavailable .maxUnavailable }}
43-
maxSurge: {{ default $.Values.global.rollout.canary.maxSurge .maxSurge }}
44-
stableMetadata: {{ default $.Values.global.rollout.canary.stableMetadata .stableMetadata| toYaml | nindent 8 }}
45-
canaryMetadata: {{ default $.Values.global.rollout.canary.canaryMetadata .canaryMetadata| toYaml | nindent 8 }}
46-
steps: {{ default $.Values.global.rollout.canary.steps .steps | toYaml | nindent 6 }}
42+
maxUnavailable: {{ .maxUnavailable }}
43+
maxSurge: {{ .maxSurge }}
44+
stableMetadata: {{ .stableMetadata| toYaml | nindent 8 }}
45+
canaryMetadata: {{ .canaryMetadata| toYaml | nindent 8 }}
46+
steps: {{ .steps | toYaml | nindent 6 }}
4747
{{- end}}
4848
{{- end }}
4949
template:
@@ -52,9 +52,9 @@ spec:
5252
{{- if .Values.podLabels }}
5353
{{- include "cf-common.tplrender" (dict "Values" .Values.podLabels "context" $) | nindent 8 }}
5454
{{- end }}
55-
{{- if .Values.podAnnotations }}
55+
{{- with include "cf-common.annotations.podAnnotations" . }}
5656
annotations:
57-
{{- include "cf-common.tplrender" (dict "Values" .Values.podAnnotations "context" $) | nindent 8 }}
57+
{{- . | nindent 8}}
5858
{{- end }}
5959
spec: {{- include "cf-common.controller.pod" . | trim | nindent 6 -}}
6060
{{- end -}}

charts/cf-common/values.yaml

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,39 +7,53 @@ global:
77
# E.g.
88
# imagePullSecrets:
99
# - myRegistrySecret
10-
# Global Rollout parameters
11-
rollout:
12-
analysis:
13-
# Limits the number of successful analysis runs and experiments to be stored in a history
14-
successfulRunHistoryLimit:
15-
# Limits the number of unsuccessful analysis runs and experiments to be stored in a history. ( Stages for unsuccessful: "Error", "Failed", "Inconclusive" )
16-
unsuccessfulRunHistoryLimit:
17-
# Rollout update strategy - can be Canary or BlueGreen.
18-
strategy:
19-
# Canary update strategy parameters
20-
canary:
21-
# The maximum number of pods that can be unavailable during the update. Value can be an absolute number / percentage
22-
maxUnavailable:
23-
# The maximum number of pods that can be scheduled above the original number of pods. Value can be an absolute number / percentage
24-
maxSurge:
25-
# Steps define sequence of steps to take during an update of the canary.
26-
steps:
27-
# Sets the ratio of canary ReplicaSet in percentage.
28-
- setWeight:
29-
# Pauses the rollout for configured duration of time. Supported units: s, m, h. when setting `duration: {}` it will pauses indefinitely until manually resumed
30-
- pause:
31-
duration:
32-
- setWeight:
33-
- pause:
34-
duration:
10+
# Global controller parameters
11+
controller:
12+
# -- Define the controller type (`deployment` \ `rollout`)
13+
type: ""
14+
# Deployment parameters (overrides for global.deployment values)
15+
deployment:
16+
# -- Set deployment upgrade strategy (`RollingUpdate`/`Recreate`)
17+
strategy:
18+
# RollingUpdate strategy parameters
19+
rollingUpdate:
20+
# -- Set RollingUpdate max unavailable (absolute number or percentage)
21+
maxUnavailable:
22+
# -- Set RollingUpdate max surge (absolute number or percentage)
23+
maxSurge:
24+
# Global Rollout parameters
25+
rollout:
26+
analysis:
27+
# Limits the number of successful analysis runs and experiments to be stored in a history
28+
successfulRunHistoryLimit:
29+
# Limits the number of unsuccessful analysis runs and experiments to be stored in a history. ( Stages for unsuccessful: "Error", "Failed", "Inconclusive" )
30+
unsuccessfulRunHistoryLimit:
31+
# Rollout update strategy - can be Canary or BlueGreen.
32+
strategy:
33+
# Canary update strategy parameters
34+
canary:
35+
# The maximum number of pods that can be unavailable during the update. Value can be an absolute number / percentage
36+
maxUnavailable:
37+
# The maximum number of pods that can be scheduled above the original number of pods. Value can be an absolute number / percentage
38+
maxSurge:
39+
# Steps define sequence of steps to take during an update of the canary.
40+
steps:
41+
# Sets the ratio of canary ReplicaSet in percentage.
42+
- setWeight:
43+
# Pauses the rollout for configured duration of time. Supported units: s, m, h. when setting `duration: {}` it will pauses indefinitely until manually resumed
44+
- pause:
45+
duration:
46+
- setWeight:
47+
- pause:
48+
duration:
3549
# -- Global Env vars. NO precedence over `.Values.container.env`
3650
env: {}
3751

3852
# -- Controller parameters
3953
# @default -- See below
4054
controller:
41-
# -- Define the controller type (`deployment`)
42-
type:
55+
# -- Define the controller type (`deployment` \ `rollout`)
56+
type: ""
4357
# -- Set labels on controller
4458
labels: {}
4559
# -- Set annotations on controller
@@ -48,7 +62,7 @@ controller:
4862
replicas:
4963
# -- Set ReplicaSet revision history limit
5064
revisionHistoryLimit:
51-
# Deployment parameters
65+
# Deployment parameters (overrides for global.deployment values)
5266
deployment:
5367
# -- Set deployment upgrade strategy (`RollingUpdate`/`Recreate`)
5468
strategy:

0 commit comments

Comments
 (0)