Skip to content

Commit dd90ea5

Browse files
feat(cf-common): templates for KEDA (#82)
1 parent dc067d0 commit dd90ea5

Some content is hidden

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

53 files changed

+707
-295
lines changed

charts/cf-common-test/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ Codefresh library chart - test chart - not for deployment!
3333
| hpa | object | `{}` | |
3434
| ingress | object | `{}` | |
3535
| initContainers | object | `{}` | |
36+
| keda.auth | object | `{}` | |
37+
| keda.spec | object | `{}` | |
3638
| nodeSelector | object | `{}` | |
3739
| pdb | object | `{}` | |
3840
| podSecurityContext | object | `{}` | |
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{{ $templateName := printf "cf-common-%s.keda.scaled-object" (index .Subcharts "cf-common").Chart.Version }}
2+
{{- include $templateName . -}}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{{ $templateName := printf "cf-common-%s.keda.trigger-authentication" (index .Subcharts "cf-common").Chart.Version }}
2+
{{- include $templateName . -}}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/quintush/helm-unittest/master/schema/helm-testsuite.json
2+
suite: KEDA ScaledObject error handlers
3+
templates:
4+
- templates/scaled-object.yaml
5+
tests:
6+
- it: Test ScaledObject zero idleReplicaCount
7+
values:
8+
- values.yaml
9+
set:
10+
keda:
11+
spec:
12+
idleReplicaCount: 1
13+
asserts:
14+
- equal:
15+
path: spec.idleReplicaCount
16+
value: 0
17+
18+
- it: Test ScaledObject fallback
19+
values:
20+
- values.yaml
21+
set:
22+
keda:
23+
spec:
24+
fallback:
25+
failureThreshold: null
26+
replicas: 6
27+
asserts:
28+
- failedTemplate:
29+
errorMessage: "Values.keda.spec.fallback.failureThreshold is required!"
30+
31+
- it: Test ScaledObject fallback
32+
values:
33+
- values.yaml
34+
set:
35+
keda:
36+
spec:
37+
fallback:
38+
failureThreshold: 3
39+
replicas: null
40+
asserts:
41+
- failedTemplate:
42+
errorMessage: "Values.keda.spec.fallback.replicas is required!"
43+
44+
- it: Test both ScaledObject and HPA enabled
45+
values:
46+
- values.yaml
47+
set:
48+
hpa:
49+
enabled: true
50+
keda:
51+
spec:
52+
enabled: true
53+
asserts:
54+
- failedTemplate:
55+
errorMessage: "Both KEDA ScaledObject and HPA are enabled. Disable HPA or Keda ScaledObject!"
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/quintush/helm-unittest/master/schema/helm-testsuite.json
2+
suite: KEDA ScaledObject metadata
3+
templates:
4+
- templates/scaled-object.yaml
5+
tests:
6+
- it: Test default KEDA ScaledObject metadata
7+
values:
8+
- values.yaml
9+
asserts:
10+
- hasDocuments:
11+
count: 1
12+
- isKind:
13+
of: ScaledObject
14+
- equal:
15+
path: metadata.labels
16+
value:
17+
app.kubernetes.io/instance: RELEASE-NAME
18+
app.kubernetes.io/managed-by: Helm
19+
app.kubernetes.io/name: cf-common-test
20+
helm.sh/chart: cf-common-test-0.0.0
21+
- equal:
22+
path: metadata.name
23+
value: RELEASE-NAME-cf-common-test
24+
25+
- it: Test KEDA ScaledObject annotations
26+
values:
27+
- values.yaml
28+
asserts:
29+
- hasDocuments:
30+
count: 1
31+
- equal:
32+
path: metadata.annotations
33+
value:
34+
autoscaling.keda.sh/paused: "true"
35+
36+
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/quintush/helm-unittest/master/schema/helm-testsuite.json
2+
suite: KEDA ScaledObject spec
3+
templates:
4+
- templates/scaled-object.yaml
5+
tests:
6+
- it: Test ScaledObject default spec
7+
values:
8+
- values.yaml
9+
asserts:
10+
- isNotEmpty:
11+
path: spec.scaleTargetRef
12+
- equal:
13+
path: spec.scaleTargetRef.kind
14+
value: Deployment
15+
- equal:
16+
path: spec.scaleTargetRef.name
17+
value: RELEASE-NAME-cf-common-test
18+
- equal:
19+
path: spec.scaleTargetRef.envSourceContainerName
20+
value: RELEASE-NAME-cf-common-test
21+
22+
- it: Test ScaledObject min/max/idle replicas
23+
values:
24+
- values.yaml
25+
set:
26+
keda:
27+
spec:
28+
minReplicaCount: 2
29+
maxReplicaCount: 10
30+
asserts:
31+
- equal:
32+
path: spec.minReplicaCount
33+
value: 2
34+
- equal:
35+
path: spec.maxReplicaCount
36+
value: 10
37+
- isNull:
38+
path: spec.idleReplicaCount
39+
40+
- it: Test ScaledObject pollingInterval/cooldownPeriod
41+
values:
42+
- values.yaml
43+
set:
44+
keda:
45+
spec:
46+
pollingInterval: 60
47+
cooldownPeriod: 600
48+
asserts:
49+
- equal:
50+
path: spec.pollingInterval
51+
value: 60
52+
- equal:
53+
path: spec.cooldownPeriod
54+
value: 600
55+
56+
- it: Test ScaledObject triggers
57+
values:
58+
- values.yaml
59+
asserts:
60+
- contains:
61+
path: spec.triggers
62+
content:
63+
type: cpu
64+
metadata:
65+
type: Utilization
66+
value: "70"
67+
68+
- it: Test ScaledObject envSourceContainerName
69+
values:
70+
- values.yaml
71+
set:
72+
keda:
73+
spec:
74+
scaleTargetRef:
75+
apiVersion: argoproj.io/v1alpha1
76+
kind: Rollout
77+
name: my-rollout
78+
envSourceContainerName: my-container
79+
asserts:
80+
- equal:
81+
path: spec.scaleTargetRef
82+
value:
83+
apiVersion: argoproj.io/v1alpha1
84+
kind: Rollout
85+
name: my-rollout
86+
envSourceContainerName: my-container
87+
88+
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/quintush/helm-unittest/master/schema/helm-testsuite.json
2+
suite: KEDA TriggerAuthentication spec
3+
templates:
4+
- templates/trigger-authentication.yaml
5+
tests:
6+
- it: Test TriggerAuthentication metadata
7+
values:
8+
- values.yaml
9+
set:
10+
keda:
11+
auth:
12+
enabled: true
13+
asserts:
14+
- hasDocuments:
15+
count: 1
16+
- isKind:
17+
of: TriggerAuthentication
18+
- equal:
19+
path: metadata.labels
20+
value:
21+
app.kubernetes.io/instance: RELEASE-NAME
22+
app.kubernetes.io/managed-by: Helm
23+
app.kubernetes.io/name: cf-common-test
24+
helm.sh/chart: cf-common-test-0.0.0
25+
- equal:
26+
path: metadata.name
27+
value: RELEASE-NAME-cf-common-test
28+
29+
- it: Test TriggerAuthentication spec
30+
set:
31+
keda:
32+
auth:
33+
enabled: true
34+
values:
35+
- values.yaml
36+
asserts:
37+
- isNotEmpty:
38+
path: spec.secretTargetRef
39+
- contains:
40+
path: spec.secretTargetRef
41+
content:
42+
parameter: parameter
43+
name: name
44+
key: key
45+
46+
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# mock deployment for KEDA
2+
controller:
3+
enabled: true
4+
type: deployment
5+
replicas: 2
6+
deployment:
7+
strategy: Recreate
8+
revisionHistoryLimit: 5
9+
10+
container:
11+
image:
12+
registry: docker.io
13+
repository: nginx
14+
tag: master
15+
pullPolicy: Always
16+
17+
hpa:
18+
enabled: false
19+
20+
keda:
21+
enabled: true
22+
spec:
23+
annotations:
24+
autoscaling.keda.sh/paused: "true"
25+
triggers:
26+
- type: cpu
27+
metadata:
28+
type: Utilization
29+
value: "70"
30+
auth:
31+
enabled: false
32+
secretTargetRef:
33+
- parameter: parameter
34+
name: name
35+
key: key

charts/cf-common-test/values.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,8 @@ additionalContainers: []
3737

3838
extraResources: []
3939

40-
externalSecrets: []
40+
externalSecrets: []
41+
42+
keda:
43+
spec: {}
44+
auth: {}

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

0 commit comments

Comments
 (0)