-
Notifications
You must be signed in to change notification settings - Fork 7.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
Support ServiceInternalTrafficPolicy #42551
Conversation
FWIW after looking at it more I think that feature is orthogonal |
// As this may contain node topology labels, which could not be got from aggregator controller | ||
out[model.LocalityLabel] = locality | ||
return out | ||
// set k8s node name label, for ServiceInternalTrafficPolicy |
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 think this should be in AugmentLabels
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.
For endpoint labels we can use AugmentLabels
(updated), but for proxy labels I'm not sure how, is there any other place to get the k8s node?
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 mutating the underlying pod labels
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.
can set it in setTopologyLabels
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 mutating the underlying pod labels
Thanks for reminding, fixed
can set it in
setTopologyLabels
I think we have to set the host label here, as we can't get it elsewhere
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.
Why not AugmentLabels then fetch it like setTopologyLabels
( proxy.ServiceInstances[0].Endpoint.Locality.Node
)
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.
Actually we can add NODE_NAME to the injection template (downward API) and get it from there 99% of the time. And fallback to ^ when its not there.
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.
The experimental-ambient branch already does this if you would like a reference
Yeah I think it also applies to
|
e77534c
to
3240a6f
Compare
pilot/pkg/model/service.go
Outdated
@@ -129,6 +129,8 @@ const ( | |||
Passthrough | |||
// DNSRoundRobinLB implies that the proxy will resolve a DNS address and forward to the resolved address | |||
DNSRoundRobinLB | |||
// NodeLocal implies that the proxy will only forward to node local endpoints | |||
NodeLocal |
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.
Using resolution is a little hacky,
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.
Any suggestions?
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.
how about add a NodeLocal bool field in ServiceAttributes
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.
Updated
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
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.
Main implementation lgtm, just think we can improve how we get the node by passing it over XDS.
// As this may contain node topology labels, which could not be got from aggregator controller | ||
out[model.LocalityLabel] = locality | ||
return out | ||
// set k8s node name label, for ServiceInternalTrafficPolicy |
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.
Why not AugmentLabels then fetch it like setTopologyLabels
( proxy.ServiceInstances[0].Endpoint.Locality.Node
)
// As this may contain node topology labels, which could not be got from aggregator controller | ||
out[model.LocalityLabel] = locality | ||
return out | ||
// set k8s node name label, for ServiceInternalTrafficPolicy |
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.
Actually we can add NODE_NAME to the injection template (downward API) and get it from there 99% of the time. And fallback to ^ when its not there.
@@ -98,7 +99,7 @@ func NewEndpointBuilderFromMetadata(c controllerInterface, proxy *model.Proxy) * | |||
if len(proxy.IPAddresses) > 0 { | |||
networkID = out.endpointNetwork(proxy.IPAddresses[0]) | |||
} | |||
out.labels = labelutil.AugmentLabels(proxy.Labels, c.Cluster(), locality, networkID) | |||
out.labels = labelutil.AugmentLabels(proxy.Labels, c.Cluster(), locality, "", networkID) |
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.
once we add node name like I mentioned, make ""
be proxy.Metadata.NodeName
pilot/pkg/xds/ads.go
Outdated
@@ -630,7 +630,7 @@ func setTopologyLabels(proxy *model.Proxy) { | |||
|
|||
locality := util.LocalityToString(proxy.Locality) | |||
// add topology labels to proxy labels | |||
proxy.Labels = labelutil.AugmentLabels(proxy.Labels, proxy.Metadata.ClusterID, locality, proxy.Metadata.Network) | |||
proxy.Labels = labelutil.AugmentLabels(proxy.Labels, proxy.Metadata.ClusterID, locality, "", proxy.Metadata.Network) |
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.
In addition to modifying Labels we should have a proxy.NodeName
we set, just like L624
pilot/pkg/xds/endpoint_builder.go
Outdated
@@ -132,6 +133,10 @@ func (b EndpointBuilder) Key() string { | |||
hash.Write(b.failoverPriorityLabels) | |||
hash.Write(Separator) | |||
} | |||
if b.service.Attributes.NodeLocal { | |||
hash.Write([]byte(b.proxy.Labels[label.LabelHostname])) |
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.
hash.Write([]byte(b.proxy.Labels[label.LabelHostname])) | |
hash.Write([]byte(b.proxy.NodeName)) |
Once other suggestions are done
// As this may contain node topology labels, which could not be got from aggregator controller | ||
out[model.LocalityLabel] = locality | ||
return out | ||
// set k8s node name label, for ServiceInternalTrafficPolicy |
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.
The experimental-ambient branch already does this if you would like a reference
31fe230
to
5af030a
Compare
} | ||
var networkID network.ID | ||
if len(proxy.IPAddresses) > 0 { | ||
networkID = out.endpointNetwork(proxy.IPAddresses[0]) | ||
} | ||
out.labels = labelutil.AugmentLabels(proxy.Labels, c.Cluster(), locality, networkID) | ||
out.labels = labelutil.AugmentLabels(proxy.Labels, c.Cluster(), locality, proxy.Metadata.NodeName, networkID) |
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.
we use GetNodeName in other places, is this intended?
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.
No, have changed to proxy.GetNodeName()
if len(proxy.GetNodeName()) == 0 { | ||
// this can happen for an "old" proxy which has no `Metadata.NodeName` set | ||
// in this case we set the node name in labels on the fly | ||
nodeName = pod.Spec.NodeName |
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 can be removed in a future release, please add a TODO
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.
Added
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.
https://prow.istio.io/view/gs/istio-prow/pr-logs/pull/istio_istio/42551/gencheck_istio/1610947968523833344
I don't know why those generated yamls have no ISTIO_META_NODE_NAME
, is that expected? Am I missing something?
I'm not very familiar with updating charts, could you please give some hints?
@@ -224,6 +224,10 @@ spec: | |||
{{- end }} | |||
- name: ISTIO_META_CLUSTER_ID | |||
value: "{{ $.Values.global.multiCluster.clusterName | default `Kubernetes` }}" | |||
- name: ISTIO_META_NODE_NAME |
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.
Curious what L164 is used for
you can just run But those files are not actually based on manifests/ but a snapshot of them to avoid excessive churn, |
Get it, thanks! The release-notes test failed because |
/retest |
Please provide a description of this PR:
Fixes #42377
NOTE: This PR does not take
ProxyTerminatingEndpoints
into account