-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
Determine ServiceInstances from Proxy labels instead of Pod Spec when possible #16483
Conversation
/retest |
seems this breaks multicluster |
/retest |
This looks like As #16476 says, there is still a potential bug for this. |
the problem is with split listeners we need to be able to apply inbound rules, etc, immediatelyotherwise there will be a period of time when inbound traffic comes in and rules are not applied the reason this is safe currently is because we have the readiness check to ensure inbound listeners are received, but this won't work now since container port is not required. better ideas are welcome, as I'm not sure this will work |
I am not sure about this? |
@hzxuzhonghu see changes like #16528. We will now capture all ports in inbound iptables. If you don't have containport, you will get Passthrough. |
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.
..
// metadata already. Because of this, we can still get most of the information we need. | ||
// While this may not be 100% accurate, the pod information should show up within a few second, so the impact should be minimal. | ||
// With this information we can set up RBAC, so we are not vulnerable during this time. | ||
if len(out) == 0 && len(proxy.WorkloadLabels) > 0 { |
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 would not do this as fallback but as the main way of looking up the pod labels as it’s a very costly operation to look up by 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.
Yeah I agree now, working on changing this to detect if we have all info require in labels and use as main lookup
654ce01
to
0d73c8f
Compare
/retest infra flake |
Fixes #16630 |
@@ -405,6 +405,10 @@ global: | |||
# have a shared root CA for this model to work. | |||
enabled: false | |||
|
|||
# Should be set to the name of the cluster this installation will run in. This is required for sidecar injection | |||
# to properly label proxies |
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 name must match the secret name configured for multicluster ( or whatever we use on the other side ).
// metadata already. Because of this, we can still get most of the information we need. | ||
// If we cannot accurately construct ServiceInstances from just the metadata, this will return an error and we can | ||
// attempt to read the real pod. | ||
instances, err := c.getProxyServiceInstancesFromMetadata(proxy) |
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 doing this only of getPodByIP returns null ?
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.
That beats the purpose of the effort in some sense. It is a lot of overhead to keep looking up stuff from k8s, especially in large clusters. Even if k8s code returns null, we have "done" the work which actually increases the backlog of connections that Pilot needs to service. OTOH, quickly creating the instance and starting to service the proxy will relieve the backlog.
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.
Looks very good - but I would still do the move of the logic to 'after pod was not found'.
/lgtm |
@costinm @rshriram you two seem to have different opinions on which should
be primary (labels or pod). I am on the fence. Any strong
opinion/justification for one or the other?
Certainly having it be the primary method was needed for testing since in
our CI tests I doubt we run into pod==nil often
…On Wed, Aug 28, 2019 at 4:02 PM Yuchen Dai ***@***.***> wrote:
/lgtm
I think it would address the #16630
<#16630> Thanks!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#16483?email_source=notifications&email_token=AAEYGXKRFEV37LRUERINTPDQG37XZA5CNFSM4IOYBGK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5MW5TI#issuecomment-525954765>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEYGXMFP4VDDC3DKPMTHQDQG37XZANCNFSM4IOYBGKQ>
.
|
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.
Looks good except for one major comment on pre-processing the pod ports to avoid repeated json unmarshall. Please fix that and then merge. Approving in good faith..
@@ -405,6 +405,10 @@ global: | |||
# have a shared root CA for this model to work. | |||
enabled: false | |||
|
|||
# Should be set to the name of the cluster this installation will run in. This is required for sidecar injection | |||
# to properly label proxies | |||
clusterName: "" |
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.
Nit. Call it as clusterID if the meta is called id. I wonder if we can auto initialize this to some uuid
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.
see my comment above - this must match the name used in the 'registry' config, I don't think it can be a generated UUID ( without making it hard to configure the registries). And there are plans to use the cluster name in telemetry, policy,etc.
// metadata already. Because of this, we can still get most of the information we need. | ||
// If we cannot accurately construct ServiceInstances from just the metadata, this will return an error and we can | ||
// attempt to read the real pod. | ||
instances, err := c.getProxyServiceInstancesFromMetadata(proxy) |
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.
That beats the purpose of the effort in some sense. It is a lot of overhead to keep looking up stuff from k8s, especially in large clusters. Even if k8s code returns null, we have "done" the work which actually increases the backlog of connections that Pilot needs to service. OTOH, quickly creating the instance and starting to service the proxy will relieve the backlog.
dummyPod := &v1.Pod{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Namespace: proxy.ConfigNamespace, | ||
Labels: proxy.WorkloadLabels[0], |
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 dont think thats the case in Consul either. I have no idea why this workloadLabels was an array of maps in the first place. But make sure that the map is not split into each array entry (with one k-v per array entry)
} | ||
|
||
// Find the Service associated with the pod. | ||
svcLister := listerv1.NewServiceLister(c.services.informer.GetIndexer()) |
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 don't know much about the right or most efficient k8s client apis to use. Would be good to get an ack from @hzxuzhonghu on this piece alone as he does work in that area
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 the most efficient way currently using k8s native method. But compared to the reverse search it is more costly.
Network: c.endpointNetwork(proxy.IPAddresses[0]), | ||
Locality: util.LocalityToString(proxy.Locality), | ||
}, | ||
Service: svcMap[hostname], |
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.
hopefully we are guaranteed that this map is not being changed while these instances are being constructed?
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.
good catch, I think this could happen. I'll fix this
} | ||
|
||
// findPortFromMetadata resolves the TargetPort of a Service Port, by reading the Pod spec. | ||
func findPortFromMetadata(svcPort v1.ServicePort, podPorts string) (int, error) { |
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 strongly suggest to not do this metadata lookup in that double forloop above, as this function is doing a bunch of json marshalling which is going to kill perf. Instead, parse the podPorts into some useful structure, may be even our own Port object where name can be "" if the port is of type int. Then in https://github.com/istio/istio/pull/16483/files#diff-288be3f23828adceb9ebb059ce53a23eR619, you can simply do a lookup from the pre-processed array.
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.
good call, will move it out
6e39f17
to
b1a801b
Compare
/retest |
In response to a cherrypick label: #16483 failed to apply on top of branch "release-1.3":
|
@howardjohn Please submit a manual backport PR. |
(cherry picked from commit 2e789b9)
backport sent
…On Fri, Aug 30, 2019 at 12:54 PM Romain Lenglet ***@***.***> wrote:
@howardjohn <https://github.com/howardjohn> Please submit a manual
backport PR.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#16483?email_source=notifications&email_token=AAEYGXIQYASPD43UAIDO7G3QHF3F3A5CNFSM4IOYBGK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5STTZA#issuecomment-526727652>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEYGXK3GISVMMTRGLUIRL3QHF3F3ANCNFSM4IOYBGKQ>
.
|
Port: targetPort, | ||
ServicePort: svcPort, | ||
Network: c.endpointNetwork(proxy.IPAddresses[0]), | ||
Locality: util.LocalityToString(proxy.Locality), |
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.
@howardjohn This is a regression, we can never get the real locality info from the node labels now.
* istio#16223 * istio#16272 * istio#16187 * istio#16466 * istio#16634 * istio#16594 * istio#16666 * istio#16483 * istio#16820 * istio#16842 * istio#16852 * istio#16835 * istio#16863 * istio#16892 * istio#16991 * istio#16957 * istio#17013 * istio#17134 * istio#17155 * istio#17235 * istio#17342 * istio#17477 * istio#17615 * istio#17334 * istio#17708 * istio#17737 * Fix injection template * Fix quoting * Fix test values * Add accidentally deleted affinity
No description provided.