1 /* 2 Copyright 2020 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package v1alpha2 18 19 import ( 20 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 22 v1 "sigs.k8s.io/gateway-api/apis/v1" 23 ) 24 25 // +genclient 26 // +kubebuilder:object:root=true 27 // +kubebuilder:resource:categories=gateway-api 28 // +kubebuilder:subresource:status 29 // +kubebuilder:skipversion 30 // +kubebuilder:deprecatedversion:warning="The v1alpha2 version of HTTPRoute has been deprecated and will be removed in a future release of the API. Please upgrade to v1." 31 // +kubebuilder:printcolumn:name="Hostnames",type=string,JSONPath=`.spec.hostnames` 32 // +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp` 33 34 // HTTPRoute provides a way to route HTTP requests. This includes the capability 35 // to match requests by hostname, path, header, or query param. Filters can be 36 // used to specify additional processing steps. Backends specify where matching 37 // requests should be routed. 38 type HTTPRoute v1.HTTPRoute 39 40 // +kubebuilder:object:root=true 41 42 // HTTPRouteList contains a list of HTTPRoute. 43 type HTTPRouteList struct { 44 metav1.TypeMeta `json:",inline"` 45 metav1.ListMeta `json:"metadata,omitempty"` 46 Items []HTTPRoute `json:"items"` 47 } 48 49 // HTTPRouteSpec defines the desired state of HTTPRoute 50 // +k8s:deepcopy-gen=false 51 type HTTPRouteSpec = v1.HTTPRouteSpec 52 53 // HTTPRouteRule defines semantics for matching an HTTP request based on 54 // conditions (matches), processing it (filters), and forwarding the request to 55 // an API object (backendRefs). 56 // +k8s:deepcopy-gen=false 57 type HTTPRouteRule = v1.HTTPRouteRule 58 59 // PathMatchType specifies the semantics of how HTTP paths should be compared. 60 // Valid PathMatchType values, along with their conformance level, are: 61 // 62 // * "Exact" - Core 63 // * "PathPrefix" - Core 64 // * "RegularExpression" - Implementation Specific 65 // 66 // PathPrefix and Exact paths must be syntactically valid: 67 // 68 // - Must begin with the `/` character 69 // - Must not contain consecutive `/` characters (e.g. `/foo///`, `//`). 70 // 71 // Note that values may be added to this enum, implementations 72 // must ensure that unknown values will not cause a crash. 73 // 74 // Unknown values here must result in the implementation setting the 75 // Accepted Condition for the Route to `status: False`, with a 76 // Reason of `UnsupportedValue`. 77 // 78 // +kubebuilder:validation:Enum=Exact;PathPrefix;RegularExpression 79 // +k8s:deepcopy-gen=false 80 type PathMatchType = v1.PathMatchType 81 82 // HTTPPathMatch describes how to select a HTTP route by matching the HTTP request path. 83 // +k8s:deepcopy-gen=false 84 type HTTPPathMatch = v1.HTTPPathMatch 85 86 // HeaderMatchType specifies the semantics of how HTTP header values should be 87 // compared. Valid HeaderMatchType values, along with their conformance levels, are: 88 // 89 // * "Exact" - Core 90 // * "RegularExpression" - Implementation Specific 91 // 92 // Note that values may be added to this enum, implementations 93 // must ensure that unknown values will not cause a crash. 94 // 95 // Unknown values here must result in the implementation setting the 96 // Accepted Condition for the Route to `status: False`, with a 97 // Reason of `UnsupportedValue`. 98 // 99 // +kubebuilder:validation:Enum=Exact;RegularExpression 100 // +k8s:deepcopy-gen=false 101 type HeaderMatchType = v1.HeaderMatchType 102 103 // HTTPHeaderName is the name of an HTTP header. 104 // 105 // Valid values include: 106 // * "Authorization" 107 // * "Set-Cookie" 108 // 109 // Invalid values include: 110 // 111 // - ":method" - ":" is an invalid character. This means that HTTP/2 pseudo 112 // headers are not currently supported by this type. 113 // 114 // * "/invalid" - "/" is an invalid character 115 // +k8s:deepcopy-gen=false 116 type HTTPHeaderName = v1.HeaderName 117 118 // HTTPHeaderMatch describes how to select a HTTP route by matching HTTP request 119 // headers. 120 // +k8s:deepcopy-gen=false 121 type HTTPHeaderMatch = v1.HTTPHeaderMatch 122 123 // QueryParamMatchType specifies the semantics of how HTTP query parameter 124 // values should be compared. Valid QueryParamMatchType values, along with their 125 // conformance levels, are: 126 // 127 // * "Exact" - Core 128 // * "RegularExpression" - Implementation Specific 129 // 130 // Note that values may be added to this enum, implementations 131 // must ensure that unknown values will not cause a crash. 132 // 133 // Unknown values here must result in the implementation setting the 134 // Accepted Condition for the Route to `status: False`, with a 135 // Reason of `UnsupportedValue`. 136 // 137 // +kubebuilder:validation:Enum=Exact;RegularExpression 138 // +k8s:deepcopy-gen=false 139 type QueryParamMatchType = v1.QueryParamMatchType 140 141 // HTTPQueryParamMatch describes how to select a HTTP route by matching HTTP 142 // query parameters. 143 // +k8s:deepcopy-gen=false 144 type HTTPQueryParamMatch = v1.HTTPQueryParamMatch 145 146 // HTTPMethod describes how to select a HTTP route by matching the HTTP 147 // method as defined by 148 // [RFC 7231](https://datatracker.ietf.org/doc/html/rfc7231#section-4) and 149 // [RFC 5789](https://datatracker.ietf.org/doc/html/rfc5789#section-2). 150 // The value is expected in upper case. 151 // 152 // Note that values may be added to this enum, implementations 153 // must ensure that unknown values will not cause a crash. 154 // 155 // Unknown values here must result in the implementation setting the 156 // Accepted Condition for the Route to `status: False`, with a 157 // Reason of `UnsupportedValue`. 158 // 159 // +kubebuilder:validation:Enum=GET;HEAD;POST;PUT;DELETE;CONNECT;OPTIONS;TRACE;PATCH 160 // +k8s:deepcopy-gen=false 161 type HTTPMethod = v1.HTTPMethod 162 163 // HTTPRouteMatch defines the predicate used to match requests to a given 164 // action. Multiple match types are ANDed together, i.e. the match will 165 // evaluate to true only if all conditions are satisfied. 166 // 167 // For example, the match below will match a HTTP request only if its path 168 // starts with `/foo` AND it contains the `version: v1` header: 169 // 170 // ``` 171 // match: 172 // 173 // path: 174 // value: "/foo" 175 // headers: 176 // - name: "version" 177 // value "v1" 178 // 179 // ``` 180 // +k8s:deepcopy-gen=false 181 type HTTPRouteMatch = v1.HTTPRouteMatch 182 183 // HTTPRouteFilter defines processing steps that must be completed during the 184 // request or response lifecycle. HTTPRouteFilters are meant as an extension 185 // point to express processing that may be done in Gateway implementations. Some 186 // examples include request or response modification, implementing 187 // authentication strategies, rate-limiting, and traffic shaping. API 188 // guarantee/conformance is defined based on the type of the filter. 189 // +k8s:deepcopy-gen=false 190 type HTTPRouteFilter = v1.HTTPRouteFilter 191 192 // HTTPRouteFilterType identifies a type of HTTPRoute filter. 193 // +k8s:deepcopy-gen=false 194 type HTTPRouteFilterType = v1.HTTPRouteFilterType 195 196 // HTTPRouteTimeouts defines timeouts that can be configured for an HTTPRoute. 197 // +k8s:deepcopy-gen=false 198 type HTTPRouteTimeouts = v1.HTTPRouteTimeouts 199 200 // HTTPHeader represents an HTTP Header name and value as defined by RFC 7230. 201 // +k8s:deepcopy-gen=false 202 type HTTPHeader = v1.HTTPHeader 203 204 // HTTPHeaderFilter defines a filter that modifies the headers of an HTTP request 205 // or response. 206 // +k8s:deepcopy-gen=false 207 type HTTPHeaderFilter = v1.HTTPHeaderFilter 208 209 // HTTPPathModifierType defines the type of path redirect or rewrite. 210 // +k8s:deepcopy-gen=false 211 type HTTPPathModifierType = v1.HTTPPathModifierType 212 213 // HTTPPathModifier defines configuration for path modifiers. 214 // <gateway:experimental> 215 // +k8s:deepcopy-gen=false 216 type HTTPPathModifier = v1.HTTPPathModifier 217 218 // HTTPRequestRedirect defines a filter that redirects a request. This filter 219 // MUST NOT be used on the same Route rule as a HTTPURLRewrite filter. 220 // +k8s:deepcopy-gen=false 221 type HTTPRequestRedirectFilter = v1.HTTPRequestRedirectFilter 222 223 // HTTPURLRewriteFilter defines a filter that modifies a request during 224 // forwarding. At most one of these filters may be used on a Route rule. This 225 // MUST NOT be used on the same Route rule as a HTTPRequestRedirect filter. 226 // 227 // Support: Extended 228 // 229 // <gateway:experimental> 230 // +k8s:deepcopy-gen=false 231 type HTTPURLRewriteFilter = v1.HTTPURLRewriteFilter 232 233 // HTTPRequestMirrorFilter defines configuration for the RequestMirror filter. 234 // +k8s:deepcopy-gen=false 235 type HTTPRequestMirrorFilter = v1.HTTPRequestMirrorFilter 236 237 // HTTPBackendRef defines how a HTTPRoute should forward an HTTP request. 238 // +k8s:deepcopy-gen=false 239 type HTTPBackendRef = v1.HTTPBackendRef 240 241 // HTTPRouteStatus defines the observed state of HTTPRoute. 242 // +k8s:deepcopy-gen=false 243 type HTTPRouteStatus = v1.HTTPRouteStatus 244