File tree Expand file tree Collapse file tree 2 files changed +74
-0
lines changed Expand file tree Collapse file tree 2 files changed +74
-0
lines changed Original file line number Diff line number Diff line change 43
43
Note that the target Gateway needs to allow HTTPRoutes from the route's
44
44
namespace to be attached for the attachment to be successful.
45
45
46
+ You can also attach routes to specific sections of the parent resource.
47
+ For example, let's say that the ` acme-lb` Gateway includes the following
48
+ listeners :
49
+
50
+ ` ` ` yaml
51
+ listeners:
52
+ - name: foo
53
+ protocol: HTTP
54
+ port: 8080
55
+ ...
56
+ - name: bar
57
+ protocol: HTTP
58
+ port: 8090
59
+ ...
60
+ - name: baz
61
+ protocol: HTTP
62
+ port: 8090
63
+ ...
64
+ ` ` `
65
+
66
+ You can bind a route to listener `foo` only, using the `sectionName` field
67
+ in `parentRefs` :
68
+
69
+ ` ` ` yaml
70
+ spec:
71
+ parentRefs:
72
+ - name: acme-lb
73
+ sectionName: foo
74
+ ` ` `
75
+
76
+ Alternatively, you can achieve the same effect by using the `port` field,
77
+ instead of `sectionName`, in the `parentRefs` :
78
+
79
+ ` ` ` yaml
80
+ spec:
81
+ parentRefs:
82
+ - name: acme-lb
83
+ port: 8080
84
+ ` ` `
85
+
86
+ Binding to a port also allows you to attach to multiple listeners at once.
87
+ For example, binding to port `8090` of the `acme-lb` Gateway would be more
88
+ convenient than binding to the corresponding listeners by name :
89
+
90
+ ` ` ` yaml
91
+ spec:
92
+ parentRefs:
93
+ - name: acme-lb
94
+ sectionName: bar
95
+ - name: acme-lb
96
+ sectionName: baz
97
+ ` ` `
98
+
99
+ However, when binding Routes by port number, Gateway admins will no longer have
100
+ the flexibility to switch ports on the Gateway without also updating the Routes.
101
+ The approach should only be used when a Route should apply to a specific port
102
+ number as opposed to listeners whose ports may be changed.
103
+
46
104
# ## Hostnames
47
105
48
106
Hostnames define a list of hostnames to match against the Host header of the
Original file line number Diff line number Diff line change @@ -49,8 +49,24 @@ In this way each `TCPRoute` "attaches" itself to a different port on the
49
49
` Gateway` so that the service `my-foo-service` is taking traffic for port `8080`
50
50
from outside the cluster and `my-bar-service` takes the port `8090` traffic.
51
51
52
+ Note that you can achieve this same result by binding the Routes to the Gateway
53
+ listeners using the `port` field in the `parentRefs` :
54
+
55
+ ` ` ` yaml
56
+ spec:
57
+ parentRefs:
58
+ - name: my-tcp-gateway
59
+ port: 8080
60
+ ` ` `
61
+
62
+ Using the `port` field instead of `sectionName` for the attachment has the
63
+ downside of more tightly coupling the relationship between the Gateway and
64
+ its associated Routes. Refer to [Attaching to Gateways][attaching] for more
65
+ details.
66
+
52
67
[tcproute]:/reference/spec/#gateway.networking.k8s.io/v1alpha2.TCPRoute
53
68
[tcp]:https://datatracker.ietf.org/doc/html/rfc793
54
69
[httproute]:/reference/spec/#gateway.networking.k8s.io/v1alpha2.HTTPRoute
55
70
[gateway]:/reference/spec/#gateway.networking.k8s.io/v1alpha2.Gateway
56
71
[svc]:https://kubernetes.io/docs/concepts/services-networking/service/
72
+ [attaching]:/api-types/httproute/#attaching-to-gateways
You can’t perform that action at this time.
0 commit comments