Skip to content

Commit 27fea14

Browse files
feat(cf-common): add sts template (#37)
1 parent bd80229 commit 27fea14

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+705
-295
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/quintush/helm-unittest/master/schema/helm-testsuite.json
2+
suite: sts error handlers
3+
templates:
4+
- templates/controller.yaml
5+
values:
6+
- values.yaml
7+
tests:
8+
- it: Test invalid controller strategy for sts
9+
values:
10+
- values.yaml
11+
set:
12+
controller:
13+
strategy: RollingStones
14+
asserts:
15+
- failedTemplate:
16+
errorMessage: "RollingStones is invalid controller strategy for Stateful Set!"
17+
18+
- it: Test invalid sts podManagementPolicy
19+
values:
20+
- values.yaml
21+
set:
22+
controller:
23+
podManagementPolicy: Sequential
24+
asserts:
25+
- failedTemplate:
26+
errorMessage: "Sequential is invalid Stateful Set podManagementPolicy!"
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/quintush/helm-unittest/master/schema/helm-testsuite.json
2+
suite: statefulset metadata
3+
templates:
4+
- templates/controller.yaml
5+
- templates/secret.yaml
6+
- templates/configmap.yaml
7+
tests:
8+
- it: Test statefulset default metadata
9+
template: templates/controller.yaml
10+
values:
11+
- values.yaml
12+
asserts:
13+
- hasDocuments:
14+
count: 1
15+
- isKind:
16+
of: StatefulSet
17+
- isNull:
18+
path: metadata.annotations
19+
- equal:
20+
path: metadata.labels
21+
value:
22+
app.kubernetes.io/instance: RELEASE-NAME
23+
app.kubernetes.io/managed-by: Helm
24+
app.kubernetes.io/name: cf-common-test
25+
helm.sh/chart: cf-common-test-0.0.0
26+
- equal:
27+
path: metadata.name
28+
value: RELEASE-NAME-cf-common-test
29+
30+
- it: Test statefulset custom metadata
31+
template: templates/controller.yaml
32+
values:
33+
- values.yaml
34+
set:
35+
controller:
36+
labels:
37+
alice: bob
38+
annotations:
39+
foo: bar
40+
asserts:
41+
- hasDocuments:
42+
count: 1
43+
- isKind:
44+
of: StatefulSet
45+
- equal:
46+
path: metadata.annotations
47+
value:
48+
foo: bar
49+
- equal:
50+
path: metadata.labels
51+
value:
52+
app.kubernetes.io/instance: RELEASE-NAME
53+
app.kubernetes.io/managed-by: Helm
54+
app.kubernetes.io/name: cf-common-test
55+
helm.sh/chart: cf-common-test-0.0.0
56+
alice: bob
57+
58+
- it: Test pod labels and annotations
59+
template: templates/controller.yaml
60+
values:
61+
- values.yaml
62+
set:
63+
podLabels:
64+
alice: bob
65+
podAnnotations:
66+
foo: bar
67+
asserts:
68+
- equal:
69+
path: spec.template.metadata.labels.alice
70+
value: bob
71+
- equal:
72+
path: spec.template.metadata.annotations.foo
73+
value: bar
74+
75+
- it: Test checksum/config annotation
76+
values:
77+
- values.yaml
78+
set:
79+
podAnnotations:
80+
checksum/config: '{{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}'
81+
configMaps:
82+
config:
83+
enabled: true
84+
data:
85+
alice: bob
86+
asserts:
87+
- equal:
88+
path: spec.template.metadata.annotations
89+
value:
90+
checksum/config: de9d09f672fb2a4162f23792f202d4b078206a32d322d2b999fd822939397cb6
91+
template: templates/controller.yaml
92+
93+
- it: Test checksum/secret annotation
94+
values:
95+
- values.yaml
96+
set:
97+
podAnnotations:
98+
checksum/secret: '{{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}'
99+
secrets:
100+
secret:
101+
enabled: true
102+
stringData:
103+
alice: bob
104+
asserts:
105+
- equal:
106+
path: spec.template.metadata.annotations
107+
value:
108+
checksum/secret: 22b7034621e9d062b0ca2a2d181ccaa21b537b480769384488b2e2b8d71e1cad
109+
template: templates/controller.yaml
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/quintush/helm-unittest/master/schema/helm-testsuite.json
2+
suite: sts spec
3+
templates:
4+
- templates/controller.yaml
5+
values:
6+
- values.yaml
7+
tests:
8+
- it: Test sts matchLabels
9+
asserts:
10+
- isNotEmpty:
11+
path: spec.selector.matchLabels
12+
- equal:
13+
path: spec.selector.matchLabels
14+
value:
15+
app.kubernetes.io/instance: RELEASE-NAME
16+
app.kubernetes.io/name: cf-common-test
17+
18+
- it: Test sts updateStrategy
19+
asserts:
20+
- equal:
21+
path: spec.updateStrategy.type
22+
value: RollingUpdate
23+
24+
- it: Test sts updateStrategy override
25+
values:
26+
- values.yaml
27+
set:
28+
controller:
29+
strategy: OnDelete
30+
asserts:
31+
- equal:
32+
path: spec.updateStrategy.type
33+
value: OnDelete
34+
35+
- it: Test sts replica number
36+
asserts:
37+
- equal:
38+
path: spec.replicas
39+
value: 2
40+
41+
- it: Test sts revisionHistoryLimit
42+
asserts:
43+
- equal:
44+
path: spec.revisionHistoryLimit
45+
value: 5
46+
47+
- it: Test sts serviceName
48+
asserts:
49+
- equal:
50+
path: spec.serviceName
51+
value: RELEASE-NAME-cf-common-test
52+
53+
- it: Test sts serviceName
54+
asserts:
55+
- equal:
56+
path: spec.serviceName
57+
value: RELEASE-NAME-cf-common-test
58+
59+
- it: Test sts podManagementPolicy
60+
asserts:
61+
- equal:
62+
path: spec.podManagementPolicy
63+
value: OrderedReady
64+
65+
- it: Test sts podManagementPolicy override
66+
values:
67+
- values.yaml
68+
set:
69+
controller:
70+
podManagementPolicy: Parallel
71+
asserts:
72+
- equal:
73+
path: spec.podManagementPolicy
74+
value: Parallel
75+
76+
- it: Test sts volumeClaimTemplates
77+
asserts:
78+
- isNotEmpty:
79+
path: spec.volumeClaimTemplates
80+
- contains:
81+
path: spec.volumeClaimTemplates
82+
content:
83+
metadata:
84+
name: data
85+
spec:
86+
accessModes:
87+
- "ReadWriteOnce"
88+
resources:
89+
requests:
90+
storage: "100Mi"
91+
92+
- it: Test sts volumeClaimTemplates overrides
93+
values:
94+
- values.yaml
95+
set:
96+
volumeClaimTemplates:
97+
data:
98+
labels:
99+
alice: bob
100+
annotations:
101+
foo: bar
102+
mountPath: /data
103+
subPath: subpath
104+
accessMode: "ReadWriteOnce"
105+
size: 200Mi
106+
storageClass: hostpath
107+
asserts:
108+
- isNotEmpty:
109+
path: spec.volumeClaimTemplates
110+
- contains:
111+
path: spec.volumeClaimTemplates
112+
content:
113+
metadata:
114+
name: data
115+
labels:
116+
alice: bob
117+
annotations:
118+
foo: bar
119+
spec:
120+
accessModes:
121+
- "ReadWriteOnce"
122+
resources:
123+
requests:
124+
storage: "200Mi"
125+
storageClassName: hostpath
126+
- contains:
127+
path: spec.template.spec.containers[0].volumeMounts
128+
content:
129+
name: data
130+
mountPath: /data
131+
subPath: subpath
132+
133+
- it: Test sts volumeClaimTemplates disabled
134+
values:
135+
- values.yaml
136+
set:
137+
volumeClaimTemplates:
138+
data:
139+
enabled: false
140+
asserts:
141+
- isEmpty:
142+
path: spec.volumeClaimTemplates
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# mock values for tests
2+
global: {}
3+
4+
controller:
5+
enabled: true
6+
type: statefulset
7+
labels: {}
8+
annotations: {}
9+
replicas: 2
10+
11+
container:
12+
image:
13+
registry: docker.io
14+
repository: bitnami/nginx
15+
tag: latest
16+
pullPolicy: Always
17+
18+
command: []
19+
args: []
20+
21+
env:
22+
ALICE: BOB
23+
24+
volumeClaimTemplates:
25+
data:
26+
labels: {}
27+
annotations: {}
28+
mountPath: /data
29+
accessMode: "ReadWriteOnce"
30+
size: 100Mi
31+
storageClass:
32+
33+
service:
34+
main:
35+
enabled: true
36+
type: ClusterIP
37+
ports:
38+
http:
39+
port: 80
40+
targetPort: 8080

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.6.0
5+
version: 0.7.0
66
type: library
77
keywords:
88
- codefresh

charts/cf-common/README.md

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

33
Codefresh library chart
44

5-
![Version: 0.6.0](https://img.shields.io/badge/Version-0.6.0-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.7.0](https://img.shields.io/badge/Version-0.7.0-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.6.0
21+
version: 0.7.0
2222
repository: https://chartmuseum.codefresh.io/cf-common
2323
```
2424
@@ -70,9 +70,6 @@ dependencies:
7070
| controller.cronjob.successfulJobsHistory | int | `1` | The number of succesful Jobs to keep |
7171
| controller.cronjob.suspend | string | `nil` | This flag tells the controller to suspend subsequent executions, it does not apply to already started executions. Defaults to false. |
7272
| controller.cronjob.ttlSecondsAfterFinished | string | `nil` | If this field is set, ttlSecondsAfterFinished after the Job finishes, it is eligible to be automatically deleted. |
73-
| controller.deployment.rollingUpdate.maxSurge | string | `nil` | Set RollingUpdate max surge (absolute number or percentage) |
74-
| controller.deployment.rollingUpdate.maxUnavailable | string | `nil` | Set RollingUpdate max unavailable (absolute number or percentage) |
75-
| controller.deployment.strategy | string | `nil` | Set deployment upgrade strategy (`RollingUpdate`/`Recreate`) |
7673
| controller.job.activeDeadlineSeconds | string | `nil` | Set the duration in seconds relative to the startTime that the job may be continuously active before the system tries to terminate it; value must be positive integer. (int) |
7774
| controller.job.backoffLimit | string | `nil` | Set the number of retries before marking this job failed. Defaults to 6. (int) |
7875
| controller.job.completions | string | `nil` | Set the desired number of successfully finished pods the job should be run with. (int) |
@@ -83,8 +80,13 @@ dependencies:
8380
| controller.job.ttlSecondsAfterFinished | string | `nil` | Set the limit on the lifetime of a Job that has finished execution (either Complete or Failed). (int) |
8481
| controller.labels | object | `{}` | Set labels on controller |
8582
| controller.nameOverride | string | `""` | Override the name suffix that is used for this controller |
83+
| controller.podManagementPolicy | string | `nil` | Set statefulset podManagementPolicy (`OrderedReady`(default)/`Parallel`). |
8684
| controller.replicas | string | `nil` | Set number of pods |
8785
| controller.revisionHistoryLimit | string | `nil` | Set ReplicaSet revision history limit |
86+
| controller.rollingUpdate | object | `{"maxSurge":null,"maxUnavailable":null,"partition":null}` | RollingUpdate strategy parameters |
87+
| controller.rollingUpdate.maxSurge | Deployment | `nil` | Set RollingUpdate max surge (absolute number or percentage) |
88+
| controller.rollingUpdate.maxUnavailable | Deployment | `nil` | Set RollingUpdate max unavailable (absolute number or percentage) |
89+
| controller.rollingUpdate.partition | StatefulSet | `nil` | Set RollingUpdate partition |
8890
| controller.rollout.analysis.successfulRunHistoryLimit | string | `nil` | Limits the number of successful analysis runs and experiments to be stored in a history |
8991
| controller.rollout.analysis.unsuccessfulRunHistoryLimit | string | `nil` | Limits the number of unsuccessful analysis runs and experiments to be stored in a history. ( Stages for unsuccessful: "Error", "Failed", "Inconclusive" ) |
9092
| controller.rollout.canary | object | `{"maxSurge":null,"maxUnavailable":null,"steps":[{"setWeight":null},{"pause":{"duration":null}},{"setWeight":null},{"pause":{"duration":null}}]}` | Canary update strategy parameters |
@@ -94,13 +96,10 @@ dependencies:
9496
| controller.rollout.canary.steps[0] | object | `{"setWeight":null}` | Sets the ratio of canary ReplicaSet in percentage. |
9597
| controller.rollout.canary.steps[1] | object | `{"pause":{"duration":null}}` | Pauses the rollout for configured duration of time. Supported units: s, m, h. when setting `duration: {}` it will pauses indefinitely until manually resumed |
9698
| controller.rollout.strategy | string | `nil` | Rollout update strategy - can be Canary or BlueGreen. |
99+
| controller.strategy | string | `nil` | Set controller upgrade strategy For Deployment: `RollingUpdate`(default) / `Recreate` For StatefulSet: `RollingUpdate`(default) / `OnDelete` |
97100
| controller.type | string | `""` | Define the controller type (`deployment`/`rollout`/`job`/`cronjob`) |
98101
| extraResources | list | `[]` | Array of extra objects to deploy with the release |
99-
| 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 |
100-
| global.controller.deployment.rollingUpdate.maxSurge | string | `nil` | Set RollingUpdate max surge (absolute number or percentage) |
101-
| global.controller.deployment.rollingUpdate.maxUnavailable | string | `nil` | Set RollingUpdate max unavailable (absolute number or percentage) |
102-
| global.controller.deployment.strategy | string | `nil` | Set deployment upgrade strategy (`RollingUpdate`/`Recreate`) |
103-
| global.controller.type | string | `""` | Define the controller type (`deployment` \ `rollout`) |
102+
| global | object | `{"controller":{},"env":{},"imagePullSecrets":[],"imageRegistry":""}` | Global parameters |
104103
| global.env | object | `{}` | Global Env vars. NO precedence over `.Values.container.env` |
105104
| global.imagePullSecrets | list | `[]` | Global Docker registry secret names as array |
106105
| global.imageRegistry | string | `""` | Global Docker image registry |
@@ -169,6 +168,7 @@ dependencies:
169168
| terminationGracePeriodSeconds | string | `nil` | Duration in seconds the pod needs to terminate gracefully |
170169
| tolerations | list | `[]` | Set tolerations constrains |
171170
| topologySpreadConstraints | list | `[]` | Set topologySpreadConstraints rules. Helm template supported. Passed through `tpl`, should be configured as string |
171+
| volumeClaimTemplates | object | `{}` | Used with `controller.type: statefulset` to create individual disks for each instance. |
172172
| volumes | object | See below | Configure volume for the controller. Additional items can be added by adding a dictionary key similar to the 'config'/`secret` key. |
173173
| volumes.config | object | `{"enabled":false,"type":"configMap"}` | Volume name. Make sure to use the same name in `configMaps`/`secrets`/`persistence` and `container.volumeMounts` |
174174
| volumes.config.enabled | bool | `false` | Enable the volume |

0 commit comments

Comments
 (0)