Skip to content

Commit f639959

Browse files
author
Kate Osborn
committed
Update client and proxy settings policies
1 parent 321f7ae commit f639959

File tree

1 file changed

+43
-14
lines changed

1 file changed

+43
-14
lines changed

docs/proposals/nginx-extensions.md

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,15 @@ _Conformance Level_: Extended/Implementation-specific
303303

304304
_Example(s)_: [Envoy Gateway BackendTrafficPolicy](https://gateway.envoyproxy.io/v0.6.0/api/extension_types/#backendtrafficpolicy), [GKE HealthCheckPolicy](https://cloud.google.com/kubernetes-engine/docs/how-to/configure-gateway-resources), [BackendTLSPolicy](https://gateway-api.sigs.k8s.io/api-types/backendtlspolicy/)
305305

306-
Policies are a Kubernetes object that augments the behavior of an object in a standard way. Policies can be attached to one object ("Direct Policy Attachment") or objects in a hierarchy ("Inherited Policy Attachment"). In both cases, Policies are implemented as CRDs, and they must include a _single_ `TargetRef` struct in the `spec` to identify how and where to apply the Policy. This `TargetRef` can include a `sectionName` to target specific matches within nested objects, such as a Listener within a Gateway or a specific Port on a Service.
306+
Policies are a Kubernetes object that augments the behavior of an object in a standard way. Policies can be attached to one object ("Direct Policy Attachment") or objects in a hierarchy ("Inherited Policy Attachment"). In both cases, Policies are implemented as CRDs, and they must include a _single_ `TargetRef` struct in the `spec` to identify how and where to apply the Policy. The Policy GEP _may_ be extended to supported multiple `TargetRefs` and/or label selectors.
307+
308+
Policies do not need to support attaching to all resource Kinds. Implementations can choose which resources the Policy can be attached to.
309+
310+
#### Direct Policy Attachment
311+
312+
A Direct Policy Attachment is a Policy that references a single object -- such as a Gateway or HTTPRoute. It is tightly bound to one instance of a particular Kind within a single Namespace or an instance of a single Kind at the cluster-scope. It affects _only_ the object specified in its TargetRef.
313+
314+
A Direct Policy _may_ target a subsection of a resource using the `sectionName` field of the `targetRef`. This allows the Policy to target specific matches within nested objects, such as a Listener within a Gateway or a specific Port on a Service.
307315

308316
Example of a TargetRef that targets an entire Gateway:
309317

@@ -326,15 +334,9 @@ targetRef:
326334
namespace: default
327335
```
328336

329-
There's also an open [GEP issue](https://github.com/kubernetes-sigs/gateway-api/issues/995) to add a name field to HTTPRouteRule and HTTPRouteMatch structs to allow users to identify different routes. Once implemented, Policies can target a specific rule or match in an HTTPRoute. The Policy GEP _may_ be extended to supported multiple `TargetRefs` and/or label selectors.
330-
331-
Policies do not need to support attaching to all resource Kinds. Implementations can choose which resources the Policy can be attached to.
332-
333-
#### Direct Policy Attachment
334-
335-
A Direct Policy Attachment is a Policy that references a single object -- such as a Gateway or HTTPRoute. It is tightly bound to one instance of a particular Kind within a single Namespace or an instance of a single Kind at the cluster-scope. It only modifies the behavior of the object that it's bound to.
337+
There's also an open [GEP issue](https://github.com/kubernetes-sigs/gateway-api/issues/995) to add a name field to HTTPRouteRule and HTTPRouteMatch structs to allow users to identify different routes. Once implemented, Policies can target a specific rule or match in an HTTPRoute.
336338

337-
Example:
339+
The BackendTLSPolicy is an example of a Direct Policy Attachment:
338340

339341
```yaml
340342
apiVersion: gateway.networking.k8s.io/v1alpha2
@@ -355,7 +357,7 @@ spec:
355357
hostname: secure-app.example.com
356358
```
357359

358-
This BackendTLSPolicy is an example of a Direct Policy Attachment. It targets the `secure-app` Service in the `default` Namespace. The TLS configuration in the `backend-tls` Policy will be applied for all Routes that reference the `secure-app` Service.
360+
This example targets the `secure-app` Service in the `default` Namespace. The TLS configuration in the `backend-tls` Policy will be applied for all Routes that reference the `secure-app` Service.
359361

360362
When to use Direct Policy Attachment:
361363

@@ -445,6 +447,19 @@ Default values are given precedence from the bottom up. A default attached to a
445447

446448
Inherited Policies do not need to support policy attachment to each resource shown in the hierarchy. Implementations can choose which resources the Policy can attach to.
447449

450+
#### Direct or Indirect?
451+
452+
| Direct | Indirect |
453+
|-------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------|
454+
| Affects ONLY the object it targets | Affects more objects that the targeted object |
455+
| Requires no extra knowledge beyond the Policy and target object | Requires knowledge of resources other than the Policy and target object to understand the state of the system |
456+
| Does not include defaults or overrides | May include defaults and/or overrides |
457+
| Should only support attaching to a single Kind | Can support attaching to multiple Kinds |
458+
| May target a subsection of a resource using the `sectionName` field of the `targetRef` struct | Does not target a subsection of a resource |
459+
460+
461+
> If a Policy can be used as an Inherited Policy, it MUST be treated as an Inherited Policy, regardless of whether a specific instance of the Policy is only affecting a single object.
462+
448463
#### Challenges of Policy Attachment
449464

450465
_Status and the Discoverability problem_
@@ -687,7 +702,7 @@ _Resource type:_ CRD
687702

688703
_Role(s):_ Cluster Operator
689704

690-
_Extension point:_ Gateway, Gateway Listener, HTTPRoute
705+
_Extension point:_ Gateway, HTTPRoute
691706

692707
_NGINX context(s)_: http, server, location
693708

@@ -705,15 +720,22 @@ NGINX directives:
705720
- [`keepalive_timeout`](https://nginx.org/en/docs/http/ngx_http_core_module.html#keepalive_timeout)
706721
- [`keepalive_disable`](https://nginx.org/en/docs/http/ngx_http_core_module.html#keepalive_disable)
707722

708-
These features are grouped because they all deal with client traffic. An Inherited Policy fits this group best because there is a use case where the Cluster Operator sets a sane default for client max body size or client keepalives that has to be overridden by an Application Developer because of the unique attributes of the Service they own.
723+
These features are grouped because they all deal with client traffic.
724+
725+
An Inherited Policy fits this group best for the following reasons:
726+
727+
- A Cluster Operator may want to set defaults for client max body size or client keepalives.
728+
- An Application Developer may want to override these defaults because of the unique attributes of their applications.
729+
- Since these settings are available in the http, server, and location contexts, there is already inheritance involved. For example, setting the client max body size in the http context, sets the client max body size of all the servers and locations. While setting the client max body size of server `example.com` will override the size set in the http context.
730+
- If this policy is applied to a Gateway is will affect all the Routes attached to the Gateway, which is one of the traits of an Inherited Policy.
709731

710732
#### Future Work
711733

712734
- Can add support for more `client_*` directives: `client_body_buffer_size`, `client_header_buffer_size`, etc.
713735

714736
#### Alternatives
715737

716-
- Direct Policy: A Direct Policy isn't a good fit for client settings because it does not support overrides and defaults.
738+
- Direct Policy: A Direct Policy isn't a good fit because the NGINX directives included in this policy are available at the http, server, and location contexts. NGINX's inheritance behavior among these contexts does not suit Direct Policy attachment. A client settings policy attached to a Gateway will affect all the Routes attached to the Gateway. This violates the Direct Policy requirement that the policy should only affect the object it attaches to. If we only support attaching this policy to an HTTPRoute, we could use a Direct Policy. However, we want to allow the Cluster Operator to configure defaults for these client settings, which means we need to support attaching to Gateways as well as HTTPRoutes.
717739

718740
### Upstream Settings
719741

@@ -863,7 +885,7 @@ _Resource type:_ CRD
863885

864886
_Role(s):_ Cluster Operator, Application Developer
865887

866-
_Extension point:_ Gateway, HTTPRoute, HTTPRoute Rule
888+
_Extension point:_ Gateway, HTTPRoute
867889

868890
_NGINX context(s):_ http, server, location
869891

@@ -883,6 +905,13 @@ NGINX directives:
883905
- [`proxy_next_upstream_retries`](https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_next_upstream_tries)
884906
- [`proxy_buffering`](https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_buffering)
885907

908+
An Inherited Policy fits this group best for the following reasons (same reasons as [Client Settings](#client-settings):
909+
910+
- A Cluster Operator may want to set defaults for proxy settings.
911+
- An Application Developer may want to override these defaults because of the unique attributes of their application.
912+
- Since these settings are available in the http, server, and location contexts, there is already inheritance involved. For example, setting the proxy connect timeout in the http context, sets the proxy connect timeout of all the servers and locations. While setting the proxy connect timeout of server `example.com` will override the size set in the http context.
913+
- If this policy is applied to a Gateway is will affect all the Routes attached to the Gateway, which is one of the traits of an Inherited Policy.
914+
886915
#### Future Work
887916

888917
- Add other `proxy_*` directives

0 commit comments

Comments
 (0)