-
Notifications
You must be signed in to change notification settings - Fork 17
feat: Allow specification of multiple topology spread constraints #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
8300b48 to
0083314
Compare
sftpgo/templates/deployment.yaml
Outdated
| maxSkew: {{ .Values.topologySpreadConstraints.maxSkew }} | ||
| topologyKey: {{ .Values.topologySpreadConstraints.topologyKey }} | ||
| whenUnsatisfiable: {{ .Values.topologySpreadConstraints.whenUnsatisfiable }} | ||
| {{- toYaml . | nindent 8 }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit problematic because it removes the label selectors.
Honestly, I'm not sure how other charts solve this out there.
Would it make sense to merge the list with the label selectors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What we can do - maybe it is not the nicest solution - is to change the code part into:
{{- with .Values.topologySpreadConstraints }}
topologySpreadConstraints:
{{- range . }}
- {{ . | toYaml | indent 8 | trim }}
labelSelector:
matchLabels:
{{- include "sftpgo.selectorLabels" $ | nindent 12 }}
{{- end }}
{{- end }}
Someone can drop the labelSelector in his override and may specify something like:
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: DoNotSchedule
matchLabelKeys:
- pod-template-hash
The result is the following:
topologySpreadConstraints:
- matchLabelKeys:
- pod-template-hash
maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
app.kubernetes.io/name: sftpgo
app.kubernetes.io/instance: sftpgo
It is the same approach that is used here.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improved version with merge:
{{- with .Values.topologySpreadConstraints }}
topologySpreadConstraints:
{{- range $constraint := . }}
{{- if not $constraint.labelSelector }}
{{- $selectorLabels := fromYaml (include "sftpgo.selectorLabels" $)}}
{{- $constraint = merge $constraint (dict "labelSelector" (dict "matchLabels" $selectorLabels)) }}
{{- end }}
- {{ $constraint | toYaml | indent 8 | trim }}
{{- end }}
{{- end }}
This version adds the default, when no labelSelector has been specified - which should be the normal case.
4ccc230 to
22187b4
Compare
…s the possibility to specify multiple topology spread constraints. These constrains are combined using a logical AND operation and control pod distribution across a cluster. Signed-off-by: Christoph Fiehe <fiehe@gmx.de>
22187b4 to
1702419
Compare
|
@sagikazarmark @drakkan |
This commit adds the possibility to specify multiple topology spread constraints. These constrains are combined using a logical AND operation and control pod distribution across a cluster.
Signed-off-by: Christoph Fiehe fiehe@gmx.de