4
4
5
5
** API Version:** v1alpha3-WD
6
6
7
- ** Compatible With:** specs.smi-spec.io/v1alpha3
7
+ ** Compatible With:** specs.smi-spec.io/v1alpha4
8
8
9
9
This set of resources allows users to define access control policy for their
10
10
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
40
40
traffic.
41
41
42
42
``` yaml
43
+ kind : TCPRoute
44
+ metadata :
45
+ name : the-routes
46
+ spec :
47
+ matches :
48
+ ports :
49
+ - 8080
50
+ ---
43
51
kind : HTTPRouteGroup
44
52
metadata :
45
53
name : the-routes
69
77
kind: ServiceAccount
70
78
name: service-a
71
79
namespace: default
72
- port: 8080
73
80
rules:
81
+ - kind: TCPRoute
82
+ name: the-routes
74
83
- kind: HTTPRouteGroup
75
84
name: the-routes
76
85
matches:
@@ -85,8 +94,8 @@ This example selects all the pods which have the `service-a` `ServiceAccount`.
85
94
Traffic destined on a path `/metrics` is allowed. The `matches` field is
86
95
optional and if omitted, a rule is valid for all the matches in a traffic spec
87
96
(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
90
99
will be allowed to all ports on the destination service.
91
100
92
101
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
103
112
the sources list. Only pods which have a `ServiceAccount` which is named in
104
113
the sources list are allowed to connect to the destination.
105
114
106
- # # Example Implementation
115
+ # # Example implementation for L7
107
116
108
117
The following implementation shows four services api, website, payment and
109
118
prometheus. It shows how it is possible to write fine grained TrafficTargets
110
119
which allow access to be controlled by route and source.
111
120
112
121
` ` ` yaml
122
+ kind: TCPRoute
123
+ metadata:
124
+ name: api-service-port
125
+ spec:
126
+ matches:
127
+ ports:
128
+ - 8080
129
+ ---
113
130
kind: HTTPRouteGroup
114
131
metadata:
115
132
name: api-service-routes
@@ -132,6 +149,8 @@ spec:
132
149
name: api-service
133
150
namespace: default
134
151
rules:
152
+ - kind: TCPRoute
153
+ name: api-service-port
135
154
- kind: HTTPRouteGroup
136
155
name: api-service-routes
137
156
matches:
@@ -150,8 +169,9 @@ spec:
150
169
kind: ServiceAccount
151
170
name: api-service
152
171
namespace: default
153
- port: 8080
154
172
rules:
173
+ - kind: TCPRoute
174
+ name: api-service-port
155
175
- kind: HTTPRouteGroup
156
176
name: api-service-routes
157
177
matches:
@@ -173,6 +193,53 @@ The previous example would allow the following HTTP traffic:
173
193
| payments-service | api-service | /api | * |
174
194
| prometheus | api-service | /metrics | GET |
175
195
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
+
176
243
# # Tradeoffs
177
244
178
245
* Additive policy - policy that denies instead of only allows is valuable
0 commit comments