Skip to content

Commit

Permalink
switch to spreadServiceAcrossNodes setting
Browse files Browse the repository at this point in the history
  • Loading branch information
elephantum committed Aug 27, 2024
1 parent 62febc8 commit 724821b
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 7 deletions.
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
9 changes: 6 additions & 3 deletions charts/simple-app/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,13 @@ spec:
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.spreadServiceAcrossNodes }}
topologySpreadConstraints:
- labelSelector:
matchLabels:
app.kubernetes.io/instance: {{ .Release.Name }}
maxSkew: {{ .Values.skew }}
{{- include "simple-app.selectorLabels" . | nindent 12 }}
maxSkew: 1
topologyKey: "kubernetes.io/hostname"
whenUnsatisfiable: {{ .Values.skewPolicy }}
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
6 changes: 3 additions & 3 deletions charts/simple-app/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

skew: 1
skewPolicy: ScheduleAnyway

nameOverride: ""
fullnameOverride: ""

Expand Down Expand Up @@ -181,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 724821b

Please sign in to comment.