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 v1 "sigs.k8s.io/gateway-api/apis/v1" 20 21 // ParentReference identifies an API object (usually a Gateway) that can be considered 22 // a parent of this resource (usually a route). The only kind of parent resource 23 // with "Core" support is Gateway. This API may be extended in the future to 24 // support additional kinds of parent resources, such as HTTPRoute. 25 // 26 // Note that there are specific rules for ParentRefs which cross namespace 27 // boundaries. Cross-namespace references are only valid if they are explicitly 28 // allowed by something in the namespace they are referring to. For example: 29 // Gateway has the AllowedRoutes field, and ReferenceGrant provides a 30 // generic way to enable any other kind of cross-namespace reference. 31 // 32 // The API object must be valid in the cluster; the Group and Kind must 33 // be registered in the cluster for this reference to be valid. 34 // +k8s:deepcopy-gen=false 35 type ParentReference = v1.ParentReference 36 37 // CommonRouteSpec defines the common attributes that all Routes MUST include 38 // within their spec. 39 // +k8s:deepcopy-gen=false 40 type CommonRouteSpec = v1.CommonRouteSpec 41 42 // PortNumber defines a network port. 43 // 44 // +kubebuilder:validation:Minimum=1 45 // +kubebuilder:validation:Maximum=65535 46 type PortNumber = v1.PortNumber 47 48 // BackendRef defines how a Route should forward a request to a Kubernetes 49 // resource. 50 // 51 // Note that when a namespace different than the local namespace is specified, a 52 // ReferenceGrant object is required in the referent namespace to allow that 53 // namespace's owner to accept the reference. See the ReferenceGrant 54 // documentation for details. 55 // +k8s:deepcopy-gen=false 56 type BackendRef = v1.BackendRef 57 58 // RouteConditionType is a type of condition for a route. 59 type RouteConditionType = v1.RouteConditionType 60 61 // RouteConditionReason is a reason for a route condition. 62 type RouteConditionReason = v1.RouteConditionReason 63 64 const ( 65 // This condition indicates whether the route has been accepted or rejected 66 // by a Gateway, and why. 67 // 68 // Possible reasons for this condition to be true are: 69 // 70 // * "Accepted" 71 // 72 // Possible reasons for this condition to be False are: 73 // 74 // * "NotAllowedByListeners" 75 // * "NoMatchingListenerHostname" 76 // * "UnsupportedValue" 77 // 78 // Possible reasons for this condition to be Unknown are: 79 // 80 // * "Pending" 81 // 82 // Controllers may raise this condition with other reasons, 83 // but should prefer to use the reasons listed above to improve 84 // interoperability. 85 RouteConditionAccepted RouteConditionType = "Accepted" 86 87 // This reason is used with the "Accepted" condition when the Route has been 88 // accepted by the Gateway. 89 RouteReasonAccepted RouteConditionReason = "Accepted" 90 91 // This reason is used with the "Accepted" condition when the route has not 92 // been accepted by a Gateway because the Gateway has no Listener whose 93 // allowedRoutes criteria permit the route 94 RouteReasonNotAllowedByListeners RouteConditionReason = "NotAllowedByListeners" 95 96 // This reason is used with the "Accepted" condition when the Gateway has no 97 // compatible Listeners whose Hostname matches the route 98 RouteReasonNoMatchingListenerHostname RouteConditionReason = "NoMatchingListenerHostname" 99 100 // This reason is used with the "Accepted" condition when a value for an Enum 101 // is not recognized. 102 RouteReasonUnsupportedValue RouteConditionReason = "UnsupportedValue" 103 104 // This reason is used with the "Accepted" when a controller has not yet 105 // reconciled the route. 106 RouteReasonPending RouteConditionReason = "Pending" 107 108 // This condition indicates whether the controller was able to resolve all 109 // the object references for the Route. 110 // 111 // Possible reasons for this condition to be true are: 112 // 113 // * "ResolvedRefs" 114 // 115 // Possible reasons for this condition to be false are: 116 // 117 // * "RefNotPermitted" 118 // * "InvalidKind" 119 // * "BackendNotFound" 120 // 121 // Controllers may raise this condition with other reasons, 122 // but should prefer to use the reasons listed above to improve 123 // interoperability. 124 RouteConditionResolvedRefs RouteConditionType = "ResolvedRefs" 125 126 // This reason is used with the "ResolvedRefs" condition when the condition 127 // is true. 128 RouteReasonResolvedRefs RouteConditionReason = "ResolvedRefs" 129 130 // This reason is used with the "ResolvedRefs" condition when 131 // one of the Listener's Routes has a BackendRef to an object in 132 // another namespace, where the object in the other namespace does 133 // not have a ReferenceGrant explicitly allowing the reference. 134 RouteReasonRefNotPermitted RouteConditionReason = "RefNotPermitted" 135 136 // This reason is used with the "ResolvedRefs" condition when 137 // one of the Route's rules has a reference to an unknown or unsupported 138 // Group and/or Kind. 139 RouteReasonInvalidKind RouteConditionReason = "InvalidKind" 140 141 // This reason is used with the "ResolvedRefs" condition when one of the 142 // Route's rules has a reference to a resource that does not exist. 143 RouteReasonBackendNotFound RouteConditionReason = "BackendNotFound" 144 ) 145 146 // RouteParentStatus describes the status of a route with respect to an 147 // associated Parent. 148 // +k8s:deepcopy-gen=false 149 type RouteParentStatus = v1.RouteParentStatus 150 151 // RouteStatus defines the common attributes that all Routes MUST include within 152 // their status. 153 // +k8s:deepcopy-gen=false 154 type RouteStatus = v1.RouteStatus 155 156 // Hostname is the fully qualified domain name of a network host. This matches 157 // the RFC 1123 definition of a hostname with 2 notable exceptions: 158 // 159 // 1. IPs are not allowed. 160 // 2. A hostname may be prefixed with a wildcard label (`*.`). The wildcard 161 // label must appear by itself as the first label. 162 // 163 // Hostname can be "precise" which is a domain name without the terminating 164 // dot of a network host (e.g. "foo.example.com") or "wildcard", which is a 165 // domain name prefixed with a single wildcard label (e.g. `*.example.com`). 166 // 167 // Note that as per RFC1035 and RFC1123, a *label* must consist of lower case 168 // alphanumeric characters or '-', and must start and end with an alphanumeric 169 // character. No other punctuation is allowed. 170 // 171 // +kubebuilder:validation:MinLength=1 172 // +kubebuilder:validation:MaxLength=253 173 // +kubebuilder:validation:Pattern=`^(\*\.)?[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$` 174 type Hostname = v1.Hostname 175 176 // PreciseHostname is the fully qualified domain name of a network host. This 177 // matches the RFC 1123 definition of a hostname with 1 notable exception that 178 // numeric IP addresses are not allowed. 179 // 180 // Note that as per RFC1035 and RFC1123, a *label* must consist of lower case 181 // alphanumeric characters or '-', and must start and end with an alphanumeric 182 // character. No other punctuation is allowed. 183 // 184 // +kubebuilder:validation:MinLength=1 185 // +kubebuilder:validation:MaxLength=253 186 // +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$` 187 type PreciseHostname = v1.PreciseHostname 188 189 // Group refers to a Kubernetes Group. It must either be an empty string or a 190 // RFC 1123 subdomain. 191 // 192 // This validation is based off of the corresponding Kubernetes validation: 193 // https://github.com/kubernetes/apimachinery/blob/02cfb53916346d085a6c6c7c66f882e3c6b0eca6/pkg/util/validation/validation.go#L208 194 // 195 // Valid values include: 196 // 197 // * "" - empty string implies core Kubernetes API group 198 // * "networking.k8s.io" 199 // * "foo.example.com" 200 // 201 // Invalid values include: 202 // 203 // * "example.com/bar" - "/" is an invalid character 204 // 205 // +kubebuilder:validation:MaxLength=253 206 // +kubebuilder:validation:Pattern=`^$|^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$` 207 type Group = v1.Group 208 209 // Kind refers to a Kubernetes Kind. 210 // 211 // Valid values include: 212 // 213 // * "Service" 214 // * "HTTPRoute" 215 // 216 // Invalid values include: 217 // 218 // * "invalid/kind" - "/" is an invalid character 219 // 220 // +kubebuilder:validation:MinLength=1 221 // +kubebuilder:validation:MaxLength=63 222 // +kubebuilder:validation:Pattern=`^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$` 223 type Kind = v1.Kind 224 225 // ObjectName refers to the name of a Kubernetes object. 226 // Object names can have a variety of forms, including RFC1123 subdomains, 227 // RFC 1123 labels, or RFC 1035 labels. 228 // 229 // +kubebuilder:validation:MinLength=1 230 // +kubebuilder:validation:MaxLength=253 231 type ObjectName = v1.ObjectName 232 233 // Namespace refers to a Kubernetes namespace. It must be a RFC 1123 label. 234 // 235 // This validation is based off of the corresponding Kubernetes validation: 236 // https://github.com/kubernetes/apimachinery/blob/02cfb53916346d085a6c6c7c66f882e3c6b0eca6/pkg/util/validation/validation.go#L187 237 // 238 // This is used for Namespace name validation here: 239 // https://github.com/kubernetes/apimachinery/blob/02cfb53916346d085a6c6c7c66f882e3c6b0eca6/pkg/api/validation/generic.go#L63 240 // 241 // Valid values include: 242 // 243 // * "example" 244 // 245 // Invalid values include: 246 // 247 // * "example.com" - "." is an invalid character 248 // 249 // +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?$` 250 // +kubebuilder:validation:MinLength=1 251 // +kubebuilder:validation:MaxLength=63 252 type Namespace = v1.Namespace 253 254 // SectionName is the name of a section in a Kubernetes resource. 255 // 256 // This validation is based off of the corresponding Kubernetes validation: 257 // https://github.com/kubernetes/apimachinery/blob/02cfb53916346d085a6c6c7c66f882e3c6b0eca6/pkg/util/validation/validation.go#L208 258 // 259 // Valid values include: 260 // 261 // * "example.com" 262 // * "foo.example.com" 263 // 264 // Invalid values include: 265 // 266 // * "example.com/bar" - "/" is an invalid character 267 // 268 // +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$` 269 // +kubebuilder:validation:MinLength=1 270 // +kubebuilder:validation:MaxLength=253 271 type SectionName = v1.SectionName 272 273 // GatewayController is the name of a Gateway API controller. It must be a 274 // domain prefixed path. 275 // 276 // Valid values include: 277 // 278 // * "example.com/bar" 279 // 280 // Invalid values include: 281 // 282 // * "example.com" - must include path 283 // * "foo.example.com" - must include path 284 // 285 // +kubebuilder:validation:MinLength=1 286 // +kubebuilder:validation:MaxLength=253 287 // +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*\/[A-Za-z0-9\/\-._~%!$&'()*+,;=:]+$` 288 type GatewayController = v1.GatewayController 289 290 // AnnotationKey is the key of an annotation in Gateway API. This is used for 291 // validation of maps such as TLS options. This matches the Kubernetes 292 // "qualified name" validation that is used for annotations and other common 293 // values. 294 // 295 // Valid values include: 296 // 297 // * example 298 // * example.com 299 // * example.com/path 300 // * example.com/path.html 301 // 302 // Invalid values include: 303 // 304 // * example~ - "~" is an invalid character 305 // * example.com. - can not start or end with "." 306 // 307 // +kubebuilder:validation:MinLength=1 308 // +kubebuilder:validation:MaxLength=253 309 // +kubebuilder:validation:Pattern=`^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]/?)*$` 310 type AnnotationKey = v1.AnnotationKey 311 312 // AnnotationValue is the value of an annotation in Gateway API. This is used 313 // for validation of maps such as TLS options. This roughly matches Kubernetes 314 // annotation validation, although the length validation in that case is based 315 // on the entire size of the annotations struct. 316 // 317 // +kubebuilder:validation:MinLength=0 318 // +kubebuilder:validation:MaxLength=4096 319 type AnnotationValue = v1.AnnotationValue 320 321 // AddressType defines how a network address is represented as a text string. 322 // This may take two possible forms: 323 // 324 // * A predefined CamelCase string identifier (currently limited to `IPAddress` or `Hostname`) 325 // * A domain-prefixed string identifier (like `acme.io/CustomAddressType`) 326 // 327 // Values `IPAddress` and `Hostname` have Extended support. 328 // 329 // The `NamedAddress` value has been deprecated in favor of implementation 330 // specific domain-prefixed strings. 331 // 332 // All other values, including domain-prefixed values have Implementation-specific support, 333 // which are used in implementation-specific behaviors. Support for additional 334 // predefined CamelCase identifiers may be added in future releases. 335 // 336 // +kubebuilder:validation:MinLength=1 337 // +kubebuilder:validation:MaxLength=253 338 // +kubebuilder:validation:Pattern=`^Hostname|IPAddress|NamedAddress|[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*\/[A-Za-z0-9\/\-._~%!$&'()*+,;=:]+$` 339 type AddressType = v1.AddressType 340 341 // Duration is a string value representing a duration in time. The format is as specified 342 // in GEP-2257, a strict subset of the syntax parsed by Golang time.ParseDuration. 343 type Duration = v1.Duration 344 345 const ( 346 // A textual representation of a numeric IP address. IPv4 347 // addresses must be in dotted-decimal form. IPv6 addresses 348 // must be in a standard IPv6 text representation 349 // (see [RFC 5952](https://tools.ietf.org/html/rfc5952)). 350 // 351 // This type is intended for specific addresses. Address ranges are not 352 // supported (e.g. you can not use a CIDR range like 127.0.0.0/24 as an 353 // IPAddress). 354 // 355 // Support: Extended 356 IPAddressType AddressType = "IPAddress" 357 358 // A Hostname represents a DNS based ingress point. This is similar to the 359 // corresponding hostname field in Kubernetes load balancer status. For 360 // example, this concept may be used for cloud load balancers where a DNS 361 // name is used to expose a load balancer. 362 // 363 // Support: Extended 364 HostnameAddressType AddressType = "Hostname" 365 366 // A NamedAddress provides a way to reference a specific IP address by name. 367 // For example, this may be a name or other unique identifier that refers 368 // to a resource on a cloud provider such as a static IP. 369 // 370 // The `NamedAddress` type has been deprecated in favor of implementation 371 // specific domain-prefixed strings. 372 // 373 // Support: Implementation-specific 374 NamedAddressType AddressType = "NamedAddress" 375 ) 376