Files
AspenandGitHub c5b724d69f feat(common): Allow configuring default topologyKey (#32461)
**Description**
<!--
Please include a summary of the change and which issue is fixed. Please
also include relevant motivation and context. List any dependencies that
are required for this change.
-->
This PR adds a global option to control the default topologyKey used for
topologySpreadConstraints

⚒️ Fixes  #32457

**⚙️ 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
- [ ] 📜 Documentation Changes

**🧪 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
-->
Ran the common library unit tests, added one to verify the usage of the
field

**📃 Notes:**
<!-- Please enter any other relevant information here -->

**✔️ 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 changes to the documentation
- [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
- [x] I made sure the title starts with `feat(chart-name):`,
`fix(chart-name):`, `chore(chart-name):`, `docs(chart-name):` or
`fix(docs):`

** App addition**

If this PR is an app addition please make sure you have done the
following.

- [ ] 🖼️ 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._
2025-02-24 13:09:20 +01:00

225 lines
7.1 KiB
YAML

suite: pod topologySpreadConstraints test
templates:
- common.yaml
release:
name: test-release-name
namespace: test-release-namespace
tests:
- it: should pass with missing topologySpreadConstraints on DaemonSet
set:
workload:
workload-name1:
enabled: true
primary: true
type: DaemonSet
podSpec: {}
asserts:
- documentIndex: &daemonSetDoc 0
isKind:
of: DaemonSet
- documentIndex: *daemonSetDoc
isNull:
path: spec.template.spec.topologySpreadConstraints
- it: should pass with defaultSpread disabled
set:
podOptions:
defaultSpread: false
workload:
workload-name1:
enabled: true
primary: true
type: Deployment
podSpec: {}
asserts:
- documentIndex: &deploymentSetDoc 0
isKind:
of: Deployment
- documentIndex: *deploymentSetDoc
isNull:
path: spec.template.spec.topologySpreadConstraints
- it: should pass defaults with missing topologySpreadConstraints on Deployment
set:
workload:
workload-name1:
enabled: true
primary: true
type: Deployment
podSpec: {}
asserts:
- documentIndex: &deploymentDoc 0
isKind:
of: Deployment
- documentIndex: *deploymentDoc
equal:
path: spec.selector.matchLabels
value:
app.kubernetes.io/instance: test-release-name
app.kubernetes.io/name: common-test
pod.name: workload-name1
- documentIndex: *deploymentDoc
equal:
path: spec.template.spec.topologySpreadConstraints
value:
- labelSelector:
matchLabels:
app.kubernetes.io/instance: test-release-name
app.kubernetes.io/name: common-test
pod.name: workload-name1
maxSkew: 1
nodeAffinityPolicy: Honor
nodeTaintsPolicy: Honor
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: ScheduleAnyway
- it: should pass with topologySpreadConstraints from "global"
set:
podOptions:
topologySpreadConstraints:
- maxSkew: 1
whenUnsatisfiable: ScheduleAnyway
topologyKey: "truecharts.org/test"
labelSelector:
matchLabels: {}
nodeAffinityPolicy: Honor
nodeTaintsPolicy: Honor
workload:
workload-name1:
enabled: true
primary: true
type: Deployment
podSpec: {}
asserts:
- documentIndex: *deploymentDoc
equal:
path: spec.selector.matchLabels
value:
app.kubernetes.io/instance: test-release-name
app.kubernetes.io/name: common-test
pod.name: workload-name1
- documentIndex: *deploymentDoc
equal:
path: spec.template.spec.topologySpreadConstraints
value:
- labelSelector:
matchLabels:
app.kubernetes.io/instance: test-release-name
app.kubernetes.io/name: common-test
pod.name: workload-name1
maxSkew: 1
nodeAffinityPolicy: Honor
nodeTaintsPolicy: Honor
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: ScheduleAnyway
- labelSelector:
matchLabels: {}
maxSkew: 1
nodeAffinityPolicy: Honor
nodeTaintsPolicy: Honor
topologyKey: truecharts.org/test
whenUnsatisfiable: ScheduleAnyway
- it: should pass with topologyKey from "global"
set:
global:
fallbackDefaults:
topologyKey: "truecharts.org/test"
workload:
workload-name1:
enabled: true
primary: true
type: Deployment
podSpec: {}
asserts:
- documentIndex: *deploymentDoc
equal:
path: spec.selector.matchLabels
value:
app.kubernetes.io/instance: test-release-name
app.kubernetes.io/name: common-test
pod.name: workload-name1
- documentIndex: *deploymentDoc
equal:
path: spec.template.spec.topologySpreadConstraints
value:
- labelSelector:
matchLabels:
app.kubernetes.io/instance: test-release-name
app.kubernetes.io/name: common-test
pod.name: workload-name1
maxSkew: 1
nodeAffinityPolicy: Honor
nodeTaintsPolicy: Honor
topologyKey: truecharts.org/test
whenUnsatisfiable: ScheduleAnyway
- it: should pass with multiple topologySpreadConstraints from "pod"
set:
podOptions:
topologySpreadConstraints:
- maxSkew: 1
whenUnsatisfiable: ScheduleAnyway
topologyKey: "truecharts.org/test1"
labelSelector:
matchLabels: {}
nodeAffinityPolicy: Honor
nodeTaintsPolicy: Honor
workload:
workload-name1:
enabled: true
primary: true
type: Deployment
podSpec:
topologySpreadConstraints:
- maxSkew: 1
whenUnsatisfiable: ScheduleAnyway
topologyKey: "truecharts.org/test2"
labelSelector:
matchLabels: {}
nodeAffinityPolicy: Honor
nodeTaintsPolicy: Honor
- maxSkew: 1
whenUnsatisfiable: ScheduleAnyway
topologyKey: "truecharts.org/test3"
labelSelector:
matchLabels: {}
nodeAffinityPolicy: Honor
nodeTaintsPolicy: Honor
asserts:
- documentIndex: *deploymentDoc
equal:
path: spec.selector.matchLabels
value:
app.kubernetes.io/instance: test-release-name
app.kubernetes.io/name: common-test
pod.name: workload-name1
- documentIndex: *deploymentDoc
equal:
path: spec.template.spec.topologySpreadConstraints
value:
- labelSelector:
matchLabels:
app.kubernetes.io/instance: test-release-name
app.kubernetes.io/name: common-test
pod.name: workload-name1
maxSkew: 1
nodeAffinityPolicy: Honor
nodeTaintsPolicy: Honor
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: ScheduleAnyway
- labelSelector:
matchLabels: {}
maxSkew: 1
nodeAffinityPolicy: Honor
nodeTaintsPolicy: Honor
topologyKey: truecharts.org/test2
whenUnsatisfiable: ScheduleAnyway
- labelSelector:
matchLabels: {}
maxSkew: 1
nodeAffinityPolicy: Honor
nodeTaintsPolicy: Honor
topologyKey: truecharts.org/test3
whenUnsatisfiable: ScheduleAnyway