Policy Attachment: Current PolicyTargetReference API limitations #1489
Replies: 2 comments 2 replies
-
I personally think the point is well made. There wasn't any end-user feedback that played into this desire for match targets, was there?
It would seem to me the main one that you already touched on is to make separate routes, as this helps with the downsides of the I think one of the things I worry most about policy attachment is how opaque it can feel from the end-user perspective, and yet how incredibly relevant it can be to their experience. At least with whole object attachment, it can be fairly simple to understand where a policy applies. With The way we're heading right now, a single For instance, if you have a policy which provides fields A, B then attach it to a Gateway with a override for B, and then attach two other instance of that policy directly to the There's a growing part of me that really wants to see the "effective policy" for any (by the way, this is a really great topic thanks for bringing it up) |
Beta Was this translation helpful? Give feedback.
-
Just to add another reference, we have a small project called Kuadrant, that is attempting to model rate limiting and auth as policy attachment resources using our own Auth and Rate Limiting services. Quite early on we found there was difficulty with policy attachment and HTTPRoute in the way described above (wanting to target a specific rule). |
Beta Was this translation helpful? Give feedback.
-
The PolicyTargetReference API currently lets us specify a whole resource to target with configuration in a custom Policy resource.
Using this for example to set a rate limit policy, we can apply Policies to different resources e.g. Gateways and HTTPRoutes to allow an operator and app owner to set defaults/overrides as they see fit. This example spike in Contour shows this with some example configuration YAMLs: projectcontour/contour#4776
However, it still feels like the PolicyTargetReference API is limited in a few scenarios that cause users to have to split configuration between multiple resources. This can in some cases just cause clutter or extra places for users to look for configuration updates/status, but in others actually mean the API doesn't work as intended.
Applying a Policy to an individual route rule
Since PolicyTargetReference only allows us to currently apply a Policy to whole resource we have to split route rules between different HTTPRoutes to target an individual route. The YAML provided in the Contour spike shows this. The
/api/needs-ratelimit
path match rule must be separated into its own HTTPRoute with a policy targeting only that resource. While the API is flexible enough to allow us to achieve the intended goal, it comes at the cost of duplication of the form (as I understand it) Gateway API is intended to do away with.Applying a Policy to a whole virtualhost
Say we want to apply a Policy to foo-prod.com and a different Policy to foo-dev.com. This could be an authorization Policy, rate limit Policy, etc. This could be done in a few ways, depending on how your organization sets up configuration:
For the first option, to apply separate Policies to foo-prod.com and foo-dev.com at the Gateway level, we would need to separate the Listeners into different Gateway resources. This has implications for many implementations, since the idea of merging Gateways is not super well defined. For example Contour does not merge Gateways at the moment and each Gateway requires a separate Contour controller and data-plane.
For the second option, we could either:
Solutions
With the ability to apply policies to sections of a resource, these limitations would appear to be mitigated. We would be able to target sections of a Gateway or Route to apply a Policy to. This would mean we don't restrict how organizations have to organize their resources as we would offer maximum flexibility.
Discussion questions/topics
Beta Was this translation helpful? Give feedback.
All reactions