Skip to content
57 changes: 52 additions & 5 deletions apis/gateway/v1beta1/targetgroupconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ type HealthCheckConfiguration struct {
// +optional
HealthCheckPath *string `json:"healthCheckPath,omitempty"`

// healthCheckPort The port to use to connect with the target.
// healthCheckPort The port the load balancer uses when performing health checks on targets.
// The default is to use the port on which each target receives traffic from the load balancer.
// +optional
HealthCheckPort *int32 `json:"healthCheckPort,omitempty"`
HealthCheckPort *string `json:"healthCheckPort,omitempty"`

// healthCheckProtocol The protocol to use to connect with the target. The GENEVE, TLS, UDP, and TCP_UDP protocols are not supported for health checks.
// +optional
Expand Down Expand Up @@ -116,6 +117,18 @@ const (
TargetGroupHealthCheckProtocolTCP TargetGroupHealthCheckProtocol = "tcp"
)

// +kubebuilder:validation:Enum=HTTP;HTTPS;TCP;TLS;UDP;TCP_UDP
type Protocol string

const (
ProtocolHTTP Protocol = "HTTP"
ProtocolHTTPS Protocol = "HTTPS"
ProtocolTCP Protocol = "TCP"
ProtocolTLS Protocol = "TLS"
ProtocolUDP Protocol = "UDP"
ProtocolTCP_UDP Protocol = "TCP_UDP"
)

// +kubebuilder:validation:Enum=http1;http2;grpc
type ProtocolVersion string

Expand All @@ -125,12 +138,23 @@ const (
ProtocolVersionGRPC ProtocolVersion = "grpc"
)

// +kubebuilder:validation:Enum=none;prefer-route-specific;prefer-default
type MergeMode string

const (
MergeModeNone MergeMode = "none"
MergeModePreferRouteSpecific MergeMode = "prefer-route-specific"
MergeModePreferDefault MergeMode = "prefer-default"
)

// TargetGroupConfigurationSpec defines the TargetGroup properties for a route.
type TargetGroupConfigurationSpec struct {

// targetReference the kubernetes object to attach the Target Group settings to.
TargetReference Reference `json:"targetReference"`

// mergeMode the mode to use for merging the identified per-route configuration and default configuration.

// defaultRouteConfiguration fallback configuration applied to all routes, unless overridden by route-specific configurations.
// +optional
DefaultConfiguration TargetGroupProps `json:"defaultConfiguration,omitempty"`
Expand All @@ -141,19 +165,23 @@ type TargetGroupConfigurationSpec struct {
}

// +kubebuilder:validation:Pattern="^(HTTPRoute|TLSRoute|TCPRoute|UDPRoute|GRPCRoute)?:([^:]+)?:([^:]+)?$"
type RouteName string
type RouteIdentifier string

// RouteConfiguration defines the per route configuration
type RouteConfiguration struct {
// name the name of the route, it should be in the form of ROUTE:NAMESPACE:NAME
Name RouteName `json:"name"`
// name the identifier of the route, it should be in the form of ROUTE:NAMESPACE:NAME
Identifier RouteIdentifier `json:"identifier"`

// targetGroupProps the target group specific properties
TargetGroupProps TargetGroupProps `json:"targetGroupProps"`
}

// TargetGroupProps defines the target group properties
type TargetGroupProps struct {
// targetGroupName specifies the name to assign to the Target Group. If not defined, then one is generated.
// +optional
TargetGroupName string `json:"targetGroupName,omitempty"`

// ipAddressType specifies whether the target group is of type IPv4 or IPv6. If unspecified, it will be automatically inferred.
// +optional
IPAddressType *TargetGroupIPAddressType `json:"ipAddressType,omitempty"`
Expand All @@ -174,10 +202,25 @@ type TargetGroupProps struct {
// +optional
TargetType *TargetType `json:"targetType,omitempty"`

// Protocol [Application / Network Load Balancer] the protocol for the target group.
// If unspecified, it will be automatically inferred.
// +optional
Protocol *Protocol `json:"protocol,omitempty"`

// protocolVersion [HTTP/HTTPS protocol] The protocol version. The possible values are GRPC , HTTP1 and HTTP2
// +optional
ProtocolVersion *ProtocolVersion `json:"protocolVersion,omitempty"`

// enableProxyProtocolV2 [Network LoadBalancers] Indicates whether proxy protocol version 2 is enabled.
// By default, proxy protocol is disabled.
// +optional
EnableProxyProtocolV2 *bool `json:"enableProxyProtocolV2,omitempty"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets infer this from the attributes value instead of creating a dedicated field.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense.


// EnableMultiCluster [Application / Network LoadBalancer]
// Allows for multiple Clusters / Services to use the generated TargetGroup ARN
// +optional
EnableMultiCluster bool `json:"enableMultiCluster,omitempty"`

// vpcID is the VPC of the TargetGroup. If unspecified, it will be automatically inferred.
// +optional
VpcID *string `json:"vpcID,omitempty"`
Expand Down Expand Up @@ -231,6 +274,10 @@ type TargetGroupConfiguration struct {
Status TargetGroupConfigurationStatus `json:"status,omitempty"`
}

func (tgConfig *TargetGroupConfiguration) GetTargetGroupConfigForRoute(name, namespace, kind string) *TargetGroupProps {
return &tgConfig.Spec.DefaultConfiguration
}

// +kubebuilder:object:root=true

// TargetGroupConfigurationList contains a list of TargetGroupConfiguration
Expand Down
12 changes: 11 additions & 1 deletion apis/gateway/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading