Files
library-charts/library/common/templates/lib/pod/_nodeSelector.tpl
Kjeld Schouten 8373140e46 feat(common): limit default arch to AMD64, add topologySpreadConstraints and ensure solid default spread (#549)
**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._
2023-11-08 12:51:11 +01:00

34 lines
985 B
Smarty

{{/* Returns Node Selector */}}
{{/* Call this template:
{{ include "tc.v1.common.lib.pod.nodeSelector" (dict "rootCtx" $ "objectData" $objectData) }}
rootCtx: The root context of the chart.
objectData: The object data to be used to render the Pod.
*/}}
{{- define "tc.v1.common.lib.pod.nodeSelector" -}}
{{- $rootCtx := .rootCtx -}}
{{- $objectData := .objectData -}}
{{- $selectors := dict -}}
{{/* Initialize from the "global" option */}}
{{- with $rootCtx.Values.podOptions.nodeSelector -}}
{{- $selectors = . -}}
{{- end -}}
{{/* Override with pods option */}}
{{- with $objectData.podSpec.nodeSelector -}}
{{- $selectors = . -}}
{{- end -}}
{{- if and (include "tc.v1.common.lib.util.stopAll" $rootCtx) (eq $objectData.type "DaemonSet") }}
"non-existing": "true"
{{ else }}
{{- range $k, $v := $selectors -}}
{{- if not $v -}}
{{- else }}
{{ $k }}: {{ tpl $v $rootCtx }}
{{- end -}}
{{- end -}}
{{ end }}
{{- end -}}