Closed
Description
User stories
- As an App Dev I will want to manipulate headers at ingress. Either to add correlation IDs, provenance data, strip unnecessary headers, or yet another use case not foreseen or delineated here.
Background
Header manipulation is supported through the HTTPRouteFilterType == RequestHeaderModifier. The RequestHeaderModifier is declared as Core support for HTTPRouteRule objects, and Extended for HTTPBackendRef objects.
This story requires Core API support, i.e., HTTPBackendRef IS NOT required to complete this task.
See https://gateway-api.sigs.k8s.io/references/spec/#gateway.networking.k8s.io%2fv1beta1.HTTPHeaderFilter for further clarification.
Functional requirements
Normal functioning:
- Support set semantics:
- Add if not exists
- Overwrite if exists
- Support add semantics:
- Add if not exists
- Append value if exists
- Support remove semantics:
- Nothing if not exists
- Remove if exists
Edge cases
- Ensure that the NKG runs the webhook validaton code and reject HTTPRoutes with invalid values (see the Webhook validation cases below).
- Ensure that NGK further validates the value and reject any values that might cause NGINX to fail to reload or any malicious value.
Webhook validation cases:
- Ensures that RequestHeaderModifier is not configured more than once per rule (https://github.com/kubernetes-sigs/gateway-api/blob/7631139b1ea4beaf575a49f56c56aa26f1e11e22/apis/v1beta1/validation/httproute.go#L108)
- Ensures a header can only be in one action (https://github.com/kubernetes-sigs/gateway-api/blob/7631139b1ea4beaf575a49f56c56aa26f1e11e22/apis/v1beta1/validation/httproute.go#L301)
Acceptance criteria:
- implement the requirements
- update the docs https://github.com/nginxinc/nginx-kubernetes-gateway/blob/main/docs/gateway-api-compatibility.md
- add an example https://github.com/nginxinc/nginx-kubernetes-gateway/tree/main/examples
- ensure the feature can pass a test based on the conformance test https://github.com/kubernetes-sigs/gateway-api/blob/7631139b1ea4beaf575a49f56c56aa26f1e11e22/conformance/tests/httproute-request-header-modifier.go#L33
Aha! Link: https://nginx.aha.io/features/NKG-64