Skip to content

feat: EnvoyPatchPolicy API#1410

Merged
zirain merged 9 commits intoenvoyproxy:mainfrom
arkodg:envoypatchpolicy
Jun 6, 2023
Merged

feat: EnvoyPatchPolicy API#1410
zirain merged 9 commits intoenvoyproxy:mainfrom
arkodg:envoypatchpolicy

Conversation

@arkodg
Copy link
Copy Markdown
Contributor

@arkodg arkodg commented May 9, 2023

Relates to #24

@arkodg arkodg requested a review from a team as a code owner May 9, 2023 18:47
@arkodg arkodg force-pushed the envoypatchpolicy branch from f289864 to f084543 Compare May 9, 2023 18:50
@arkodg arkodg marked this pull request as draft May 9, 2023 18:52
@codecov
Copy link
Copy Markdown

codecov bot commented May 9, 2023

Codecov Report

Merging #1410 (b2133c5) into main (22bd06b) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main    #1410   +/-   ##
=======================================
  Coverage   61.40%   61.40%           
=======================================
  Files          79       79           
  Lines       11459    11459           
=======================================
  Hits         7036     7036           
  Misses       3962     3962           
  Partials      461      461           

@arkodg arkodg force-pushed the envoypatchpolicy branch from f084543 to 012f104 Compare May 9, 2023 18:58
@arkodg arkodg marked this pull request as ready for review May 10, 2023 00:46
@arkodg arkodg requested review from a team, LanceEa, Xunzhuo and qicz and removed request for a team May 10, 2023 00:46
@arkodg
Copy link
Copy Markdown
Contributor Author

arkodg commented May 10, 2023

cc @howardjohn @costinm in case you see any reuse/overlap w Istio w Gateway API

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This seems like it will tank performance. Each resource will need to be marshalled to json, patched, then unmarshalled (?).

When we used to do similar it was 90% CPU cost of Istio (which took a ton of cpu) on just json. And we were only doing marshalling, not the other 2 steps

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it won't be each resource, name of the resource here is mandatory, so we would need to find (guessing its O(N) based on

type XdsResources = map[resourcev3.Type][]types.Resource
) the specific resource and marshal + patch + unmarshal

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

picked json over proto because it has an RFC and more commonly used in the ecosystem (k8s, kustomize) and REST APIs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

thanks for outlining the CPU cost, we should quantity this performance hit and highlight it in docs

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

one note - I think you will need to import every single proto in envoy into the control plane. Unless you have some tricks. Istio does it - not too bad, but bloats the binary

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Also means you could never use non-upsteam extensions to envoy

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah we autogenerate and import today in the client side (egctl)
with this PR we will need to do it in server side too
https://github.com/envoyproxy/gateway/blob/main/internal/xds/extensions/extensions.gen.go

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍 one minor suggestion: don't import the v2 stuff. One less headache to deal with down the line... and in only sort of works IME

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

thanks, will rm them

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

raised #1442 to rm v2 imports

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@zhaohuabing I dont think we'll be able to handle your use case if we purely relied on protojson tooling

Copy link
Copy Markdown
Member

@zhaohuabing zhaohuabing Jun 4, 2023

Choose a reason for hiding this comment

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

It would be a headache for any user who adds their own custom filters to envoy since EG can't recognize the APIs of these filters.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I understand your sentiment, and it is something we should support, which can be tracked with a GH issue, for now, it doesnt require any changes to the API, or am I missing something ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, it's an implementation concern rather than API.

@howardjohn
Copy link
Copy Markdown

cc @howardjohn @costinm in case you see any reuse/overlap w Istio w Gateway API

I don't personally. Patching APIs are impossible to support, I don't think anything like this should be standardized in GW API

@arkodg
Copy link
Copy Markdown
Contributor Author

arkodg commented May 10, 2023

cc @howardjohn @costinm in case you see any reuse/overlap w Istio w Gateway API

I don't personally. Patching APIs are impossible to support, I don't think anything like this should be standardized in GW API

@howardjohn I was referring to a common Gateway Extension API across the projects.
Since Istio already has EnvoyFIlter, that should work along side Gateway APIs, patching in Istio is already covered :) but this API could move the spec into Gateway API nouns

qicz
qicz previously approved these changes May 11, 2023
Copy link
Copy Markdown
Member

@qicz qicz left a comment

Choose a reason for hiding this comment

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

looks good to me

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Given that we can already configure rate limiting using the native Envoy Gateway ratelimit API, I'd like to see some other examples:

  1. You have three different upstream services, each of which needs to use a specific certificate to originate TLS.

    • The current Gateway API doesn't have a lot of support for upstream TLS origination. There's ongoing work to support it natively, but until that's accepted, this would be a reasonable use for an extension mechanism.
    • Obviously you don't know the routes involved, you just know that you happen to have three upstream services that need certificates.
  2. You need to allow the HTTP listener, but not the HTTPS listener, to route traffic to the path prefix /.well-known/acme-challenge/ over to the my-acme-server Service. (Other traffic may arrive on the HTTP listener too, but that traffic should be unaffected.)

    • This is the path used by the HTTP-01 ACME challenge, which always arrives over HTTP and must not be redirected to HTTPS. If a vendor wants to do custom ACME work, this might be a thing they'd need to do.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

can you share some raw xds Config for the examples ?

Comment on lines 126 to 128
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This was pretty fascinating to read. I agree with the sentiment and I feel compelled to note that if even the author acknowledges that it must forever remain experimental because it's too fragile to promote to stable, we should all but certainly not implement this in the first place unless there's a truly compelling reason to do so. I haven't seen that yet.

@kflynn
Copy link
Copy Markdown
Contributor

kflynn commented May 11, 2023

@howardjohn writes:

I don't personally [see any overlap with utility for Istio]. Patching APIs are impossible to support, I don't think anything like this should be standardized in GW API

It's kind of rare for me to unequivocally agree with John (😉), but I do here. I'm extremely concerned with how support for this API would play out in the long term. Emissary used to offer a much more constrained capability to do something similar, and it caused us more than a few problems.

Copy link
Copy Markdown
Contributor

@kflynn kflynn left a comment

Choose a reason for hiding this comment

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

GitHub says I'm reviewing rather than just commenting, so, uh, OK. 🙂 I definitely want to see some more example uses, and I think we should probably further discuss in the Envoy Gateway meetings before proceeding.

Copy link
Copy Markdown
Member

@zhaohuabing zhaohuabing May 22, 2023

Choose a reason for hiding this comment

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

Does this imply that in order to apply a patch, a user need to know the absolute path of a listener/route/cluster from the configuration root?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes, they could easily add to the beginning using 0 or end using -.If they want to insert somewhere in the middle , they would need to rely on egctl to make sure their config works correctly. This experience is identical to kubectl patch e.g. https://gateway.envoyproxy.io/v0.4.0/user/secure-gateways.html#tls-certificates. This experience might not be extremely use friendly, but its based on a known RFC/spec and is not meant to be a common case

Copy link
Copy Markdown
Member

@zhaohuabing zhaohuabing May 22, 2023

Choose a reason for hiding this comment

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

"EnvoyPatch" seems clear enough to me. Do we need to add "Policy" here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

previous reviewers for the RateLimit feature had requested RateLimit to suffix with Filter so we could differentiate Filter and Policy

Copy link
Copy Markdown
Member

@zhaohuabing zhaohuabing May 22, 2023

Choose a reason for hiding this comment

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

Is there a "all" target or similar mechanism by which we can apply an EnvoyFilter to multiple targets? There might be scenarios multiple gateway resources need to be apply the same EnvoyFilters.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

prefer if we started off with 1:1 mappings, since policy attachment UX is already perceived as complex, the use case can be satisfied today by creating another identical PolicyAttachment and applying it to another TargetRef. In the future we could make TargetRef plural, note this definition is taken from upstream

@qicz qicz added kind/enhancement New feature or request area/api API-related issues labels May 26, 2023
@qicz qicz added the area/config Issues related to config management, e.g. Config Manager, Config Sources, etc. label May 26, 2023
@qicz qicz added this to the 0.5.0-rc1 milestone May 26, 2023
@arkodg arkodg mentioned this pull request May 29, 2023
@arkodg arkodg force-pushed the envoypatchpolicy branch from eda9e03 to 9d6ca36 Compare May 31, 2023 01:41
Arko Dasgupta added 8 commits May 31, 2023 11:21
Relates to envoyproxy#24

Signed-off-by: Arko Dasgupta <arko@tetrate.io>
Signed-off-by: Arko Dasgupta <arko@tetrate.io>
Signed-off-by: Arko Dasgupta <arko@tetrate.io>
Signed-off-by: Arko Dasgupta <arko@tetrate.io>
Signed-off-by: Arko Dasgupta <arko@tetrate.io>
Signed-off-by: Arko Dasgupta <arko@tetrate.io>
Signed-off-by: Arko Dasgupta <arko@tetrate.io>
Signed-off-by: Arko Dasgupta <arko@tetrate.io>
@arkodg
Copy link
Copy Markdown
Contributor Author

arkodg commented May 31, 2023

/retest

qicz

This comment was marked as duplicate.

Copy link
Copy Markdown
Member

@qicz qicz left a comment

Choose a reason for hiding this comment

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

LGTM

* This API will always be an experimental API and cannot be graduated into a stable API because Envoy Gateway cannot garuntee
* that the naming scheme for the generated resources names will not change across releases
* that the underlying Envoy Proxy API will not change across releases
* This API needs to be explicitly enabled using the [EnvoyGateway][] API
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I did not see the EnvoyGateway API changes ? Do I miss anything?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ive raised a separate issue to track this #1468

semantics.

## Design Decisions
* This API will only support a single `targetRef` and can bind to only a `Gateway` resource. This simplifies reasoning of how
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A EnvoyPatchPolicy can be only binded to one Gateway, right ? But can a Gateway be binded with multiple different EnvoyPatchPolicy APIs ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes, ive added a priority field with PolicyAttachment so user can optionally order the Policiies that are being bind to a Gateway

Copy link
Copy Markdown
Member

@Xunzhuo Xunzhuo left a comment

Choose a reason for hiding this comment

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

lgtm!

Copy link
Copy Markdown
Member

@zhaohuabing zhaohuabing left a comment

Choose a reason for hiding this comment

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

LGTM

@zirain zirain merged commit 9fedf7d into envoyproxy:main Jun 6, 2023
@arkodg arkodg mentioned this pull request Jun 6, 2023
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/api API-related issues area/config Issues related to config management, e.g. Config Manager, Config Sources, etc. kind/enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants