44
55** API Version:** v1alpha3-WD
66
7- ** Compatible With:** specs.smi-spec.io/v1alpha4-WD
7+ ** Compatible with:** specs.smi-spec.io/v1alpha4-WD
8+
9+ ## Specification
810
911This set of resources allows users to define access control policy for their
1012applications. It is the authorization side of the picture. Authentication should
@@ -13,8 +15,6 @@ already be handled by the underlying implementation and surfaced through a subje
1315Access control in this specification is additive, all traffic is denied by default.
1416See [ tradeoffs] ( #tradeoffs ) for a longer discussion about why.
1517
16- ## Specification
17-
1818### TrafficTarget
1919
2020A ` TrafficTarget ` associates a set of traffic definitions (rules) with a
@@ -43,6 +43,14 @@ To understand how this all fits together, first define the routes for some
4343traffic.
4444
4545``` yaml
46+ kind : TCPRoute
47+ metadata :
48+ name : the-routes
49+ spec :
50+ matches :
51+ ports :
52+ - 8080
53+ ---
4654kind : HTTPRouteGroup
4755metadata :
4856 name : the-routes
7280 kind: ServiceAccount
7381 name: service-a
7482 namespace: default
75- port: 8080
7683 rules:
84+ - kind: TCPRoute
85+ name: the-routes
7786 - kind: HTTPRouteGroup
7887 name: the-routes
7988 matches:
@@ -88,8 +97,9 @@ This example selects all the pods which have the `service-a` `ServiceAccount`.
8897Traffic destined on a path `/metrics` is allowed. The `matches` field is
8998optional and if omitted, a rule is valid for all the matches in a traffic spec
9099(a OR relationship). It is possible for a service to expose multiple ports,
91- the `port` field allows the user to specify specifically which port traffic
92- should be allowed on. `port` is an optional element, if not specified, traffic
100+ the TCPRoute/UDPRoute `matches.ports` field allows the user to specify
101+ specifically which port traffic should be allowed on.
102+ The `matches.ports` is an optional element, if not specified, traffic
93103will be allowed to all ports on the destination service.
94104
95105Allowing destination traffic should only be possible with permission of the
@@ -106,13 +116,21 @@ Source identities which are allowed to connect to the destination is defined in
106116the sources list. Only pods which have a `ServiceAccount` which is named in
107117the sources list are allowed to connect to the destination.
108118
109- # # Example Implementation
119+ # # Example implementation for L7
110120
111121The following implementation shows four services api, website, payment and
112122prometheus. It shows how it is possible to write fine grained TrafficTargets
113123which allow access to be controlled by route and source.
114124
115125` ` ` yaml
126+ kind: TCPRoute
127+ metadata:
128+ name: api-service-port
129+ spec:
130+ matches:
131+ ports:
132+ - 8080
133+ ---
116134kind: HTTPRouteGroup
117135metadata:
118136 name: api-service-routes
@@ -135,6 +153,8 @@ spec:
135153 name: api-service
136154 namespace: default
137155 rules:
156+ - kind: TCPRoute
157+ name: api-service-port
138158 - kind: HTTPRouteGroup
139159 name: api-service-routes
140160 matches:
@@ -153,8 +173,9 @@ spec:
153173 kind: ServiceAccount
154174 name: api-service
155175 namespace: default
156- port: 8080
157176 rules:
177+ - kind: TCPRoute
178+ name: api-service-port
158179 - kind: HTTPRouteGroup
159180 name: api-service-routes
160181 matches:
@@ -176,6 +197,53 @@ The previous example would allow the following HTTP traffic:
176197| payments-service | api-service | /api | * |
177198| prometheus | api-service | /metrics | GET |
178199
200+ # # Example implementation for L4
201+
202+ The following implementation shows how to define TrafficTargets for
203+ allowing TCP and UDP traffic to specific ports.
204+
205+ ` ` ` yaml
206+ kind: TCPRoute
207+ metadata:
208+ name: tcp-ports
209+ spec:
210+ matches:
211+ ports:
212+ - 8301
213+ - 8302
214+ - 8300
215+ ---
216+ kind: UDPRoute
217+ metadata:
218+ name: udp-ports
219+ spec:
220+ matches:
221+ ports:
222+ - 8301
223+ - 8302
224+ ---
225+ kind: TrafficTarget
226+ metadata:
227+ name: protocal-specific
228+ spec:
229+ destination:
230+ kind: ServiceAccount
231+ name: server
232+ namespace: default
233+ rules:
234+ - kind: TCPRoute
235+ name: tcp-ports
236+ - kind: UDPRoute
237+ name: udp-ports
238+ sources:
239+ - kind: ServiceAccount
240+ name: client
241+ namespace: default
242+ ` ` `
243+
244+ Note that the above configuration will allow TCP and UDP traffic to
245+ both `8301` and `8302` ports, but will block UDP traffic to `8300`.
246+
179247# # Tradeoffs
180248
181249* Additive policy - policy that denies instead of only allows is valuable
0 commit comments