mirror of
https://github.com/truecharts/library-charts.git
synced 2026-07-03 09:49:15 -03:00
**Description** When moving to support clustered and multi-arch systems, we need to ensure our charts are only ran on AMD64 by default, as not all containers support ARM64 (or example). Further more, we need to ensure our pods can have their topologySpreadConstraints set. As replica's of the same deployment, should not be put on the same nodes and, preferably, spread accross multiple racks (failure domains), we need to setup sane defaults to push the kubernetes scheduler to try to put replica's on seperate nodes and failure domains by default for Deployments and StatefulSets. **⚙️ Type of change** - [x] ⚙️ Feature/App addition - [ ] 🪛 Bugfix - [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] 🔃 Refactor of current code **🧪 How Has This Been Tested?** <!-- Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration --> **📃 Notes:** Also removes the failure on empty nodeSelector and instead skips empty nodeSelectors, this allows for explicit overrides. **✔️ Checklist:** - [x] ⚖️ My code follows the style guidelines of this project - [x] 👀 I have performed a self-review of my own code - [x] #️⃣ I have commented my code, particularly in hard-to-understand areas - [x] 📄 I have made corresponding changes to the documentation - [x] ⚠️ My changes generate no new warnings - [x] 🧪 I have added tests to this description that prove my fix is effective or that my feature works - [x] ⬆️ I increased versions for any altered app according to semantic versioning **➕ App addition** If this PR is an app addition please make sure you have done the following. - [x] 🪞 I have opened a PR on [truecharts/containers](https://github.com/truecharts/containers) adding the container to TrueCharts mirror repo. - [x] 🖼️ I have added an icon in the Chart's root directory called `icon.png` --- _Please don't blindly check all the boxes. Read them and only check those that apply. Those checkboxes are there for the reviewer to see what is this all about and the status of this PR with a quick glance._
267 lines
6.6 KiB
YAML
267 lines
6.6 KiB
YAML
suite: pod node selector test
|
|
templates:
|
|
- common.yaml
|
|
release:
|
|
name: test-release-name
|
|
namespace: test-release-namespace
|
|
tests:
|
|
- it: should pass without default arch set
|
|
set:
|
|
podOptions:
|
|
nodeSelector:
|
|
kubernetes.io/arch: ""
|
|
workload:
|
|
workload-name1:
|
|
enabled: true
|
|
primary: true
|
|
type: CronJob
|
|
schedule: "*/1 * * * *"
|
|
podSpec: {}
|
|
asserts:
|
|
- documentIndex: &cronJobDoc 0
|
|
isKind:
|
|
of: CronJob
|
|
- documentIndex: *cronJobDoc
|
|
isNull:
|
|
path: spec.jobTemplate.spec.template.spec.nodeSelector
|
|
|
|
- it: should pass with empty nodeSelector
|
|
set:
|
|
podOptions:
|
|
nodeSelector: {}
|
|
workload:
|
|
workload-name1:
|
|
enabled: true
|
|
primary: true
|
|
type: CronJob
|
|
schedule: "*/1 * * * *"
|
|
podSpec: {}
|
|
asserts:
|
|
- documentIndex: *cronJobDoc
|
|
equal:
|
|
path: spec.jobTemplate.spec.template.spec.nodeSelector
|
|
value:
|
|
kubernetes.io/arch: amd64
|
|
|
|
- it: should pass with nodeSelector from "global"
|
|
set:
|
|
podOptions:
|
|
nodeSelector:
|
|
disk: ssd
|
|
cpu: intel
|
|
workload:
|
|
workload-name1:
|
|
enabled: true
|
|
primary: true
|
|
type: CronJob
|
|
schedule: "*/1 * * * *"
|
|
podSpec: {}
|
|
asserts:
|
|
- documentIndex: *cronJobDoc
|
|
equal:
|
|
path: spec.jobTemplate.spec.template.spec.nodeSelector
|
|
value:
|
|
disk: ssd
|
|
cpu: intel
|
|
kubernetes.io/arch: amd64
|
|
|
|
- it: should set nodeSelector to non-existing on DaemonSet with stopAll
|
|
set:
|
|
global:
|
|
stopAll: true
|
|
podOptions:
|
|
nodeSelector:
|
|
disk: ssd
|
|
workload:
|
|
workload-name1:
|
|
enabled: true
|
|
primary: true
|
|
type: DaemonSet
|
|
podSpec: {}
|
|
asserts:
|
|
- documentIndex: *cronJobDoc
|
|
equal:
|
|
path: spec.template.spec.nodeSelector
|
|
value:
|
|
non-existing: "true"
|
|
|
|
- it: should set nodeSelector to non-existing on DaemonSet with ixChartContext - isStopped (true)
|
|
set:
|
|
global:
|
|
namespace: ix-something
|
|
ixChartContext:
|
|
storageClassName: some-storage-class
|
|
isStopped: true
|
|
podOptions:
|
|
nodeSelector:
|
|
disk: ssd
|
|
workload:
|
|
workload-name1:
|
|
enabled: true
|
|
primary: true
|
|
type: DaemonSet
|
|
podSpec: {}
|
|
asserts:
|
|
- documentIndex: *cronJobDoc
|
|
equal:
|
|
path: spec.template.spec.nodeSelector
|
|
value:
|
|
non-existing: "true"
|
|
|
|
- it: should not set nodeSelector to non-existing on DaemonSet with ixChartContext - isStopped (false)
|
|
set:
|
|
global:
|
|
namespace: ix-something
|
|
ixChartContext:
|
|
storageClassName: some-storage-class
|
|
isStopped: false
|
|
podOptions:
|
|
nodeSelector:
|
|
disk: ssd
|
|
workload:
|
|
workload-name1:
|
|
enabled: true
|
|
primary: true
|
|
type: DaemonSet
|
|
podSpec: {}
|
|
asserts:
|
|
- documentIndex: *cronJobDoc
|
|
notEqual:
|
|
path: spec.template.spec.nodeSelector
|
|
value:
|
|
non-existing: "true"
|
|
|
|
- it: should not set nodeSelector to non-existent on non-DaemonSet with stopAll
|
|
set:
|
|
global:
|
|
stopAll: true
|
|
podOptions:
|
|
nodeSelector:
|
|
disk: ssd
|
|
workload:
|
|
workload-name1:
|
|
enabled: true
|
|
primary: true
|
|
type: Deployment
|
|
podSpec: {}
|
|
asserts:
|
|
- documentIndex: *cronJobDoc
|
|
notEqual:
|
|
path: spec.template.spec.nodeSelector
|
|
value:
|
|
non-existing: "true"
|
|
|
|
- it: should not set nodeSelector to non-existent on non-DaemonSet with ixChartContext - isStopped (true)
|
|
set:
|
|
global:
|
|
namespace: ix-something
|
|
ixChartContext:
|
|
storageClassName: some-storage-class
|
|
isStopped: true
|
|
podOptions:
|
|
nodeSelector:
|
|
disk: ssd
|
|
workload:
|
|
workload-name1:
|
|
enabled: true
|
|
primary: true
|
|
type: Deployment
|
|
podSpec: {}
|
|
asserts:
|
|
- documentIndex: *cronJobDoc
|
|
notEqual:
|
|
path: spec.template.spec.nodeSelector
|
|
value:
|
|
non-existing: "true"
|
|
|
|
- it: should not set nodeSelector to non-existent on non-DaemonSet with ixChartContext - isStopped (false)
|
|
set:
|
|
global:
|
|
namespace: ix-something
|
|
ixChartContext:
|
|
storageClassName: some-storage-class
|
|
isStopped: false
|
|
podOptions:
|
|
nodeSelector:
|
|
disk: ssd
|
|
workload:
|
|
workload-name1:
|
|
enabled: true
|
|
primary: true
|
|
type: Deployment
|
|
podSpec: {}
|
|
asserts:
|
|
- documentIndex: *cronJobDoc
|
|
notEqual:
|
|
path: spec.template.spec.nodeSelector
|
|
value:
|
|
non-existing: "true"
|
|
|
|
- it: should pass with nodeSelector from "pod"
|
|
set:
|
|
podOptions:
|
|
nodeSelector:
|
|
disk: ssd
|
|
cpu: intel
|
|
workload:
|
|
workload-name1:
|
|
enabled: true
|
|
primary: true
|
|
type: CronJob
|
|
schedule: "*/1 * * * *"
|
|
podSpec:
|
|
nodeSelector:
|
|
disk: hdd
|
|
cpu: amd
|
|
asserts:
|
|
- documentIndex: *cronJobDoc
|
|
equal:
|
|
path: spec.jobTemplate.spec.template.spec.nodeSelector
|
|
value:
|
|
disk: hdd
|
|
cpu: amd
|
|
|
|
- it: should pass with nodeSelector from "pod" with tpl
|
|
set:
|
|
disk_type: hdd
|
|
podOptions:
|
|
nodeSelector:
|
|
disk: ssd
|
|
cpu: intel
|
|
workload:
|
|
workload-name1:
|
|
enabled: true
|
|
primary: true
|
|
type: CronJob
|
|
schedule: "*/1 * * * *"
|
|
podSpec:
|
|
nodeSelector:
|
|
disk: "{{ .Values.disk_type }}"
|
|
cpu: amd
|
|
asserts:
|
|
- documentIndex: *cronJobDoc
|
|
equal:
|
|
path: spec.jobTemplate.spec.template.spec.nodeSelector
|
|
value:
|
|
disk: hdd
|
|
cpu: amd
|
|
|
|
- it: should ignore with empty value on nodeSelector
|
|
set:
|
|
podOptions:
|
|
nodeSelector:
|
|
disk: ""
|
|
workload:
|
|
workload-name1:
|
|
enabled: true
|
|
primary: true
|
|
type: CronJob
|
|
schedule: "*/1 * * * *"
|
|
podSpec: {}
|
|
asserts:
|
|
- documentIndex: *cronJobDoc
|
|
equal:
|
|
path: spec.jobTemplate.spec.template.spec.nodeSelector
|
|
value:
|
|
kubernetes.io/arch: amd64
|