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 23 // +genclient 24 // +kubebuilder:object:root=true 25 // +kubebuilder:resource:categories=gateway-api 26 // +kubebuilder:subresource:status 27 // +kubebuilder:storageversion 28 // +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp` 29 30 // TCPRoute provides a way to route TCP requests. When combined with a Gateway 31 // listener, it can be used to forward connections on the port specified by the 32 // listener to a set of backends specified by the TCPRoute. 33 type TCPRoute struct { 34 metav1.TypeMeta `json:",inline"` 35 metav1.ObjectMeta `json:"metadata,omitempty"` 36 37 // Spec defines the desired state of TCPRoute. 38 Spec TCPRouteSpec `json:"spec"` 39 40 // Status defines the current state of TCPRoute. 41 Status TCPRouteStatus `json:"status,omitempty"` 42 } 43 44 // TCPRouteSpec defines the desired state of TCPRoute 45 type TCPRouteSpec struct { 46 CommonRouteSpec `json:",inline"` 47 48 // Rules are a list of TCP matchers and actions. 49 // 50 // +kubebuilder:validation:MinItems=1 51 // +kubebuilder:validation:MaxItems=16 52 Rules []TCPRouteRule `json:"rules"` 53 } 54 55 // TCPRouteStatus defines the observed state of TCPRoute 56 type TCPRouteStatus struct { 57 RouteStatus `json:",inline"` 58 } 59 60 // TCPRouteRule is the configuration for a given rule. 61 type TCPRouteRule struct { 62 // BackendRefs defines the backend(s) where matching requests should be 63 // sent. If unspecified or invalid (refers to a non-existent resource or a 64 // Service with no endpoints), the underlying implementation MUST actively 65 // reject connection attempts to this backend. Connection rejections must 66 // respect weight; if an invalid backend is requested to have 80% of 67 // connections, then 80% of connections must be rejected instead. 68 // 69 // Support: Core for Kubernetes Service 70 // 71 // Support: Extended for Kubernetes ServiceImport 72 // 73 // Support: Implementation-specific for any other resource 74 // 75 // Support for weight: Extended 76 // 77 // +kubebuilder:validation:MinItems=1 78 // +kubebuilder:validation:MaxItems=16 79 BackendRefs []BackendRef `json:"backendRefs,omitempty"` 80 } 81 82 // +kubebuilder:object:root=true 83 84 // TCPRouteList contains a list of TCPRoute 85 type TCPRouteList struct { 86 metav1.TypeMeta `json:",inline"` 87 metav1.ListMeta `json:"metadata,omitempty"` 88 Items []TCPRoute `json:"items"` 89 } 90