Skip to content

Commit d8ea1ee

Browse files
feat(cf-common): global tolertions/nodeSelector/affinity (#101)
1 parent 1091946 commit d8ea1ee

Some content is hidden

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

47 files changed

+517
-327
lines changed

charts/cf-common-test/tests/deployment/spec_test.yaml

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,34 @@ tests:
147147
value:
148148
node-type: app
149149

150+
- it: Test global nodeSelector
151+
values:
152+
- values.yaml
153+
set:
154+
global:
155+
nodeSelector:
156+
alice: bob
157+
asserts:
158+
- equal:
159+
path: spec.template.spec.nodeSelector
160+
value:
161+
alice: bob
162+
163+
- it: Test deployment nodeSelector with global nodeSelector
164+
values:
165+
- values.yaml
166+
set:
167+
global:
168+
nodeSelector:
169+
alice: bob
170+
nodeSelector:
171+
alice: bar
172+
asserts:
173+
- equal:
174+
path: spec.template.spec.nodeSelector
175+
value:
176+
alice: bar
177+
150178
- it: Test deployments tolerations
151179
values:
152180
- values.yaml
@@ -163,6 +191,50 @@ tests:
163191
key: codefresh.io
164192
value: app
165193

194+
- it: Test global tolerations
195+
values:
196+
- values.yaml
197+
set:
198+
global:
199+
tolerations:
200+
- effect: NoSchedule
201+
key: codefresh.io
202+
value: app
203+
asserts:
204+
- contains:
205+
path: spec.template.spec.tolerations
206+
content:
207+
effect: NoSchedule
208+
key: codefresh.io
209+
value: app
210+
211+
- it: Test deployment tolerations with global tolerations
212+
values:
213+
- values.yaml
214+
set:
215+
global:
216+
tolerations:
217+
- effect: NoSchedule
218+
key: worker
219+
value: true
220+
tolerations:
221+
- effect: NoSchedule
222+
key: codefresh.io
223+
value: app
224+
asserts:
225+
- contains:
226+
path: spec.template.spec.tolerations
227+
content:
228+
effect: NoSchedule
229+
key: codefresh.io
230+
value: app
231+
- contains:
232+
path: spec.template.spec.tolerations
233+
content:
234+
effect: NoSchedule
235+
key: worker
236+
value: true
237+
166238
- it: Test deployments affinity
167239
values:
168240
- values.yaml
@@ -189,6 +261,79 @@ tests:
189261
values:
190262
- app
191263

264+
- it: Test global affinity
265+
values:
266+
- values.yaml
267+
set:
268+
global:
269+
affinity:
270+
nodeAffinity:
271+
requiredDuringSchedulingIgnoredDuringExecution:
272+
nodeSelectorTerms:
273+
- matchExpressions:
274+
- key: node-type
275+
operator: In
276+
values:
277+
- app
278+
asserts:
279+
- equal:
280+
path: spec.template.spec.affinity
281+
value:
282+
nodeAffinity:
283+
requiredDuringSchedulingIgnoredDuringExecution:
284+
nodeSelectorTerms:
285+
- matchExpressions:
286+
- key: node-type
287+
operator: In
288+
values:
289+
- app
290+
291+
- it: Test deployment affinity with global affinity
292+
values:
293+
- values.yaml
294+
set:
295+
global:
296+
affinity:
297+
nodeAffinity:
298+
requiredDuringSchedulingIgnoredDuringExecution:
299+
nodeSelectorTerms:
300+
- matchExpressions:
301+
- key: node-type
302+
operator: In
303+
values:
304+
- app
305+
affinity:
306+
podAffinity:
307+
requiredDuringSchedulingIgnoredDuringExecution:
308+
- labelSelector:
309+
matchExpressions:
310+
- key: security
311+
operator: In
312+
values:
313+
- S1
314+
topologyKey: failure-domain.beta.kubernetes.io/zone
315+
asserts:
316+
- equal:
317+
path: spec.template.spec.affinity
318+
value:
319+
nodeAffinity:
320+
requiredDuringSchedulingIgnoredDuringExecution:
321+
nodeSelectorTerms:
322+
- matchExpressions:
323+
- key: node-type
324+
operator: In
325+
values:
326+
- app
327+
podAffinity:
328+
requiredDuringSchedulingIgnoredDuringExecution:
329+
- labelSelector:
330+
matchExpressions:
331+
- key: security
332+
operator: In
333+
values:
334+
- S1
335+
topologyKey: failure-domain.beta.kubernetes.io/zone
336+
192337
- it: Test deployment with sidecar container
193338
values:
194339
- values.yaml
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/quintush/helm-unittest/master/schema/helm-testsuite.json
2+
suite: extra env vars
3+
templates:
4+
- templates/controller.yaml
5+
- templates/secret.yaml
6+
tests:
7+
- it: Test extraEnv env vars
8+
values:
9+
- values.yaml
10+
template: templates/controller.yaml
11+
set:
12+
container:
13+
env:
14+
ALICE: BOB
15+
extraEnv:
16+
FOO: $(ALICE)
17+
asserts:
18+
- contains:
19+
path: spec.template.spec.containers[0].env
20+
content:
21+
name: ALICE
22+
value: BOB
23+
- contains:
24+
path: spec.template.spec.containers[0].env
25+
content:
26+
name: FOO
27+
value: $(ALICE)

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

charts/cf-common/README.md

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

33
Codefresh library chart
44

5-
![Version: 0.22.0](https://img.shields.io/badge/Version-0.22.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.23.0](https://img.shields.io/badge/Version-0.23.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.22.0
21+
version: 0.23.0
2222
repository: https://chartmuseum.codefresh.io/cf-common
2323
```
2424
@@ -106,11 +106,14 @@ dependencies:
106106
| externalSecrets | list | `[]` | Create External Secrets |
107107
| extraResources | list | `[]` | Array of extra objects to deploy with the release |
108108
| fullNameOverride | string | `""` | String to fully override app name |
109-
| global | object | `{"clusterDomain":"","controller":{},"env":{},"imagePullSecrets":[],"imageRegistry":""}` | Global parameters |
109+
| global | object | `{"affinity":{},"clusterDomain":"","controller":{},"env":{},"imagePullSecrets":[],"imageRegistry":"","nodeSelector":{},"tolerations":[]}` | Global parameters |
110+
| global.affinity | object | `{}` | Set global affinity constrains |
110111
| global.clusterDomain | string | `""` | Cluster domain |
111112
| global.env | object | `{}` | Global Env vars. NO precedence over `.Values.container.env` |
112113
| global.imagePullSecrets | list | `[]` | Global Docker registry secret names as array |
113114
| global.imageRegistry | string | `""` | Global Docker image registry |
115+
| global.nodeSelector | object | `{}` | Set global node selection constrains |
116+
| global.tolerations | list | `[]` | Set global tolerations constrains |
114117
| hpa | object | See below | Configure autoscaling (Horizontal Pod Autoscaler) |
115118
| hpa.enabled | bool | `false` | Enable HPA |
116119
| hpa.maxReplicas | string | `nil` | Set maximum autoscaling replicas |

0 commit comments

Comments
 (0)