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
Make podIPs order match node IP family preference #97979
Conversation
So this issue should only be observed in dual stack configurations ? |
No, as @danwinship points out;
So in a single stack cluster with primary family IPv4 where the CNI-plugin returns two addresses but the IPv6 address first you get;
NOTE this is a single stack IPv4 cluster with; I use This is not as bad for K8s as it looks since
It is probably a disaster for other programs that looks at podIP and endpoints, for instance a service mesh. |
Same thing with this PR applied;
|
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.
LGTM
it LGTM, should we document this somewhere else?
|
9b86f65
to
6c7b716
Compare
sigh, I always forget that
it's really a CNI thing, not a kubernetes thing... |
I mean the kubelet behaviour
|
/retest I'd be +1 to documenting that the order output here matters and why. |
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.
/lgtm
@@ -2613,3 +2614,137 @@ func TestGenerateAPIPodStatusHostNetworkPodIPs(t *testing.T) { | |||
}) | |||
} | |||
} | |||
|
|||
func TestGenerateAPIPodStatusPodIPs(t *testing.T) { |
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.
Great tests \o/
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.
+1 great coverage
/triage accepted |
totally agree |
/assign @thockin |
the kubelet changes look good to me for sig-node. ordering makes sense here. /approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: aanm, danwinship, derekwaynecarr, uablrek The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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.
Need to rebase and nuke BUILD
f1dfb04
to
5fd1651
Compare
/lgtm |
Great 👍 |
This works around rook/rook#7522 by making podIP use the IPv6 address instead of the IPv4 address. As of kubernetes 1.21 with kubernetes/kubernetes#97979, it looks like the podIP family will match the node IP family. The node IP still defaults to IPv4, but specifying it manually works.
For the record, this fix is only a partial fix, as it misses pod creation case: #103263 |
Add missing comment about node addresses and podIPs order: kubernetes/kubernetes#95239 kubernetes/kubernetes#97979
What type of PR is this?
/kind bug
What this PR does / why we need it:
Kubelet currently sets
pod.status.podIPs
directly from the array of IPs returned from the runtime. But there are two problems with this:pod.status.podIPs
is restricted to be at most one IPv4 and at most one IPv6 IP, but the list of IPs from CRI/CNI has no such restriction; if the runtime returned, eg, 3 IPv4 addresses, then kubelet would try to set podIPs to that and then fail.This PR fixes kubelet to always pick an IP of the same family as its
--node-ip
for the first pod IP, and an IP of the opposite family (if any) for the second pod IP, and ignore any other IPs from the runtime.Which issue(s) this PR fixes:
Fixes #95251
Does this PR introduce a user-facing change?:
/sig network
/priority important-longterm
/cc @uablrek @aojea @khenidak
/auto-cc