-
Notifications
You must be signed in to change notification settings - Fork 771
TLSRoute: Require hostnames and bump version to v1alpha3 #3872
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
Changes from 6 commits
6d2a8bc
d67ce96
4eb32a7
615aa3c
afb02dc
2ba0374
236339c
cf5c16d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| /* | ||
| Copyright 2020 The Kubernetes 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. | ||
| */ | ||
|
|
||
| package v1alpha3 | ||
|
|
||
| import v1 "sigs.k8s.io/gateway-api/apis/v1" | ||
|
|
||
| // CommonRouteSpec defines the common attributes that all Routes MUST include | ||
| // within their spec. | ||
| // +k8s:deepcopy-gen=false | ||
| type CommonRouteSpec = v1.CommonRouteSpec | ||
|
|
||
| // BackendRef defines how a Route should forward a request to a Kubernetes | ||
| // resource. | ||
| // | ||
| // Note that when a namespace different than the local namespace is specified, a | ||
| // ReferenceGrant object is required in the referent namespace to allow that | ||
| // namespace's owner to accept the reference. See the ReferenceGrant | ||
| // documentation for details. | ||
| // +k8s:deepcopy-gen=false | ||
| type BackendRef = v1.BackendRef | ||
|
|
||
| // RouteStatus defines the common attributes that all Routes MUST include within | ||
| // their status. | ||
| // +k8s:deepcopy-gen=false | ||
| type RouteStatus = v1.RouteStatus | ||
|
|
||
| // Hostname is the fully qualified domain name of a network host. This matches | ||
| // the RFC 1123 definition of a hostname with 2 notable exceptions: | ||
| // | ||
| // 1. IPs are not allowed. | ||
| // 2. A hostname may be prefixed with a wildcard label (`*.`). The wildcard | ||
| // label must appear by itself as the first label. | ||
| // | ||
| // Hostname can be "precise" which is a domain name without the terminating | ||
| // dot of a network host (e.g. "foo.example.com") or "wildcard", which is a | ||
| // domain name prefixed with a single wildcard label (e.g. `*.example.com`). | ||
| // | ||
| // Note that as per RFC1035 and RFC1123, a *label* must consist of lower case | ||
| // alphanumeric characters or '-', and must start and end with an alphanumeric | ||
| // character. No other punctuation is allowed. | ||
| // | ||
| // +kubebuilder:validation:MinLength=1 | ||
| // +kubebuilder:validation:MaxLength=253 | ||
| // +kubebuilder:validation:Pattern=`^(\*\.)?[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$` | ||
| type Hostname = v1.Hostname | ||
|
|
||
| // SectionName is the name of a section in a Kubernetes resource. | ||
| // | ||
| // In the following resources, SectionName is interpreted as the following: | ||
| // | ||
| // * Gateway: Listener name | ||
| // * HTTPRoute: HTTPRouteRule name | ||
| // * Service: Port name | ||
| // | ||
| // Section names can have a variety of forms, including RFC 1123 subdomains, | ||
| // RFC 1123 labels, or RFC 1035 labels. | ||
| // | ||
| // This validation is based off of the corresponding Kubernetes validation: | ||
| // https://github.com/kubernetes/apimachinery/blob/02cfb53916346d085a6c6c7c66f882e3c6b0eca6/pkg/util/validation/validation.go#L208 | ||
| // | ||
| // Valid values include: | ||
| // | ||
| // * "example" | ||
| // * "foo-example" | ||
| // * "example.com" | ||
| // * "foo.example.com" | ||
| // | ||
| // Invalid values include: | ||
| // | ||
| // * "example.com/bar" - "/" is an invalid character | ||
| // | ||
| // +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$` | ||
| // +kubebuilder:validation:MinLength=1 | ||
| // +kubebuilder:validation:MaxLength=253 | ||
| type SectionName = v1.SectionName |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,105 @@ | ||||||||||||||||||
| /* | ||||||||||||||||||
| Copyright 2020 The Kubernetes 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. | ||||||||||||||||||
| */ | ||||||||||||||||||
|
|
||||||||||||||||||
| package v1alpha3 | ||||||||||||||||||
|
|
||||||||||||||||||
| import ( | ||||||||||||||||||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||||||||||||||
|
|
||||||||||||||||||
| "sigs.k8s.io/gateway-api/apis/v1alpha2" | ||||||||||||||||||
| ) | ||||||||||||||||||
|
|
||||||||||||||||||
| // +genclient | ||||||||||||||||||
| // +kubebuilder:object:root=true | ||||||||||||||||||
| // +kubebuilder:resource:categories=gateway-api | ||||||||||||||||||
| // +kubebuilder:subresource:status | ||||||||||||||||||
| // +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp` | ||||||||||||||||||
|
|
||||||||||||||||||
| // The TLSRoute resource is similar to TCPRoute, but can be configured | ||||||||||||||||||
| // to match against TLS-specific metadata. This allows more flexibility | ||||||||||||||||||
| // in matching streams for a given TLS listener. | ||||||||||||||||||
| // | ||||||||||||||||||
| // If you need to forward traffic to a single target for a TLS listener, you | ||||||||||||||||||
| // could choose to use a TCPRoute with a TLS listener. | ||||||||||||||||||
| type TLSRoute struct { | ||||||||||||||||||
| metav1.TypeMeta `json:",inline"` | ||||||||||||||||||
| metav1.ObjectMeta `json:"metadata,omitempty"` | ||||||||||||||||||
|
|
||||||||||||||||||
| // Spec defines the desired state of TLSRoute. | ||||||||||||||||||
| Spec TLSRouteSpec `json:"spec"` | ||||||||||||||||||
|
|
||||||||||||||||||
| // Status defines the current state of TLSRoute. | ||||||||||||||||||
| Status v1alpha2.TLSRouteStatus `json:"status,omitempty"` | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| // TLSRouteSpec defines the desired state of a TLSRoute resource. | ||||||||||||||||||
| type TLSRouteSpec struct { | ||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Going back in time to one of the recent times we did something similar, we used aliases in the old API version that pointed to the new one. I'd recommend doing that here as well. So in this case v1alpha3 would be the source of truth, and v1alpha2 would point at that. Take a look at this for an example: gateway-api/apis/v1beta1/gateway_types.go Lines 48 to 55 in 093f653
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When promoting TLSRoutes to TLSRoute promotion from from
|
||||||||||||||||||
| CommonRouteSpec `json:",inline"` | ||||||||||||||||||
|
|
||||||||||||||||||
| // Hostnames defines a set of SNI hostnames that should match against the | ||||||||||||||||||
| // SNI attribute of TLS ClientHello message in TLS handshake. This matches | ||||||||||||||||||
| // the RFC 1123 definition of a hostname with 2 notable exceptions: | ||||||||||||||||||
| // | ||||||||||||||||||
| // 1. IPs are not allowed in SNI hostnames per RFC 6066. | ||||||||||||||||||
| // 2. A hostname may be prefixed with a wildcard label (`*.`). The wildcard | ||||||||||||||||||
| // label must appear by itself as the first label. | ||||||||||||||||||
| // | ||||||||||||||||||
| // If a hostname is specified by both the Listener and TLSRoute, there | ||||||||||||||||||
| // must be at least one intersecting hostname for the TLSRoute to be | ||||||||||||||||||
| // attached to the Listener. For example: | ||||||||||||||||||
| // | ||||||||||||||||||
| // * A Listener with `test.example.com` as the hostname matches TLSRoutes | ||||||||||||||||||
| // that have either not specified any hostnames, or have specified at | ||||||||||||||||||
| // least one of `test.example.com` or `*.example.com`. | ||||||||||||||||||
| // * A Listener with `*.example.com` as the hostname matches TLSRoutes | ||||||||||||||||||
| // that have either not specified any hostnames or have specified at least | ||||||||||||||||||
| // one hostname that matches the Listener hostname. For example, | ||||||||||||||||||
| // `test.example.com` and `*.example.com` would both match. On the other | ||||||||||||||||||
| // hand, `example.com` and `test.example.net` would not match. | ||||||||||||||||||
| // | ||||||||||||||||||
| // If both the Listener and TLSRoute have specified hostnames, any | ||||||||||||||||||
| // TLSRoute hostnames that do not match the Listener hostname MUST be | ||||||||||||||||||
| // ignored. For example, if a Listener specified `*.example.com`, and the | ||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For what added in #4437 does
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd recommend going through #4437 (comment) thread for more details |
||||||||||||||||||
| // TLSRoute specified `test.example.com` and `test.example.net`, | ||||||||||||||||||
| // `test.example.net` must not be considered for a match. | ||||||||||||||||||
| // | ||||||||||||||||||
| // If both the Listener and TLSRoute have specified hostnames, and none | ||||||||||||||||||
| // match with the criteria above, then the TLSRoute is not accepted. The | ||||||||||||||||||
| // implementation must raise an 'Accepted' Condition with a status of | ||||||||||||||||||
| // `False` in the corresponding RouteParentStatus. | ||||||||||||||||||
| // | ||||||||||||||||||
| // Support: Core | ||||||||||||||||||
| // | ||||||||||||||||||
| // +kubebuilder:validation:MinItems=1 | ||||||||||||||||||
| // +kubebuilder:validation:MaxItems=16 | ||||||||||||||||||
| Hostnames []Hostname `json:"hostnames,omitempty"` | ||||||||||||||||||
|
rostislavbobo marked this conversation as resolved.
|
||||||||||||||||||
|
|
||||||||||||||||||
| // Rules are a list of TLS matchers and actions. | ||||||||||||||||||
| // | ||||||||||||||||||
| // +kubebuilder:validation:MinItems=1 | ||||||||||||||||||
| // +kubebuilder:validation:MaxItems=16 | ||||||||||||||||||
| // <gateway:experimental:validation:XValidation:message="Rule name must be unique within the route",rule="self.all(l1, !has(l1.name) || self.exists_one(l2, has(l2.name) && l1.name == l2.name))"> | ||||||||||||||||||
| Rules []v1alpha2.TLSRouteRule `json:"rules"` | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| // +kubebuilder:object:root=true | ||||||||||||||||||
|
|
||||||||||||||||||
| // TLSRouteList contains a list of TLSRoute | ||||||||||||||||||
| type TLSRouteList struct { | ||||||||||||||||||
| metav1.TypeMeta `json:",inline"` | ||||||||||||||||||
| metav1.ListMeta `json:"metadata,omitempty"` | ||||||||||||||||||
| Items []TLSRoute `json:"items"` | ||||||||||||||||||
| } | ||||||||||||||||||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.