-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add support for wildcard hostname in VirutalServer #2939
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2939 +/- ##
==========================================
+ Coverage 52.28% 52.32% +0.03%
==========================================
Files 58 58
Lines 15965 15970 +5
==========================================
+ Hits 8348 8357 +9
+ Misses 7337 7335 -2
+ Partials 280 278 -2
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
…s-ingress into feat/wildcardhostname
func validateHost(host string, fieldPath *field.Path) field.ErrorList { | ||
allErrs := field.ErrorList{} | ||
|
||
if host == "" { | ||
return append(allErrs, field.Required(fieldPath, "")) | ||
} | ||
|
||
for _, msg := range validation.IsDNS1123Subdomain(host) { | ||
allErrs = append(allErrs, field.Invalid(fieldPath, host, msg)) | ||
if !strings.HasPrefix(host, wildcardHost) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also validate the wildcard host - we can use validation.IsWildcardDNS1123Subdomain
see here for reference
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
service.beta.kubernetes.io/aws-load-balancer-backend-protocol: "tcp" | ||
service.beta.kubernetes.io/aws-load-balancer-proxy-protocol: "*" | ||
service.beta.kubernetes.io/aws-load-balancer-type: "nlb" | ||
service.beta.kubernetes.io/aws-load-balancer-nlb-target-type: "ip" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor one but these 2 annotations can be appended to old list instead of replacing them
@@ -51,7 +51,7 @@ spec: | |||
{{% table %}} | |||
|Field | Description | Type | Required | | |||
| ---| ---| ---| --- | | |||
|``host`` | The host (domain name) of the server. Must be a valid subdomain as defined in RFC 1123, such as ``my-app`` or ``hello.example.com``. Wildcard domains like ``*.example.com`` are not allowed. The ``host`` value needs to be unique among all Ingress and VirtualServer resources. See also [Handling Host and Listener Collisions](/nginx-ingress-controller/configuration/handling-host-and-listener-collisions). | ``string`` | Yes | | |||
|``host`` | The host (domain name) of the server. Must be a valid subdomain as defined in RFC 1123, such as ``my-app`` or ``hello.example.com``. When using a wildcard domain like ``*.example.com`` the domain must be contained in double quotes. The ``host`` value needs to be unique among all Ingress and VirtualServer resources. See also [Handling Host and Listener Collisions](/nginx-ingress-controller/configuration/handling-host-and-listener-collisions). | ``string`` | Yes | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ``host`` value needs to be unique
: do we allow two VS resources with same wildcard host? eg. both with *.something.com
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I'll check if that's possible or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't allow two VS resources to be deployed with the same wildcard hostname. Output below is what I got when I tried this:
Spec:
Host: *.example.com
Routes:
Action:
Pass: tea
Path: /tea
Action:
Pass: coffee
Path: /coffee
Tls:
Secret: cafe-secret
Upstreams:
Name: tea
Port: 80
Service: tea-svc
Name: coffee
Port: 80
Service: coffee-svc
Status:
Message: Host is taken by another resource
Reason: Rejected
State: Warning
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning Rejected 13s nginx-ingress-controller Host is taken by another resource
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
approved but left couple comments!
Proposed changes
This change updates the
VirutalServer
CRD to add support for a wildcard hostname.This change also makes updates to ExternalDNS to allow a
DNSEndpoint
type to be created when specifying a wildcard hostname in aVirtualServer
object.Checklist
Before creating a PR, run through this checklist and mark each as complete.