Skip to content
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

WorkloadSelector support for DestinationRule #2207

Merged
merged 7 commits into from
Mar 19, 2022

Conversation

kfaseela
Copy link
Member

Adding support for workloadSelector in DR
as per RFC Simplify Sidecar Egress For MTLS

Signed-off-by: Faseela K faseela.k@est.tech

@istio-policy-bot
Copy link

😊 Welcome @kfaseela! This is either your first contribution to the Istio api repo, or it's been
awhile since you've been here.

You can learn more about the Istio working groups, code of conduct, and contributing guidelines
by referring to Contributing to Istio.

Thanks for contributing!

Courtesy of your friendly welcome wagon.

@istio-testing istio-testing added do-not-merge/work-in-progress Block merging of a PR because it isn't ready yet. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 14, 2022
@kfaseela
Copy link
Member Author

/test release-notes_api

Copy link
Member

@howardjohn howardjohn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am +1 to the idea

// Criteria used to select the specific set of pods/VMs on which this
// `Sidecar` configuration should be applied. If omitted, the `Sidecar`
// configuration will be applied to all workload instances in the same namespace.
WorkloadSelector workload_selector = 5;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should use istio.type.v1beta1.WorkloadSelector. Through unfortunate situation we ended up with two different ones to handle the same case, but all modern CRDs are using that type.

Also the comments are copy+pasted from Sidecar, need to be updated.

@bianpengyuan
Copy link
Contributor

Curious, how does this interact with subset? Is it that the unmatched proxy won't have subset configured? If so should we also have workload selector at virtual service to make it consistent. There are definitely demand for this istio/istio#36240 and istio/istio#29434

@howardjohn
Copy link
Member

howardjohn commented Jan 14, 2022 via email

@hzxuzhonghu
Copy link
Member

First, i wanna say i am totally for this proposal.
But i think this will break backward compatibility. Before a DR without wokloadSelector, it would be applied to all namespaces.

But with this, without workloadSelector set, it will be applied to the same namespace

@linsun
Copy link
Member

linsun commented Jan 19, 2022

This is an interesting concept. Could we think through what impact it will have for DR priority ordering: client side, server side, namespace, global.

BTW, is this workload selector for client side or server side?

@kfaseela
Copy link
Member Author

First, i wanna say i am totally for this proposal. But i think this will break backward compatibility. Before a DR without wokloadSelector, it would be applied to all namespaces.

But with this, without workloadSelector set, it will be applied to the same namespace

I think the confusion came due to my wrong description of the attribute that it will be namespace specific. will correct it

@kfaseela
Copy link
Member Author

This is an interesting concept. Could we think through what impact it will have for DR priority ordering: client side, server side, namespace, global.

BTW, is this workload selector for client side or server side?

workSelector by default is global, and we can use "exportTo" to limit namespace list.
DR is for both client and server, and we want to limit client side in this PR.

DR will impact server side in TLS case, TLS mode in DR can be changed to override global TLS mode (e.g.STRICT), from this perspective, we can limit the "workSelector" to client side only, and keep server side behaviour as before.

@howardjohn
Copy link
Member

howardjohn commented Jan 19, 2022

workSelector by default is global, and we can use "exportTo" to limit namespace list.

I disagree, if workloadSelector is present it should only match current namespace. This matches all of our resources (except Gateway, and its been replaced by another mechanism in gateway-api and was a mistake IMO).

DR will impact server side in TLS case, TLS mode in DR can be changed to override global TLS mode (e.g.STRICT), from this perspective, we can limit the "workSelector" to client side only, and keep server side behaviour as before.

DR only impacts server for circuit breakers, not TLS. If we want similar for this behavior we should do #1754 imo

@bianpengyuan
Copy link
Contributor

DR will impact server side in TLS case, TLS mode in DR can be changed to override global TLS mode (e.g.STRICT), from this perspective, we can limit the "workSelector" to client side only, and keep server side behaviour as before.

istio/istio#36731 (comment) as an example of why it would also benefit server side.

@howardjohn
Copy link
Member

istio/istio#36731 (comment) as an example of why it would also benefit server side.

I think its still somewhat ambiguous and #1754 would be preferred. For example, say I have a DR for httpbin.default.svc.cluster.local and selector app=httpbin. We would apply config on inbound and outbound side - use may have actually only wanted it on one or the other. Sidecar makes it very explicit

@bianpengyuan
Copy link
Contributor

I think its still somewhat ambiguous and #1754 would be preferred

Yeah I agree. Adding selector to DR is more like a workaround for the inbound configuration issue, which might complicate the configuration or not even cover some of the use cases.

kfaseela added a commit to Nordix/api that referenced this pull request Feb 4, 2022
As per https://github.com/istio/api#updating `make proto-lock`
has to be run as part of new api changes. I was trying
to run the same for my PR istio#2207
and saw some additional changes added in proto.lock which
was not introduced by my change. Hence putting them in a separate
PR here to check if these changes are needed or not.

Signed-off-by: Faseela K <faseela.k@est.tech>
istio-testing pushed a commit that referenced this pull request Feb 7, 2022
As per https://github.com/istio/api#updating `make proto-lock`
has to be run as part of new api changes. I was trying
to run the same for my PR #2207
and saw some additional changes added in proto.lock which
was not introduced by my change. Hence putting them in a separate
PR here to check if these changes are needed or not.

Signed-off-by: Faseela K <faseela.k@est.tech>
@kfaseela kfaseela changed the title WIP: WorkloadSelector support for DestinationRule WorkloadSelector support for DestinationRule Mar 10, 2022
@istio-testing istio-testing added needs-rebase Indicates a PR needs to be rebased before being merged and removed do-not-merge/work-in-progress Block merging of a PR because it isn't ready yet. labels Mar 10, 2022
@istio-testing istio-testing removed the needs-rebase Indicates a PR needs to be rebased before being merged label Mar 17, 2022
Copy link
Member

@howardjohn howardjohn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM, just needs some docs improvements

@@ -162,6 +163,28 @@ import "gogoproto/gogo.proto";
// simple: ROUND_ROBIN
// ```
// {{</tab>}}
//
// {{<tab name="v1alpha3" category-value="v1alpha3">}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is adding a third tab to a tab group of {v1alpha3,v1beta1}.

If we want to provide and example with workloadSelector, we should look like:

You can also use a workload selector .. blah blah...

{{<tabset category-name="selector-example">}}
{{tab }}
....

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, if I fixed it properly. Could you please take another look now?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great

//
// Criteria used to select the specific set of pods/VMs on which this
// `DestinationRule` configuration should be applied. If omitted, the `DestinationRule`
// configuration will be applied to all workload instances in the same namespace.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Same namespace" is not require accurate, since it can apply cross namespace,

We should also note that with workload selector set it is NOT cross namespace.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be clearly documented, whether this is selecting cross namespaces or within the same namespace.

Also move this field up to first position.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tried to rephrase the comment.

@istio-testing istio-testing added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 18, 2022
@@ -162,6 +163,28 @@ import "gogoproto/gogo.proto";
// simple: ROUND_ROBIN
// ```
// {{</tab>}}
//
// {{<tab name="v1alpha3" category-value="v1alpha3">}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great

Adding support for workloadSelector in DR
as per RFC Simplify Sidecar Egress For MTLS

Signed-off-by: Faseela K <faseela.k@est.tech>
Signed-off-by: Faseela K <faseela.k@est.tech>
Signed-off-by: Faseela K <faseela.k@est.tech>
Signed-off-by: Faseela K <faseela.k@est.tech>
Signed-off-by: Faseela K <faseela.k@est.tech>
Signed-off-by: Faseela K <faseela.k@est.tech>
@kfaseela
Copy link
Member Author

/retest

// configuration will be applied only to the workload instances matching the workload selector
// label in the same namespace. Workload selectors do not apply across namespace boundaries.
// If omitted, the `DestinationRule` falls back to its default behavior.
istio.type.v1beta1.WorkloadSelector workload_selector = 5;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be we should explain when this will be used vs. default behaviour? That is not clear to me while reading this comment.

@howardjohn WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clarified in the comment

Signed-off-by: Faseela K <faseela.k@est.tech>
Copy link
Contributor

@ramaraochavali ramaraochavali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

@istio-testing istio-testing merged commit 7fbbe6f into istio:master Mar 19, 2022
@kfaseela
Copy link
Member Author

Thank you!

// Criteria used to select the specific set of pods/VMs on which this
// `DestinationRule` configuration should be applied. If specified, the `DestinationRule`
// configuration will be applied only to the workload instances matching the workload selector
// label in the same namespace. Workload selectors do not apply across namespace boundaries.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I donot think this is consistent with other API @howardjohn

Not a good idea to be inconsistent

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain what about it is inconsistent? My expectation is that this behaves the same way as every other Istio API that has a workload selector?

Copy link
Member

@hzxuzhonghu hzxuzhonghu Mar 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Workload selectors do not apply across namespace boundaries.

For gateway, the selector works across namespaces.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another point it from implement view: currently dr is used both fro outbound and inbound setting. Then if this only applies to the same namespace, does that mean we need to create two DRs for a service if the caller resides in different namespace as server?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hzxuzhonghu : implementation can be seen at : istio/istio#37174

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I donot see how to deal with the inconsistency

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is different from not only gateway. but also authorization policy

If the authorization policy is in the root namespace, the selector
	// will additionally match with workloads in all namespaces.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But not EnvoyFilter, Sidecar, Telemetry, ProxyConfig, WasmPlugin, PeerAuthentication, or Request Authentication.

Gateway was a mistake IMO - we do not do this cross namespace in the gateway-api and we have a flag to disable cross namespace for Istio gateway.

AuthzPolicy is the odd one out, not DR, IMO.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is very confusing and error-prone. What's the long-term plan? After upgrading API version, we should remove all this bad inconsistency

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two inconsistencies - Gateway and AuthzPolicy.

Gateway is mostly addressed as noted. The new API does not have these issues and the current one has a flag.

AuthzPolicy - we have started looking into changing it but there has been some push back https://docs.google.com/document/u/0/d/1sCA6ReTnAR5tyKwuc7KPMygv2UPOlxL6IEU8Og0nQm0/mobilebasic.

So we have a plan. In the mean time, this change is consistent with 7 other Istio APIs - including the 3 most recently added ones. It seems inconsistent and unfair to block this change for inconsistency when factoring this in.

What do you think? Is it ok to move forward with this? If not, do you have alternative ideas?

I am highly motivated to move forward with this as we are stretching @kfaseela 's - a new contributor who could become a major regular contributor - motivation very thin after months of work to put a hold on the last minute.

@ramaraochavali
Copy link
Contributor

But i think this will break backward compatibility. Before a DR without wokloadSelector, it would be applied to all namespaces.

But with this, without workloadSelector set, it will be applied to the same namespace

@kfaseela Is this correct? I thought there is no change in behaviour for the case of DR with no workload selector?

@kfaseela
Copy link
Member Author

But i think this will break backward compatibility. Before a DR without wokloadSelector, it would be applied to all namespaces.

But with this, without workloadSelector set, it will be applied to the same namespace

@kfaseela Is this correct? I thought there is no change in behaviour for the case of DR with no workload selector?

This is not correct. The namespace restriction is there only for workloadSelector set cases.

@kfaseela kfaseela deleted the egress-mtls-sidecar branch August 5, 2022 08:39
@pkgulati
Copy link

How to achieve workloadSelector for incoming traffic. I want to apply max connections limit using Destination Rule only on SERVER side of the service using istio proxy (side car).

@kfaseela
Copy link
Member Author

kfaseela commented Jan 9, 2023

@pkgulati : This was discussed under: istio/istio#41235

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants