Skip to content
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

Adds default selectorLabels to topologySpreadConstraints if not otherwise specified. #429

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions charts/vector/templates/_pod.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,13 @@ tolerations:
{{- end }}
{{- with .Values.topologySpreadConstraints }}
topologySpreadConstraints:
{{- range $_, $entry := . }}
{{- if not (dig "labelSelectors" "matchLabels" false $entry) }}
{{- $ls := "labelSelectors:\n matchLabels: {}" | fromYaml }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not very familiar with this, but the \n seems a bit hacky. I wonder if we can do this more cleanly with a dict.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, it's kind of gross. I just updated this to use the dict function to create the nested dictionary keys.

{{- $_ := set $ls.labelSelectors "matchLabels" (include "vector.selectorLabels" $ | fromYaml) }}
{{- $entry := merge $entry $ls }}
{{- end }}
{{- end }}
{{- toYaml . | nindent 2 }}
{{- end }}
volumes:
Expand Down
2 changes: 2 additions & 0 deletions charts/vector/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ affinity: {}

# topologySpreadConstraints -- Configure [topology spread constraints](https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/)
# for Vector Pods. Valid for the "Aggregator" and "Stateless-Aggregator" roles.
#
# If no "selectorLabels.matchLabels" are defined then defaults will be used to match the selectorLabels of this instance.
topologySpreadConstraints: []

# Configuration for Vector's Service.
Expand Down