Skip to content

Commit aa2c2c3

Browse files
committed
Gateway API v0.5.0 API Review
1 parent 36736f7 commit aa2c2c3

7 files changed

+304
-88
lines changed

apis/v1alpha2/gateway_types.go

+6-46
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ type GatewaySpec struct {
135135
// it assigns to the Gateway and add a corresponding entry in
136136
// GatewayStatus.Addresses.
137137
//
138-
// Support: Core
138+
// Support: Extended
139139
//
140140
// +optional
141141
// +kubebuilder:validation:MaxItems=16
@@ -145,7 +145,8 @@ type GatewaySpec struct {
145145
// Listener embodies the concept of a logical endpoint where a Gateway accepts
146146
// network connections.
147147
type Listener struct {
148-
// Name is the name of the Listener.
148+
// Name is the name of the Listener. This name MUST be unique within a
149+
// Gateway.
149150
//
150151
// Support: Core
151152
Name SectionName `json:"name"`
@@ -320,7 +321,7 @@ type GatewayTLSConfig struct {
320321
// CertificateRefs can reference to standard Kubernetes resources, i.e.
321322
// Secret, or implementation-specific custom resources.
322323
//
323-
// Support: Core - A single reference to a Kubernetes Secret
324+
// Support: Core - A single reference to a Kubernetes Secret of type kubernetes.io/tls
324325
//
325326
// Support: Implementation-specific (More than one reference or other resource types)
326327
//
@@ -381,7 +382,7 @@ type AllowedRoutes struct {
381382
// with the application protocol specified in the Listener's Protocol field.
382383
// If an implementation does not support or recognize this resource type, it
383384
// MUST set the "ResolvedRefs" condition to False for this Listener with the
384-
// "InvalidRoutesRef" reason.
385+
// "InvalidRouteKinds" reason.
385386
//
386387
// Support: Core
387388
//
@@ -449,6 +450,7 @@ type GatewayAddress struct {
449450
// Type of the address.
450451
//
451452
// +optional
453+
// +kubebuilder:validation:Enum=IPAddress;Hostname;NamedAddress
452454
// +kubebuilder:default=IPAddress
453455
Type *AddressType `json:"type,omitempty"`
454456

@@ -462,40 +464,6 @@ type GatewayAddress struct {
462464
Value string `json:"value"`
463465
}
464466

465-
// AddressType defines how a network address is represented as a text string.
466-
//
467-
// If the requested address is unsupported, the controller
468-
// should raise the "Detached" listener status condition on
469-
// the Gateway with the "UnsupportedAddress" reason.
470-
//
471-
// +kubebuilder:validation:Enum=IPAddress;Hostname;NamedAddress
472-
type AddressType string
473-
474-
const (
475-
// A textual representation of a numeric IP address. IPv4
476-
// addresses must be in dotted-decimal form. IPv6 addresses
477-
// must be in a standard IPv6 text representation
478-
// (see [RFC 5952](https://tools.ietf.org/html/rfc5952)).
479-
//
480-
// Support: Extended
481-
IPAddressType AddressType = "IPAddress"
482-
483-
// A Hostname represents a DNS based ingress point. This is similar to the
484-
// corresponding hostname field in Kubernetes load balancer status. For
485-
// example, this concept may be used for cloud load balancers where a DNS
486-
// name is used to expose a load balancer.
487-
//
488-
// Support: Extended
489-
HostnameAddressType AddressType = "Hostname"
490-
491-
// A NamedAddress provides a way to reference a specific IP address by name.
492-
// For example, this may be a name or other unique identifier that refers
493-
// to a resource on a cloud provider such as a static IP.
494-
//
495-
// Support: Implementation-Specific
496-
NamedAddressType AddressType = "NamedAddress"
497-
)
498-
499467
// GatewayStatus defines the observed state of Gateway.
500468
type GatewayStatus struct {
501469
// Addresses lists the IP addresses that have actually been
@@ -673,7 +641,6 @@ const (
673641
//
674642
// * "HostnameConflict"
675643
// * "ProtocolConflict"
676-
// * "RouteConflict"
677644
//
678645
// Possible reasons for this condition to be False are:
679646
//
@@ -695,13 +662,6 @@ const (
695662
// number, but have conflicting protocol specifications.
696663
ListenerReasonProtocolConflict ListenerConditionReason = "ProtocolConflict"
697664

698-
// This reason is used with the "Conflicted" condition when the route
699-
// resources selected for this Listener conflict with other
700-
// specified properties of the Listener (e.g. Protocol).
701-
// For example, a Listener that specifies "UDP" as the protocol
702-
// but a route selector that resolves "TCPRoute" objects.
703-
ListenerReasonRouteConflict ListenerConditionReason = "RouteConflict"
704-
705665
// This reason is used with the "Conflicted" condition when the condition
706666
// is False.
707667
ListenerReasonNoConflicts ListenerConditionReason = "NoConflicts"

apis/v1alpha2/httproute_types.go

+121-16
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,15 @@ type HTTPRouteRule struct {
152152
//
153153
// * The oldest Route based on creation timestamp.
154154
// * The Route appearing first in alphabetical order by
155-
// "<namespace>/<name>".
155+
// "{namespace}/{name}".
156156
//
157157
// If ties still exist within the Route that has been given precedence,
158158
// matching precedence MUST be granted to the first matching rule meeting
159159
// the above criteria.
160160
//
161+
// When no rules matching a request have been successfully attached to the
162+
// parent a request is coming from, a HTTP 404 status code MUST be returned.
163+
//
161164
// +optional
162165
// +kubebuilder:validation:MaxItems=8
163166
// +kubebuilder:default={{path:{ type: "PathPrefix", value: "/"}}}
@@ -187,13 +190,25 @@ type HTTPRouteRule struct {
187190

188191
// BackendRefs defines the backend(s) where matching requests should be
189192
// sent.
190-
191-
// If unspecified or invalid (refers to a non-existent resource or a Service
192-
// with no endpoints), the rule performs no forwarding. If there are also no
193-
// filters specified that would result in a response being sent, a HTTP 503
194-
// status code is returned. 503 responses must be sent so that the overall
195-
// weight is respected; if an invalid backend is requested to have 80% of
196-
// requests, then 80% of requests must get a 503 instead.
193+
//
194+
// A 404 status code MUST be returned if there are no BackendRefs or filters
195+
// specified that would result in a response being sent.
196+
//
197+
// A BackendRef is considered invalid when it refers to:
198+
//
199+
// * an unknown or unsupported kind of resource
200+
// * a resource that does not exist
201+
// * a resource in another namespace when the reference has not been
202+
// explicitly allowed by a ReferencePolicy (or equivalent concept).
203+
//
204+
// When a BackendRef is invalid, 404 status codes MUST be returned for
205+
// requests that would have otherwise been routed to an invalid backend. If
206+
// multiple backends are specified, and some are invalid, the proportion of
207+
// requests that would otherwise have been routed to an invalid backend
208+
// MUST receive a 404 status code.
209+
//
210+
// When a BackendRef refers to a Service that has no ready endpoints, it is
211+
// recommended to return a 503 status code.
197212
//
198213
// Support: Core for Kubernetes Service
199214
// Support: Custom for any other resource
@@ -227,11 +242,10 @@ const (
227242
// Matches based on a URL path prefix split by `/`. Matching is
228243
// case sensitive and done on a path element by element basis. A
229244
// path element refers to the list of labels in the path split by
230-
// the `/` separator. A request is a match for path _p_ if every
231-
// _p_ is an element-wise prefix of the request path.
245+
// the `/` separator. When specified, a trailing `/` is ignored.
232246
//
233-
// For example, `/abc`, `/abc/` and `/abc/def` match the prefix
234-
// `/abc`, but `/abcd` does not.
247+
// For example. the paths `/abc`, `/abc/`, and `/abc/def` would all match
248+
// the prefix `/abc`, but the path `/abcd` would not.
235249
//
236250
// "PathPrefix" is semantically equivalent to the "Prefix" path type in the
237251
// Kubernetes Ingress API.
@@ -495,6 +509,8 @@ type HTTPRouteFilter struct {
495509
// that filter MUST receive a HTTP error response.
496510
//
497511
// +unionDiscriminator
512+
// +kubebuilder:validation:Enum=RequestHeaderModifier;RequestMirror;RequestRedirect;ExtensionRef
513+
// <gateway:experimental:validation:Enum=RequestHeaderModifier;RequestMirror;RequestRedirect;URLRewrite;ExtensionRef>
498514
Type HTTPRouteFilterType `json:"type"`
499515

500516
// RequestHeaderModifier defines a schema for a filter that modifies request
@@ -522,6 +538,13 @@ type HTTPRouteFilter struct {
522538
// +optional
523539
RequestRedirect *HTTPRequestRedirectFilter `json:"requestRedirect,omitempty"`
524540

541+
// URLRewrite defines a schema for a filter that modifies a request during forwarding.
542+
// Support: Extended
543+
//
544+
// <gateway:experimental>
545+
// +optional
546+
URLRewrite *HTTPURLRewriteFilter `json:"urlRewrite,omitempty"`
547+
525548
// ExtensionRef is an optional, implementation-specific extension to the
526549
// "filter" behavior. For example, resource "myroutefilter" in group
527550
// "networking.example.net"). ExtensionRef MUST NOT be used for core and
@@ -534,7 +557,6 @@ type HTTPRouteFilter struct {
534557
}
535558

536559
// HTTPRouteFilterType identifies a type of HTTPRoute filter.
537-
// +kubebuilder:validation:Enum=RequestHeaderModifier;RequestMirror;RequestRedirect;ExtensionRef
538560
type HTTPRouteFilterType string
539561

540562
const (
@@ -548,13 +570,26 @@ const (
548570

549571
// HTTPRouteFilterRequestRedirect can be used to redirect a request to
550572
// another location. This filter can also be used for HTTP to HTTPS
551-
// redirects.
573+
// redirects. This may not be used on the same Route rule or BackendRef as a
574+
// URLRewrite filter.
552575
//
553576
// Support in HTTPRouteRule: Core
554577
//
555578
// Support in HTTPBackendRef: Extended
556579
HTTPRouteFilterRequestRedirect HTTPRouteFilterType = "RequestRedirect"
557580

581+
// HTTPRouteFilterURLRewrite can be used to modify a request during
582+
// forwarding. At most one of these filters may be used on a Route rule.
583+
// This may not be used on the same Route rule or BackendRef as a
584+
// RequestRedirect filter.
585+
//
586+
// Support in HTTPRouteRule: Extended
587+
//
588+
// Support in HTTPBackendRef: Extended
589+
//
590+
// <gateway:experimental>
591+
HTTPRouteFilterURLRewrite HTTPRouteFilterType = "URLRewrite"
592+
558593
// HTTPRouteFilterRequestMirror can be used to mirror HTTP requests to a
559594
// different backend. The responses from this backend MUST be ignored by
560595
// the Gateway.
@@ -664,7 +699,42 @@ type HTTPRequestHeaderFilter struct {
664699
Remove []string `json:"remove,omitempty"`
665700
}
666701

667-
// HTTPRequestRedirectFilter defines configuration for the RequestRedirect filter.
702+
// HTTPPathModifierType defines the type of path redirect.
703+
type HTTPPathModifierType string
704+
705+
const (
706+
// This type of modifier indicates that the complete path will be replaced
707+
// by the path redirect value.
708+
AbsoluteHTTPPathModifier HTTPPathModifierType = "Absolute"
709+
710+
// This type of modifier indicates that any prefix path matches will be
711+
// replaced by the substitution value. For example, a path with a prefix
712+
// match of "/foo" and a ReplacePrefixMatch substitution of "/bar" will have
713+
// the "/foo" prefix replaced with "/bar" in matching requests.
714+
PrefixMatchHTTPPathModifier HTTPPathModifierType = "ReplacePrefixMatch"
715+
)
716+
717+
// HTTPPathModifier defines configuration for path modifiers.
718+
// <gateway:experimental>
719+
type HTTPPathModifier struct {
720+
// Type defines the type of path modifier.
721+
//
722+
// <gateway:experimental>
723+
// +kubebuilder:validation:Enum=Absolute;ReplacePrefixMatch
724+
Type HTTPPathModifierType `json:"type"`
725+
726+
// Substitution defines the HTTP path value to substitute. An empty value
727+
// ("") indicates that the portion of the path to be changed should be
728+
// removed from the resulting path. For example, a request to "/foo/bar"
729+
// with a prefix match of "/foo" would be modified to "/bar".
730+
//
731+
// <gateway:experimental>
732+
// +kubebuilder:validation:MaxLength=1024
733+
Substitution string `json:"substitution"`
734+
}
735+
736+
// HTTPRequestRedirect defines a filter that redirects a request. This filter
737+
// MUST not be used on the same Route rule as a HTTPURLRewrite filter.
668738
type HTTPRequestRedirectFilter struct {
669739
// Scheme is the scheme to be used in the value of the `Location`
670740
// header in the response.
@@ -685,6 +755,16 @@ type HTTPRequestRedirectFilter struct {
685755
// +optional
686756
Hostname *PreciseHostname `json:"hostname,omitempty"`
687757

758+
// Path defines parameters used to modify the path of the incoming request.
759+
// The modified path is then used to construct the `Location` header. When
760+
// empty, the request path is used as-is.
761+
//
762+
// Support: Extended
763+
//
764+
// <gateway:experimental>
765+
// +optional
766+
Path *HTTPPathModifier `json:"path,omitempty"`
767+
688768
// Port is the port to be used in the value of the `Location`
689769
// header in the response.
690770
// When empty, port (if specified) of the request is used.
@@ -704,6 +784,31 @@ type HTTPRequestRedirectFilter struct {
704784
StatusCode *int `json:"statusCode,omitempty"`
705785
}
706786

787+
// HTTPURLRewriteFilter defines a filter that modifies a request during
788+
// forwarding. At most one of these filters may be used on a Route rule. This
789+
// may not be used on the same Route rule as a HTTPRequestRedirect filter.
790+
//
791+
// <gateway:experimental>
792+
// Support: Extended
793+
type HTTPURLRewriteFilter struct {
794+
// Hostname is the value to be used to replace the Host header value during
795+
// forwarding.
796+
//
797+
// Support: Extended
798+
//
799+
// <gateway:experimental>
800+
// +optional
801+
Hostname *Hostname `json:"hostname,omitempty"`
802+
803+
// Path defines a path rewrite.
804+
//
805+
// Support: Extended
806+
//
807+
// <gateway:experimental>
808+
// +optional
809+
Path *HTTPPathModifier `json:"path,omitempty"`
810+
}
811+
707812
// HTTPRequestMirrorFilter defines configuration for the RequestMirror filter.
708813
type HTTPRequestMirrorFilter struct {
709814
// BackendRef references a resource where mirrored requests are sent.
@@ -738,7 +843,7 @@ type HTTPBackendRef struct {
738843
//
739844
// If there is a cross-namespace reference to an *existing* object
740845
// that is not covered by a ReferencePolicy, the controller must ensure the
741-
// "ResolvedRefs" condition on the Route is set to `status: true`,
846+
// "ResolvedRefs" condition on the Route is set to `status: False`,
742847
// with the "RefNotPermitted" reason and not configure this backend in the
743848
// underlying implementation.
744849
//

apis/v1alpha2/object_reference_types.go

+1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ type BackendObjectReference struct {
100100
Group *Group `json:"group,omitempty"`
101101

102102
// Kind is kind of the referent. For example "HTTPRoute" or "Service".
103+
// Defaults to "Service" when not specified.
103104
//
104105
// +optional
105106
// +kubebuilder:default=Service

apis/v1alpha2/referencepolicy_types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ type ReferencePolicyTo struct {
123123
// * Service
124124
Kind Kind `json:"kind"`
125125

126-
// Name is the name of the referent. When unspecified or empty, this policy
126+
// Name is the name of the referent. When unspecified, this policy
127127
// refers to all resources of the specified Group and Kind in the local
128128
// namespace.
129129
//

0 commit comments

Comments
 (0)