-
Notifications
You must be signed in to change notification settings - Fork 704
Add support for wildcard hosts on Ingresses #3381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sunjayBhatia
merged 11 commits into
projectcontour:main
from
sunjayBhatia:ingress-v1-wildcard-host
Apr 26, 2021
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
d62c0ac
Add support for wildcard hosts on Ingresses
sunjayBhatia 3664e38
Merge remote-tracking branch 'origin/main' into ingress-v1-wildcard-host
sunjayBhatia 0746a16
Add test for sorting regex header matches
sunjayBhatia bfc358e
Requested comment
sunjayBhatia 43d9f96
Merge remote-tracking branch 'origin/main' into ingress-v1-wildcard-host
sunjayBhatia 1d5ed2d
Rename ingress in integration test
sunjayBhatia cf2dee4
Comment in Ingress support notes
sunjayBhatia c2ca39f
Use v1beta1 Ingress in integration test
sunjayBhatia 45f558d
Merge remote-tracking branch 'origin/main' into ingress-v1-wildcard-host
sunjayBhatia 4bb8e5d
Merge remote-tracking branch 'origin/main' into ingress-v1-wildcard-host
sunjayBhatia 5584e98
Put back Ingress v1 resource in integration test
sunjayBhatia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
165 changes: 165 additions & 0 deletions
165
_integration/testsuite/ingress/001-ingress-tls-wildcard-host.yaml
This file contains hidden or 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,165 @@ | ||
| # Copyright Project Contour Authors | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
| # not use this file except in compliance with the License. You may obtain | ||
| # a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
| # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
| # License for the specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| import data.contour.resources | ||
|
|
||
| # Ensure that cert-manager is installed. | ||
| # Version check the certificates resource. | ||
|
|
||
| Group := "cert-manager.io" | ||
| Version := "v1" | ||
|
|
||
| have_certmanager_version { | ||
| v := resources.versions["certificates"] | ||
| v[_].Group == Group | ||
| v[_].Version == Version | ||
| } | ||
|
|
||
| skip[msg] { | ||
| not resources.is_supported("certificates") | ||
| msg := "cert-manager is not installed" | ||
| } | ||
|
|
||
| skip[msg] { | ||
| not have_certmanager_version | ||
|
|
||
| avail := resources.versions["certificates"] | ||
|
|
||
| msg := concat("\n", [ | ||
| sprintf("cert-manager version %s/%s is not installed", [Group, Version]), | ||
| "available versions:", | ||
| yaml.marshal(avail) | ||
| ]) | ||
| } | ||
|
|
||
| --- | ||
|
|
||
| # Create a self-signed issuer to give us secrets. | ||
|
|
||
| apiVersion: cert-manager.io/v1 | ||
| kind: Issuer | ||
| metadata: | ||
| name: selfsigned | ||
| spec: | ||
| selfSigned: {} | ||
|
|
||
| --- | ||
|
|
||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| metadata: | ||
| name: ingress-conformance-echo | ||
| $apply: | ||
| fixture: | ||
| as: echo | ||
|
|
||
| --- | ||
|
|
||
| apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| name: ingress-conformance-echo | ||
| $apply: | ||
| fixture: | ||
| as: echo | ||
|
|
||
| --- | ||
|
|
||
| apiVersion: cert-manager.io/v1 | ||
| kind: Certificate | ||
| metadata: | ||
| name: wildcard-cert | ||
| spec: | ||
| dnsNames: | ||
| - "*.projectcontour.io" | ||
| secretName: wildcard | ||
| issuerRef: | ||
| name: selfsigned | ||
|
|
||
| --- | ||
|
|
||
| apiVersion: networking.k8s.io/v1 | ||
| kind: Ingress | ||
| metadata: | ||
| name: wildcard-ingress | ||
| spec: | ||
| tls: | ||
| - hosts: | ||
| - "*.projectcontour.io" | ||
| secretName: wildcard | ||
| rules: | ||
| - host: "*.projectcontour.io" | ||
| http: | ||
| paths: | ||
| - pathType: Prefix | ||
| path: "/" | ||
| backend: | ||
| service: | ||
| name: echo | ||
| port: | ||
| number: 80 | ||
|
|
||
| --- | ||
|
|
||
| import data.contour.http.client | ||
| import data.contour.http.client.url | ||
| import data.contour.http.expect | ||
|
|
||
| import data.builtin.result | ||
|
|
||
| # Hostname, SNI, expected status code. | ||
| cases := [ | ||
| [ "random1.projectcontour.io", "", 200 ], | ||
| [ "random2.projectcontour.io", "random2.projectcontour.io", 200 ], | ||
| [ "a.random3.projectcontour.io", "a.random3.projectcontour.io", 404 ], | ||
| [ "random4.projectcontour.io", "other-random4.projectcontour.io", 421 ], | ||
| [ "random5.projectcontour.io", "a.random5.projectcontour.io", 421 ], | ||
| [ "random6.projectcontour.io:9999", "random6.projectcontour.io", 200 ], | ||
| ] | ||
|
|
||
| request_for_host[host] = request { | ||
| c := cases[_] | ||
| host := c[0] | ||
| sni := c[1] | ||
| request := { | ||
| "method": "GET", | ||
| "url": url.https("/echo"), | ||
| "headers": { | ||
| "Host": host, | ||
| "User-Agent": client.ua("ingress-tls-wildcard"), | ||
| }, | ||
| "tls_server_name": sni, | ||
| "tls_insecure_skip_verify": true, | ||
| } | ||
| } | ||
|
|
||
| response_for_host[host] = resp { | ||
| c := cases[_] | ||
| host := c[0] | ||
| request := request_for_host[host] | ||
| resp := http.send(request) | ||
| } | ||
|
|
||
| # Ensure that we get a response for each test case. | ||
| error_missing_responses { | ||
| count(cases) != count(response_for_host) | ||
| } | ||
|
|
||
| check_for_status_code [msg] { | ||
| c := cases[_] | ||
| host := c[0] | ||
| status := c[2] | ||
| resp := response_for_host[host] | ||
| msg := expect.response_status_is(resp, status) | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.