Skip to content
This repository was archived by the owner on Oct 20, 2023. It is now read-only.

Commit 8008055

Browse files
committed
Add TCP/UDP routes to access/v1alpha3
Replace 'destination.port' with TCP/UDPRoute 'matches.ports' Signed-off-by: stefanprodan <[email protected]>
1 parent 894612a commit 8008055

File tree

1 file changed

+73
-6
lines changed

1 file changed

+73
-6
lines changed

apis/traffic-access/traffic-access-WD.md

+73-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
**API Version:** v1alpha3-WD
66

7-
**Compatible With:** specs.smi-spec.io/v1alpha3
7+
**Compatible With:** specs.smi-spec.io/v1alpha4
88

99
This set of resources allows users to define access control policy for their
1010
applications. It is the authorization side of the picture. Authentication should
@@ -40,6 +40,14 @@ To understand how this all fits together, first define the routes for some
4040
traffic.
4141

4242
```yaml
43+
kind: TCPRoute
44+
metadata:
45+
name: the-routes
46+
spec:
47+
matches:
48+
ports:
49+
- 8080
50+
---
4351
kind: HTTPRouteGroup
4452
metadata:
4553
name: the-routes
@@ -69,8 +77,9 @@ spec:
6977
kind: ServiceAccount
7078
name: service-a
7179
namespace: default
72-
port: 8080
7380
rules:
81+
- kind: TCPRoute
82+
name: the-routes
7483
- kind: HTTPRouteGroup
7584
name: the-routes
7685
matches:
@@ -85,8 +94,8 @@ This example selects all the pods which have the `service-a` `ServiceAccount`.
8594
Traffic destined on a path `/metrics` is allowed. The `matches` field is
8695
optional and if omitted, a rule is valid for all the matches in a traffic spec
8796
(a OR relationship). It is possible for a service to expose multiple ports,
88-
the `port` field allows the user to specify specifically which port traffic
89-
should be allowed on. `port` is an optional element, if not specified, traffic
97+
the TCPRoute/UDPRoute `matches.ports` field allows the user to specify specifically which port traffic
98+
should be allowed on. The `matches.ports` is an optional element, if not specified, traffic
9099
will be allowed to all ports on the destination service.
91100

92101
Allowing destination traffic should only be possible with permission of the
@@ -103,13 +112,21 @@ Source identities which are allowed to connect to the destination is defined in
103112
the sources list. Only pods which have a `ServiceAccount` which is named in
104113
the sources list are allowed to connect to the destination.
105114

106-
## Example Implementation
115+
## Example implementation for L7
107116

108117
The following implementation shows four services api, website, payment and
109118
prometheus. It shows how it is possible to write fine grained TrafficTargets
110119
which allow access to be controlled by route and source.
111120

112121
```yaml
122+
kind: TCPRoute
123+
metadata:
124+
name: api-service-port
125+
spec:
126+
matches:
127+
ports:
128+
- 8080
129+
---
113130
kind: HTTPRouteGroup
114131
metadata:
115132
name: api-service-routes
@@ -132,6 +149,8 @@ spec:
132149
name: api-service
133150
namespace: default
134151
rules:
152+
- kind: TCPRoute
153+
name: api-service-port
135154
- kind: HTTPRouteGroup
136155
name: api-service-routes
137156
matches:
@@ -150,8 +169,9 @@ spec:
150169
kind: ServiceAccount
151170
name: api-service
152171
namespace: default
153-
port: 8080
154172
rules:
173+
- kind: TCPRoute
174+
name: api-service-port
155175
- kind: HTTPRouteGroup
156176
name: api-service-routes
157177
matches:
@@ -173,6 +193,53 @@ The previous example would allow the following HTTP traffic:
173193
| payments-service | api-service | /api | * |
174194
| prometheus | api-service | /metrics | GET |
175195

196+
## Example implementation for L4
197+
198+
The following implementation how to define TrafficTargets for allowing TCP and UDP
199+
traffic to specific ports.
200+
201+
```yaml
202+
kind: TCPRoute
203+
metadata:
204+
name: tcp-ports
205+
spec:
206+
matches:
207+
ports:
208+
- 8301
209+
- 8302
210+
- 8300
211+
---
212+
kind: UDPRoute
213+
metadata:
214+
name: udp-ports
215+
spec:
216+
matches:
217+
ports:
218+
- 8301
219+
- 8302
220+
---
221+
kind: TrafficTarget
222+
metadata:
223+
name: protocal-specific
224+
spec:
225+
destination:
226+
kind: ServiceAccount
227+
name: server
228+
namespace: default
229+
rules:
230+
- kind: TCPRoute
231+
name: tcp-ports
232+
- kind: UDPRoute
233+
name: udp-ports
234+
sources:
235+
- kind: ServiceAccount
236+
name: client
237+
namespace: default
238+
```
239+
240+
Note that the above configuration will allow TCP and UDP traffic to both `8301` and `8302` ports,
241+
but will block UDP traffic to `8300`.
242+
176243
## Tradeoffs
177244

178245
* Additive policy - policy that denies instead of only allows is valuable

0 commit comments

Comments
 (0)