Commit 9b35db1
authored
feature: Add support to opt-out from zone aware routing via Ingress/RouteGroup (#4049)
Introduce the annotation `zalando.org/traffic-zone-aware: "false"` on
Ingress and RouteGroup resources. When set, the resource receives all
endpoints across all zones, bypassing zone filtering both at the
dataclient layer (endpoint fetch) and at the routesrv layer (per-zone
route serving).
Usage:
```
metadata:
annotations:
zalando.org/traffic-zone-aware: "false"
```
Tasks
1. Define `zalando.org/traffic-zone-aware` annotation constant in the
kubernetes package
2. Modify `GetEndpointSlicesByService` and `GetEndpointSlicesByTarget`
in `clusterstate.go` to accept ing and rg context param respectively and
skip zone filtering when value
ing.disableZoneAwareness/rg.disableZoneAwareness is true
3. Add zoneAwarenessAnnotationFilter() helper that returns an annotate()
filter when the zone-aware opt-out annotation is present
4. Modify Ingress v1 path rule conversion (`convertPathRuleV1`) and
default backend conversion (`convertDefaultBackendV1`) to read the
annotation, pass it to endpoint fetch and prepend the annotate() filter
when annotation is set
5. Modify RouteGroup backend application (`applyServiceBackend`) to read
the annotation, pass it to endpoint fetch and prepend the annotate()
filter when annotation is set
6. Add isZoneAwarenessDisabled() in routesrv/polling.go to detect the
opt-out by inspecting the route filter chain
7. Wire isZoneAwarenessDisabled() into getRouteForZone() to skip zone
filtering for opted-out routes
8. Update makeRoute test helper to inject the annotate() filter when the
opt-out flag is passed
9. Add integration test with two Ingresses in zone `eu-central-1a`: one
opted out (expects all endpoints across zones), one default (expects
only zone-local endpoints)
10. Add unit tests for `filterRoutesByZone` covering opt-out scenarios:
both routes opted out, opt-out mixed with normal route, and opt-out with
a below-threshold zone
Tested the changes:
The skipper-ingress with zone aware routing enabled was in Zone-A
1. Deployed ingress with 10 replicas, which means 10 endpoints are
available
```
zkubectl -n gmapp1 get pods -L topology.kubernetes.io/zone
NAME READY STATUS RESTARTS AGE ZONE
app1-v8-5c5965f6d4-7h6zr 1/1 Running 0 69s eu-central-1a
app1-v8-5c5965f6d4-7tnq4 1/1 Running 0 68s eu-central-1a
app1-v8-5c5965f6d4-98mz7 1/1 Running 0 68s eu-central-1c
app1-v8-5c5965f6d4-99n9p 1/1 Running 0 69s eu-central-1c
app1-v8-5c5965f6d4-bvdst 1/1 Running 0 69s eu-central-1a
app1-v8-5c5965f6d4-htn78 1/1 Running 0 68s eu-central-1b
app1-v8-5c5965f6d4-q75b9 1/1 Running 0 69s eu-central-1b
app1-v8-5c5965f6d4-wtgm5 1/1 Running 0 69s eu-central-1a
app1-v8-5c5965f6d4-xhv9q 1/1 Running 0 69s eu-central-1c
app1-v8-5c5965f6d4-zlz9x 1/1 Running 0 69s eu-central-1b
```
This meets the threshold to serve same zone endpoints, but since the
ingress has the opt-out annotation, the route contains all the endpoints
and not just zone filtered
```
kube_gmapp1__app1_v8_traffic_segment__gmapp1_pg9_test_zalan_do____app1_v8: Host(/^(gmapp1[.]pg9-test[.]zalan[.]do[.]?(:[0-9]+)?)$/) && TrafficSegment(0, 1)
-> disableAccessLog(2, 3, 404, 429)
-> fifo(2000, 20, "1s")
-> annotate("zalando.org/traffic-zone-aware", "false")
-> oauthTokeninfoValidate("{optOutAnnotations: [iam.zalando.org/public], optOutHosts: [\"^.*[.]ingress[.]cluster[.]local\"], unauthorizedResponse: \"Authentication required, see https://cloud.docs.zalando.net/howtos/authenticate-requests/#default-authentication\\n\"}")
-> stateBagToTag("auth-user", "client.uid")
-> <powerOfRandomNChoices, "http://[2a05:d024:90:1103:3e99::6]:8080", "http://[2a05:d024:90:1103:3e99::7]:8080", "http://[2a05:d024:90:1103:3e99::8]:8080", "http://[2a05:d024:90:1103:3e99::9]:8080", "http://[2a05:d024:90:1104:2396::a]:8080", "http://[2a05:d024:90:1104:2396::b]:8080", "http://[2a05:d024:90:1104:2396::c]:8080", "http://[2a05:d024:90:1105:4749::4]:8080", "http://[2a05:d024:90:1105:4749::6]:8080", "http://[2a05:d024:90:1105:4749::7]:8080">;
```
2. Deployed a routegroup with 15 replicas, which means 15 endpoints are
available
```
zkubectl -n gmapp2 get pods -L topology.kubernetes.io/zone
NAME READY STATUS RESTARTS AGE ZONE
app2-v2-c9694944-598mc 1/1 Running 0 7m6s eu-central-1c
app2-v2-c9694944-6bcpm 1/1 Running 0 7m6s eu-central-1c
app2-v2-c9694944-7jgpp 1/1 Running 0 7m7s eu-central-1b
app2-v2-c9694944-88xzb 1/1 Running 0 7m7s eu-central-1a
app2-v2-c9694944-8kl6q 1/1 Running 0 7m6s eu-central-1c
app2-v2-c9694944-8wc97 1/1 Running 0 7m7s eu-central-1c
app2-v2-c9694944-cv9g8 1/1 Running 0 7m7s eu-central-1c
app2-v2-c9694944-dkh2h 1/1 Running 0 7m6s eu-central-1a
app2-v2-c9694944-flnx9 1/1 Running 0 7m6s eu-central-1a
app2-v2-c9694944-klk6r 1/1 Running 0 7m7s eu-central-1a
app2-v2-c9694944-kwddv 1/1 Running 0 7m6s eu-central-1b
app2-v2-c9694944-pjbtz 1/1 Running 0 7m6s eu-central-1a
app2-v2-c9694944-q5xrh 1/1 Running 0 7m7s eu-central-1b
app2-v2-c9694944-rs8hk 1/1 Running 0 7m7s eu-central-1a
app2-v2-c9694944-t6crt 1/1 Running 0 7m6s eu-central-1b
```
This meets the threshold to serve same zone endpoints, but since the
routegroup has the opt-out annotation, the route contains all the
endpoints and not just zone filtered
```
kube_rg__gmapp2__app2_v2_traffic_segment__get__0_0: Path("/test") && Host(/^(app2[.]teapot[.]zalan[.]do[.]?(:[0-9]+)?)$/) && Method("GET") && TrafficSegment(0, 1)
-> disableAccessLog(2, 3, 404, 429)
-> fifo(2000, 20, "1s")
-> annotate("zalando.org/traffic-zone-aware", "false")
-> annotate("iam.zalando.org/public", "The application uses its own authentication logic, similar to using Partner IAM.")
-> status(200)
-> inlineContent("Hello from second backend!")
-> oauthTokeninfoValidate("{optOutAnnotations: [iam.zalando.org/public], optOutHosts: [\"^.*[.]ingress[.]cluster[.]local\"], unauthorizedResponse: \"Authentication required, see https://cloud.docs.zalando.net/howtos/authenticate-requests/#default-authentication\\n\"}")
-> stateBagToTag("auth-user", "client.uid")
-> <powerOfRandomNChoices, "http://[2a05:d024:90:1103:3e99::10]:8080", "http://[2a05:d024:90:1103:3e99::11]:8080", "http://[2a05:d024:90:1103:3e99::12]:8080", "http://[2a05:d024:90:1103:3e99::13]:8080", "http://[2a05:d024:90:1103:3e99::14]:8080", "http://[2a05:d024:90:1103:3e99::f]:8080", "http://[2a05:d024:90:1104:2396::10]:8080", "http://[2a05:d024:90:1104:2396::d]:8080", "http://[2a05:d024:90:1104:2396::e]:8080", "http://[2a05:d024:90:1104:2396::f]:8080", "http://[2a05:d024:90:1105:4749::8]:8080", "http://[2a05:d024:90:1105:4749::9]:8080", "http://[2a05:d024:90:1105:4749::a]:8080", "http://[2a05:d024:90:1105:4749::b]:8080", "http://[2a05:d024:90:1105:4749::c]:8080">;
```
ref: #3971
---------
Signed-off-by: greeshma1196 <greeshma.mathew@gmail.com>1 parent 048c71b commit 9b35db1
15 files changed
Lines changed: 548 additions & 41 deletions
File tree
- dataclients/kubernetes
- testdata
- ingressV1/zone-aware-traffic
- routegroups/zone-aware-traffic
- routesrv
- testdata/zone-aware-traffic
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
108 | 112 | | |
109 | 113 | | |
110 | 114 | | |
| |||
167 | 171 | | |
168 | 172 | | |
169 | 173 | | |
170 | | - | |
| 174 | + | |
171 | 175 | | |
172 | 176 | | |
173 | 177 | | |
| |||
192 | 196 | | |
193 | 197 | | |
194 | 198 | | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
195 | 203 | | |
196 | 204 | | |
197 | 205 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
51 | 53 | | |
52 | 54 | | |
53 | 55 | | |
| |||
270 | 272 | | |
271 | 273 | | |
272 | 274 | | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
273 | 285 | | |
274 | 286 | | |
275 | 287 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
128 | | - | |
| 128 | + | |
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| |||
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
182 | 186 | | |
183 | 187 | | |
184 | 188 | | |
| |||
407 | 411 | | |
408 | 412 | | |
409 | 413 | | |
410 | | - | |
| 414 | + | |
411 | 415 | | |
412 | 416 | | |
413 | 417 | | |
| |||
454 | 458 | | |
455 | 459 | | |
456 | 460 | | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
457 | 465 | | |
458 | 466 | | |
459 | 467 | | |
| |||
482 | 490 | | |
483 | 491 | | |
484 | 492 | | |
485 | | - | |
486 | | - | |
487 | | - | |
488 | | - | |
489 | | - | |
490 | | - | |
491 | | - | |
492 | | - | |
493 | | - | |
494 | | - | |
495 | | - | |
496 | | - | |
497 | | - | |
498 | | - | |
499 | | - | |
500 | | - | |
501 | | - | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
502 | 511 | | |
503 | 512 | | |
504 | 513 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
178 | 179 | | |
179 | 180 | | |
180 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
181 | 186 | | |
182 | 187 | | |
183 | 188 | | |
| |||
197 | 202 | | |
198 | 203 | | |
199 | 204 | | |
200 | | - | |
| 205 | + | |
| 206 | + | |
201 | 207 | | |
202 | 208 | | |
203 | 209 | | |
| |||
597 | 603 | | |
598 | 604 | | |
599 | 605 | | |
| 606 | + | |
600 | 607 | | |
601 | 608 | | |
602 | 609 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
Lines changed: 135 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
0 commit comments