Skip to content

Commit 154f5d3

Browse files
committed
docs(gateway-api): document custom backendRef and backend-specific filters for HTTPRoute
Signed-off-by: kahirokunn <okinakahiro@gmail.com>
1 parent 65b9c0a commit 154f5d3

File tree

1 file changed

+72
-3
lines changed

1 file changed

+72
-3
lines changed

docs/gitbook/tutorials/gatewayapi-progressive-delivery.md

Lines changed: 72 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,12 @@ When the canary analysis starts, Flagger will call the pre-rollout webhooks befo
242242
After a couple of seconds Flagger will create the canary objects:
243243

244244
```bash
245-
# applied
245+
# applied
246246
deployment.apps/podinfo
247247
horizontalpodautoscaler.autoscaling/podinfo
248248
canary.flagger.app/podinfo
249249

250-
# generated
250+
# generated
251251
deployment.apps/podinfo-primary
252252
horizontalpodautoscaler.autoscaling/podinfo-primary
253253
service/podinfo
@@ -404,7 +404,7 @@ While Flagger can perform weighted routing and A/B testing individually, with Ga
404404
release with session affinity.
405405
For more information you can read the [deployment strategies docs](../usage/deployment-strategies.md#canary-release-with-session-affinity).
406406

407-
> **Note:** The implementation must have support for the [`ResponseHeaderModifier`](https://github.com/kubernetes-sigs/gateway-api/blob/3d22aa5a08413222cb79e6b2e245870360434614/apis/v1beta1/httproute_types.go#L651) API.
407+
> **Note:** The implementation must have support for the [`ResponseHeaderModifier`](https://github.com/kubernetes-sigs/gateway-api/blob/3d22aa5a08413222cb79e6b2e245870360434614/apis/v1beta1/httproute_types.go#L651) API.
408408
409409
Create a canary custom resource \(replace www.example.com with your own domain\):
410410

@@ -728,3 +728,72 @@ With the above configuration, Flagger will run a canary release with the followi
728728
* send notification with the canary analysis result
729729
730730
The above procedures can be extended with [custom metrics](../usage/metrics.md) checks, [webhooks](../usage/webhooks.md), [manual promotion](../usage/webhooks.md#manual-gating) approval and [Slack or MS Teams](../usage/alerting.md) notifications.
731+
732+
## Custom backends and backend-specific filters (Gateway API)
733+
734+
Flagger can configure custom `backendRef` and backend-specific `filters` on the generated `HTTPRoute` when using the Gateway API provider. This allows you to:
735+
736+
* override the default `Service` backend with an arbitrary backend object reference
737+
* attach filters that are executed only when a specific backend is selected by routing (e.g., per-backend header modifiers)
738+
739+
This is controlled via `spec.service.primaryBackend` and `spec.service.canaryBackend` fields of the `Canary` resource. When set, Flagger will use these values to populate `rules[].backendRefs[]` for the primary and canary targets respectively.
740+
741+
Example:
742+
743+
```yaml
744+
apiVersion: flagger.app/v1beta1
745+
kind: Canary
746+
metadata:
747+
name: podinfo
748+
namespace: test
749+
spec:
750+
targetRef:
751+
apiVersion: apps/v1
752+
kind: Deployment
753+
name: podinfo
754+
service:
755+
port: 9898
756+
hosts:
757+
- www.example.com
758+
gatewayRefs:
759+
- name: gateway
760+
namespace: istio-ingress
761+
# Optional: override backends and add backend-specific filters
762+
primaryBackend:
763+
backendRef:
764+
group: ""
765+
kind: Service
766+
name: podinfo-primary
767+
port: 9898
768+
filters:
769+
- type: ResponseHeaderModifier
770+
responseHeaderModifier:
771+
add:
772+
- name: X-Primary-Backend
773+
value: "true"
774+
canaryBackend:
775+
backendRef:
776+
group: ""
777+
kind: Service
778+
name: podinfo-canary
779+
port: 9898
780+
filters:
781+
- type: ResponseHeaderModifier
782+
responseHeaderModifier:
783+
add:
784+
- name: X-Canary-Backend
785+
value: "true"
786+
analysis:
787+
interval: 1m
788+
threshold: 5
789+
maxWeight: 50
790+
stepWeight: 10
791+
```
792+
793+
Notes:
794+
795+
* Backend-specific filters attached via `primaryBackend.filters` and `canaryBackend.filters` are only evaluated when requests are forwarded to that particular backend.
796+
* If the backend references a cross-namespace resource, Flagger will automatically create and maintain `ReferenceGrant` objects to allow the `HTTPRoute` to reference it across namespaces.
797+
* You can continue to use route-level filters through the existing `service.headers`, `service.rewrite`, and `service.mirror` fields; those apply regardless of which backend is selected.
798+
799+
This feature is supported only with the Gateway API provider. Other providers ignore `primaryBackend` and `canaryBackend`.

0 commit comments

Comments
 (0)