Skip to content

Commit

Permalink
add topologySpreadConstraints (#32)
Browse files Browse the repository at this point in the history
To make the deployment as resilient as possible, we distribute it by default. I opted against "DoNotSchedule" as we want to have the pods as fast as possible and also provide stable operations on a single node cluster.
  • Loading branch information
bitte-ein-bit authored Aug 22, 2022
1 parent f3e0fa8 commit 3918321
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion charts/k8s-sizing-webhook/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,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.3.0
version: 0.4.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
15 changes: 15 additions & 0 deletions charts/k8s-sizing-webhook/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,21 @@ spec:
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.topologySpreadConstraints.enable }}
topologySpreadConstraints:
- maxSkew: 1
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: {{ .Values.topologySpreadConstraints.policy | quote }}
labelSelector:
matchLabels:
{{- include "k8s-sizing-webhook.selectorLabels" . | nindent 12 }}
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: {{ .Values.topologySpreadConstraints.policy | quote }}
labelSelector:
matchLabels:
{{- include "k8s-sizing-webhook.selectorLabels" . | nindent 12 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
Expand Down
4 changes: 4 additions & 0 deletions charts/k8s-sizing-webhook/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ podDisruptionBudget:
create: true
minAvailable: 1

topologySpreadConstraints:
enable: true
policy: ScheduleAnyway

resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
Expand Down

0 comments on commit 3918321

Please sign in to comment.