Skip to content

Commit effffb2

Browse files
lexfreiclaude
andauthored
docs(gateway-api): clarify annotation placement (#5918)
Addresses #5901 Related: #4056 Add clear documentation on annotation placement for Gateway API sources to prevent confusion about which annotations go on Gateway vs Route resources. Changes: - Add Gateway API Annotation Placement section to annotations.md - Add Annotations section with examples to gateway-api.md - Include Cloudflare and AWS provider examples - Document common mistakes Per review feedback, compressed annotations.md section to minimal size: - Removed annotation placement matrix table - Removed YAML examples - Kept concise 2-line summary - Kept link to comprehensive documentation Co-authored-by: Claude <[email protected]>
1 parent 866afef commit effffb2

File tree

2 files changed

+117
-1
lines changed

2 files changed

+117
-1
lines changed

docs/annotations/annotations.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ The following table documents which sources support which annotations:
2727
[^1]: Unless the `--ignore-hostname-annotation` flag is specified.
2828
[^2]: Only behaves differently than `hostname` for `Service`s of type `ClusterIP` or `LoadBalancer`.
2929
[^3]: Also supported on `Pods` referenced from a headless `Service`'s `Endpoints`.
30-
[^4]: The annotation must be on the `Gateway`.
30+
[^4]: For Gateway API sources, annotation placement differs by type. See [Gateway API Annotation Placement](#gateway-api-annotation-placement) for details.
3131
[^5]: The annotation must be on the listener's `VirtualService`.
3232

3333
## external-dns.alpha.kubernetes.io/access
@@ -210,3 +210,13 @@ Specifies the set identifier for DNS records generated by the resource.
210210

211211
A set identifier differentiates among multiple DNS record sets that have the same combination of domain and type.
212212
Which record set or sets are returned to queries is then determined by the configured routing policy.
213+
214+
## Gateway API Annotation Placement
215+
216+
When using Gateway API sources (`gateway-httproute`, `gateway-grpcroute`, `gateway-tlsroute`, etc.), annotations
217+
are read from different resources: **Gateway resource** reads only `target` annotation, while **Route resources**
218+
(HTTPRoute, GRPCRoute, TLSRoute, etc.) read all other annotations (`hostname`, `ttl`, `controller`, and
219+
provider-specific annotations like `cloudflare-*`, `aws-*`, `scw-*`).
220+
221+
For more details and comprehensive examples, see the
222+
[Gateway API documentation](../sources/gateway-api.md#annotations).

docs/sources/gateway-api.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,112 @@ for HTTPRoutes and TLSRoutes by ExternalDNS, but it's _strongly_ recommended tha
3535
specs to provide all intended hostnames, since the Gateway that ultimately routes their
3636
requests/connections won't recognize additional hostnames from the annotation.
3737

38+
## Annotations
39+
40+
### Annotation Placement
41+
42+
ExternalDNS reads different annotations from different Gateway API resources:
43+
44+
- **Gateway annotations**: Only `external-dns.alpha.kubernetes.io/target` is read from Gateway resources
45+
- **Route annotations**: All other annotations (hostname, ttl, controller, provider-specific) are read from Route
46+
resources (HTTPRoute, GRPCRoute, TLSRoute, TCPRoute, UDPRoute)
47+
48+
This separation aligns with Gateway API architecture where Gateway defines infrastructure (IP addresses, listeners)
49+
and Routes define application-level DNS records.
50+
51+
### Examples
52+
53+
#### Example: Cloudflare Proxied Records
54+
55+
```yaml
56+
apiVersion: gateway.networking.k8s.io/v1
57+
kind: Gateway
58+
metadata:
59+
name: my-gateway
60+
namespace: default
61+
annotations:
62+
# ✅ Correct: target annotation on Gateway
63+
external-dns.alpha.kubernetes.io/target: "203.0.113.1"
64+
spec:
65+
gatewayClassName: cilium
66+
listeners:
67+
- name: https
68+
hostname: "*.example.com"
69+
protocol: HTTPS
70+
port: 443
71+
---
72+
apiVersion: gateway.networking.k8s.io/v1
73+
kind: HTTPRoute
74+
metadata:
75+
name: my-route
76+
annotations:
77+
# ✅ Correct: provider-specific annotations on HTTPRoute
78+
external-dns.alpha.kubernetes.io/cloudflare-proxied: "true"
79+
external-dns.alpha.kubernetes.io/ttl: "300"
80+
spec:
81+
parentRefs:
82+
- name: my-gateway
83+
namespace: default
84+
hostnames:
85+
- api.example.com
86+
rules:
87+
- backendRefs:
88+
- name: api-service
89+
port: 8080
90+
```
91+
92+
#### Example: AWS Route53 with Routing Policies
93+
94+
```yaml
95+
apiVersion: gateway.networking.k8s.io/v1
96+
kind: Gateway
97+
metadata:
98+
name: aws-gateway
99+
annotations:
100+
# ✅ Correct: target annotation on Gateway
101+
external-dns.alpha.kubernetes.io/target: "alb-123.us-east-1.elb.amazonaws.com"
102+
---
103+
apiVersion: gateway.networking.k8s.io/v1
104+
kind: HTTPRoute
105+
metadata:
106+
name: weighted-route
107+
annotations:
108+
# ✅ Correct: AWS-specific annotations on HTTPRoute
109+
external-dns.alpha.kubernetes.io/aws-weight: "100"
110+
external-dns.alpha.kubernetes.io/set-identifier: "backend-v1"
111+
spec:
112+
parentRefs:
113+
- name: aws-gateway
114+
hostnames:
115+
- app.example.com
116+
```
117+
118+
### Common Mistakes
119+
120+
❌ **Incorrect**: Placing provider-specific annotations on Gateway
121+
122+
```yaml
123+
kind: Gateway
124+
metadata:
125+
annotations:
126+
# ❌ These annotations are ignored on Gateway
127+
external-dns.alpha.kubernetes.io/cloudflare-proxied: "true"
128+
external-dns.alpha.kubernetes.io/ttl: "300"
129+
```
130+
131+
❌ **Incorrect**: Placing target annotation on HTTPRoute
132+
133+
```yaml
134+
kind: HTTPRoute
135+
metadata:
136+
annotations:
137+
# ❌ This annotation is ignored on Routes
138+
external-dns.alpha.kubernetes.io/target: "203.0.113.1"
139+
```
140+
141+
For a complete list of supported annotations, see the
142+
[annotations documentation](../annotations/annotations.md#gateway-api-annotation-placement).
143+
38144
## Manifest with RBAC
39145
40146
```yaml

0 commit comments

Comments
 (0)