Skip to content

Commit

Permalink
Merge pull request #22 from dmitrz/add-toplogy-spread
Browse files Browse the repository at this point in the history
  • Loading branch information
elephantum authored Aug 27, 2024
2 parents cd20684 + 724821b commit ba0d8f8
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 1 deletion.
4 changes: 4 additions & 0 deletions charts/simple-app/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.13.0

* Add `spreadServiceAcrossNodes` setting

# 0.12.0, 0.12.1

* Add `monitoringCoreos` setting for prometheus-operator managed metrics
Expand Down
2 changes: 1 addition & 1 deletion charts/simple-app/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: "0.12.1"
version: "0.13.0"

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
10 changes: 10 additions & 0 deletions charts/simple-app/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,13 @@ spec:
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.spreadServiceAcrossNodes }}
topologySpreadConstraints:
- labelSelector:
matchLabels:
{{- include "simple-app.selectorLabels" . | nindent 12 }}
maxSkew: 1
topologyKey: "kubernetes.io/hostname"
nodeTaintsPolicy: Honor
whenUnsatisfiable: ScheduleAnyway
{{- end }}
19 changes: 19 additions & 0 deletions charts/simple-app/tests/simple_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -308,3 +308,22 @@ tests:
- equal:
path: metadata.name
value: simple

- it: Spread service across nodes
template: deployment.yaml
set:
spreadServiceAcrossNodes: true
asserts:
- isKind:
of: Deployment
- equal:
path: spec.template.spec.topologySpreadConstraints
value:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
nodeTaintsPolicy: Honor
whenUnsatisfiable: ScheduleAnyway
labelSelector:
matchLabels:
app.kubernetes.io/instance: simple
app.kubernetes.io/name: simple-app
3 changes: 3 additions & 0 deletions charts/simple-app/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@
"affinity": {
"type": "object"
},
"spreadServiceAcrossNodes": {
"type": "boolean"
},
"gke": {
"type": "object",
"properties": {
Expand Down
3 changes: 3 additions & 0 deletions charts/simple-app/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ tolerations: []

affinity: {}

# If set, create topologySpreadConstraints to spread the pods across nodes
spreadServiceAcrossNodes: false

# Settings specific to GKE deployment
gke:
# If enabled and gateway.enabled is true, creates GCPBackendPolicy and
Expand Down

0 comments on commit ba0d8f8

Please sign in to comment.