-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Include labelSelector for affinity and topologySpreadConstraints #4666
base: master
Are you sure you want to change the base?
Include labelSelector for affinity and topologySpreadConstraints #4666
Conversation
|
Welcome @pvickery-ParamountCommerce! |
Hi @pvickery-ParamountCommerce. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
651a289
to
8c7bd6d
Compare
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.
Thanks for the PR @pvickery-ParamountCommerce. The comments in values.yaml were incorrectly copied from a chart where this had been implemented. Did you also see that the same comment was present for affinity
? I think we have the following 3 options:
- Change the comments and don't add default label selectors
- Implement your pattern for
affinity
- Implement the other pattern
FYI you also need to add a chart CHANGELOG entry under [UNRELEASED]
.
8c7bd6d
to
fe6ba6c
Compare
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Thanks for the feedback @stevehipwell! I used these values to test affinity when automatically adding the affinity:
podAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
topologyKey : "kubernetes.io/hostname"
# labelSelector:
# matchExpressions:
# - key: app.kubernetes.io/name
# operator: In
# values:
# - test
requiredDuringSchedulingIgnoredDuringExecution:
- topologyKey : "kubernetes.io/hostname"
# labelSelector:
# matchExpressions:
# - key: app.kubernetes.io/name
# operator: In
# values:
# - test
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
topologyKey : "kubernetes.io/hostname"
# labelSelector:
# matchExpressions:
# - key: app.kubernetes.io/name
# operator: In
# values:
# - test
requiredDuringSchedulingIgnoredDuringExecution:
- topologyKey : "kubernetes.io/hostname"
# labelSelector:
# matchExpressions:
# - key: app.kubernetes.io/name
# operator: In
# values:
# - test |
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.
Could you move the basic structure out into the deployment template, use smaller template functions and make use of with
? Something like below (untested).
{{- with .Values.affinity }}
affinity:
{{- with .podAffinity }}
podAffinity:
{{- with preferredDuringSchedulingIgnoredDuringExecution }}
{{- range . }}
{{- if dig "podAffinityTerm" "labelSelector" nil . }}
{{- toYaml (list .) | nindent 10 }}
{{- else }}
{{ include "external-dns.podAffinityPreferred" . }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
fe6ba6c
to
2a14be3
Compare
2a14be3
to
bc43727
Compare
Thanks @stevehipwell, that is a good idea! I've updated it with your suggestion and have tested it locally |
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.
Could you also look at updating the charts/ci/ci-values.yaml to include coverage for these changes? FYI CI uses a standard Kind cluster .
If this isn't possible we could look at adding a kubconform
step to validate the templates.
bc43727
to
4400005
Compare
4400005
to
f388cbe
Compare
Thanks @stevehipwell and sorry for the delay! |
/ok-to-test |
f388cbe
to
eb43997
Compare
eb43997
to
d164107
Compare
@pvickery-ParamountCommerce this looks to be failing the lint. |
d164107
to
32f0e11
Compare
Ah shoot! I've updated it again to pass the linting checks. |
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.
Just a couple of comments.
32f0e11
to
844bab3
Compare
One more push to fix those findings. I also updatee how the labelSelector is added to remove a useless newline. Thanks again for all the help @stevehipwell! {{- if dig "labelSelector" nil . }}
- - {{- toYaml . | nindent 16 }}
+ - {{ toYaml . | indent 16 | trim }} |
Description
The labelSelector is used to track the pods that are used for the topologySpreadConstraints calculation. matchLabelKeys is used to only use the pods in the current version of the deployments replicaset.
I believe the following message isn't true before this PR.
external-dns/charts/external-dns/values.yaml
Lines 155 to 156 in 1ceaf79
More details about matchLabelKeys can be found here:
Checklist