-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
validator: make sure Ingress/RouteGroup doesn't have duplicate hosts (#…
…2753) Signed-off-by: Mustafa Abdelrahman <[email protected]>
- Loading branch information
1 parent
cb7d01c
commit 6c33066
Showing
13 changed files
with
168 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
cmd/webhook/admission/testdata/ingress/invalid-ingress-with-duplicate-hosts.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"request": { | ||
"uid": "req-uid", | ||
"name": "req1", | ||
"namespace": "n1", | ||
"object": { | ||
"metadata": { | ||
"name": "ing1", | ||
"namespace": "ing1", | ||
"annotations": { | ||
"zalando.org/skipper-filter": "status(200) -> inlineContent(\"This should work\")", | ||
"zalando.org/skipper-predicate": "Header(\"test\", \"test\") && Path(\"/login\")", | ||
"zalando.org/skipper-routes": "r1: Header(\"test2\", \"test2\") && Path(\"/login\") -> status(200) -> \"http://foo.test\"" | ||
} | ||
}, | ||
"spec": { | ||
"rules": [ | ||
{ | ||
"host": "example.com", | ||
"http": { | ||
"paths": [ | ||
{ | ||
"backend": { | ||
"service": { | ||
"name": "example-service", | ||
"port": { | ||
"number": 80 | ||
} | ||
} | ||
}, | ||
"path": "/", | ||
"pathType": "Prefix" | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
cmd/webhook/admission/testdata/rg/rg-with-duplicate-hosts.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"request": { | ||
"uid": "req-uid", | ||
"name": "req1", | ||
"namespace": "n1", | ||
"object": { | ||
"metadata": { | ||
"name": "rg1", | ||
"namespace": "n1" | ||
}, | ||
"spec": { | ||
"backends": [ | ||
{ | ||
"name": "backend", | ||
"type": "shunt" | ||
} | ||
], | ||
"defaultBackends": [ | ||
{ | ||
"backendName": "backend" | ||
} | ||
], | ||
"hosts": [ | ||
"example.org", | ||
"example.com", | ||
"example.org" | ||
] | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
dataclients/kubernetes/definitions/testdata/validation/route-with-duplicate-hosts.log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
duplicate host \\\"example\.org\\\" |
28 changes: 28 additions & 0 deletions
28
dataclients/kubernetes/definitions/testdata/validation/route-with-duplicate-hosts.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
apiVersion: zalando.org/v1 | ||
kind: RouteGroup | ||
metadata: | ||
name: test-route-group | ||
spec: | ||
hosts: | ||
- example.org | ||
- example.org | ||
- example.com | ||
backends: | ||
- name: app | ||
type: service | ||
serviceName: app-svc | ||
servicePort: 80 | ||
defaultBackends: | ||
- backendName: app | ||
routes: | ||
- path: / | ||
methods: | ||
- GET | ||
- HEAD | ||
predicates: | ||
- Foo("X-Bar", "42") | ||
filters: | ||
- foo(42) | ||
- bar(24) | ||
backends: | ||
- backendName: app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +0,0 @@ | ||
kube_rg__default__myapp__all__0_0: | ||
Host("^(app[.]example[.]org[.]?(:[0-9]+)?|example[.]org[.]?(:[0-9]+)?)$") | ||
&& Path("/app") | ||
-> <roundRobin, "http://10.2.4.8:80", "http://10.2.4.16:80">; | ||
|
||
kube_rg____app_example_org__catchall__0_0: Host("^(app[.]example[.]org[.]?(:[0-9]+)?)$") -> <shunt>; | ||
kube_rg____example_org__catchall__0_0: Host("^(example[.]org[.]?(:[0-9]+)?)$") -> <shunt>; | ||
1 change: 1 addition & 0 deletions
1
dataclients/kubernetes/testdata/routegroups/convert/use-unique-hosts.log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
duplicate host \\\"app\.example\.org\\\" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +0,0 @@ | ||
kube_rg__default__myapp__all__0_0: Path("/articles") && Host(/^(example[.]org[.]?(:[0-9]+)?)$/) | ||
-> <roundRobin, "http://10.2.9.103:7272", "http://10.2.9.104:7272">; | ||
|
||
kube_rg__default__myapp__all__1_0: Path("/articles/shoes") && Host(/^(example[.]org[.]?(:[0-9]+)?)$/) | ||
-> <roundRobin, "http://10.2.9.103:7272", "http://10.2.9.104:7272">; | ||
|
||
kube_rg__default__myapp__all__2_0: Path("/order") && Host(/^(example[.]org[.]?(:[0-9]+)?)$/) | ||
-> <roundRobin, "http://10.2.9.103:7272", "http://10.2.9.104:7272">; | ||
|
||
kube_rg____example_org__catchall__0_0: Host(/^(example[.]org[.]?(:[0-9]+)?)$/) | ||
-> <shunt>; | ||
1 change: 1 addition & 0 deletions
1
dataclients/kubernetes/testdata/routegroups/examples/duplicate-host.log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
duplicate host \\\"example\.org\\\" |