-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Controller: Correctly identify other pods on shutdown. #13444
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
✅ Deploy Preview for kubernetes-ingress-nginx canceled.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: DerekTBrown 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 |
Welcome @DerekTBrown! |
Hi @DerekTBrown. Thanks for your PR. I'm waiting for a kubernetes 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. |
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.
Gonna review the Go code later.
/retitle Controller: Correctly identify other pods on shutdown.
/triage accepted
/kind feature
/priority backlog
/hold
@@ -34,6 +34,9 @@ spec: | |||
labels: | |||
{{- include "ingress-nginx.labels" . | nindent 8 }} | |||
app.kubernetes.io/component: controller | |||
{{- if not .Values.controller.disableLeaderElection }} | |||
nginx.ingress.kubernetes.io/electionID: {{ include "ingress-nginx.controller.electionID" . }} |
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.
Not sure if camel case is the way to go here...
nginx.ingress.kubernetes.io/electionID: {{ include "ingress-nginx.controller.electionID" . }} | |
nginx.ingress.kubernetes.io/election-id: {{ include "ingress-nginx.controller.electionID" . }} |
@@ -40,6 +40,9 @@ spec: | |||
labels: | |||
{{- include "ingress-nginx.labels" . | nindent 8 }} | |||
app.kubernetes.io/component: controller | |||
{{- if not .Values.controller.disableLeaderElection }} | |||
nginx.ingress.kubernetes.io/electionID: {{ include "ingress-nginx.controller.electionID" . }} |
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.
Same here:
nginx.ingress.kubernetes.io/electionID: {{ include "ingress-nginx.controller.electionID" . }} | |
nginx.ingress.kubernetes.io/election-id: {{ include "ingress-nginx.controller.electionID" . }} |
@@ -208,3 +208,30 @@ tests: | |||
- equal: | |||
path: spec.template.spec.runtimeClassName | |||
value: myClass | |||
|
|||
- it: should create a DaemonSet with the electionID label on the pod template when leader election is enabled |
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.
- it: should create a DaemonSet with the electionID label on the pod template when leader election is enabled | |
- it: should create a DaemonSet with election ID label |
controller.disableLeaderElection: false | ||
asserts: | ||
- equal: | ||
path: spec.template.metadata.labels['nginx.ingress.kubernetes.io/electionID'] |
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.
path: spec.template.metadata.labels['nginx.ingress.kubernetes.io/electionID'] | |
path: spec.template.metadata.labels["nginx.ingress.kubernetes.io/election-id"] |
- it: should create a DaemonSet with the electionID label on the pod template when leader election is enabled | ||
set: | ||
controller.kind: DaemonSet | ||
controller.disableLeaderElection: false |
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.
I'd actually omit explicitly setting this, so the test fails as soon as someone changes the default.
- it: should create a DaemonSet with the custom electionID label on the pod template when controller.electionID is set and leader election is enabled | ||
set: | ||
controller.kind: DaemonSet | ||
controller.disableLeaderElection: false |
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.
Same here: I'd actually omit explicitly setting this, so the test fails as soon as someone changes the default.
controller.electionID: custom-election-id | ||
asserts: | ||
- equal: | ||
path: spec.template.metadata.labels['nginx.ingress.kubernetes.io/electionID'] |
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.
path: spec.template.metadata.labels['nginx.ingress.kubernetes.io/electionID'] | |
path: spec.template.metadata.labels["nginx.ingress.kubernetes.io/election-id"] |
path: spec.template.metadata.labels['nginx.ingress.kubernetes.io/electionID'] | ||
value: custom-election-id | ||
|
||
- it: should create a DaemonSet without the electionID label on the pod template when leader election is disabled |
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.
- it: should create a DaemonSet without the electionID label on the pod template when leader election is disabled | |
- it: should create a DaemonSet without election ID label if `controller.disableLeaderElection` is true |
controller.disableLeaderElection: true | ||
asserts: | ||
- notExists: | ||
path: spec.template.metadata.labels['nginx.ingress.kubernetes.io/electionID'] |
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.
path: spec.template.metadata.labels['nginx.ingress.kubernetes.io/electionID'] | |
path: spec.template.metadata.labels["nginx.ingress.kubernetes.io/election-id"] |
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.
Same here as for the DaemonSet tests.
What we are looking for here is basically a way to determine all the other pods targeted by either the Deployment or the DaemonSet, right? Why don't we hand in the selector labels used in the |
Reviewing the code once again, I'm asking myself if the whole stuff in |
What this PR does / why we need it:
electionID
. We expect a pod to tear down an ingress iff all pods with the same electionID have gone away (i.e. meaning there will be no future successful master election).Types of changes
This is a breaking change in two respects:
Which issue/s this PR fixes
--update-status-on-shutdown
for external DNS #18771How Has This Been Tested?
helm chart
to validate the new label is defined.status.go
component to validate the pod finding behavior.Checklist:
Footnotes
See: https://github.com/kubernetes/ingress-nginx/issues/11087#issuecomment-2712118775 ↩ ↩2 ↩3