feat: Add wildcard DNS support for DNSEndpoint resources#107
Open
angelbarrera92 wants to merge 1 commit into
Open
feat: Add wildcard DNS support for DNSEndpoint resources#107angelbarrera92 wants to merge 1 commit into
angelbarrera92 wants to merge 1 commit into
Conversation
Implements wildcard DNS pattern matching (e.g., *.example.com) to resolve queries for single-level subdomains, following RFC 4592 standards. Key changes: - Add matchesWildcard() function for pattern matching logic - Update getEndpointsByCaseInsensitiveName() to support wildcards - Ensure exact matches take precedence over wildcard matches - Add comprehensive test coverage (11 unit tests + integration tests) - Include example YAML for wildcard DNS usage Wildcard behavior: - *.example.com matches test.example.com ✓ - *.example.com does NOT match example.com (apex) ✗ - *.example.com does NOT match sub.test.example.com ✗ - Case-insensitive matching preserved - Backwards compatible with existing exact matches Fixes k8gb-io#106 Signed-off-by: Barrera, Angel <Angel.Barrera@adidas.com>
c028544 to
13441ca
Compare
Member
|
@angelbarrera92 thanks for the contribution! Have you tested this change end-to-end? |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #106
Description
This PR implements wildcard DNS support for DNSEndpoint resources, enabling the CoreDNS CRD plugin to resolve queries using wildcard patterns (e.g.,
*.example.com).Previously, the plugin only performed exact hostname matching. With this change, DNSEndpoint resources can now define wildcard patterns that match single-level subdomains, following standard DNS wildcard behavior as defined in RFC 4592.
Changes Made
Core Functionality (
common/k8sctrl/ctrl.go)matchesWildcard()function to implement wildcard pattern matching logicgetEndpointsByCaseInsensitiveName()to support both exact and wildcard matchesmargeLocalDNSEndpoints()to properly handle nil labelsTesting (
common/k8sctrl/ctrl_test.go)matchesWildcard()function (11 test cases)Documentation (
terratest/example/dnsendpoint_wildcard.yaml)Wildcard Behavior
Following standard DNS wildcard rules:
*.example.commatchestest.example.com*.example.commatchesapp.example.com*.example.comdoes NOT matchexample.com(apex domain)*.example.comdoes NOT matchsub.test.example.com(multi-level subdomain)Example Usage
Now queries for
app1.apps.example.com,app2.apps.example.com, etc. will all resolve to the specified targets.Testing
All tests pass:
go test ./... -shortSpecific wildcard tests:
Breaking Changes
None. This is a backwards-compatible feature addition. Existing DNSEndpoint resources with exact hostnames continue to work exactly as before.
Additional Notes