Skip to content

Commit 4178d3a

Browse files
authored
Merge pull request #4220 from zac-nixon/znixon/tg-config
[gw api] Add TG config logic to find and create user specified TG config.
2 parents d56faca + fbcd85e commit 4178d3a

16 files changed

+1042
-292
lines changed

apis/gateway/v1beta1/targetgroupconfig_types.go

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -153,24 +153,26 @@ type TargetGroupConfigurationSpec struct {
153153
// targetReference the kubernetes object to attach the Target Group settings to.
154154
TargetReference Reference `json:"targetReference"`
155155

156-
// mergeMode the mode to use for merging the identified per-route configuration and default configuration.
157-
158156
// defaultRouteConfiguration fallback configuration applied to all routes, unless overridden by route-specific configurations.
159157
// +optional
160158
DefaultConfiguration TargetGroupProps `json:"defaultConfiguration,omitempty"`
161159

162-
// routeConfigurations the route configuration for specific routes
160+
// routeConfigurations the route configuration for specific routes. the longest prefix match (kind:namespace:name) is taken to combine with the default properties.
163161
// +optional
164162
RouteConfigurations []RouteConfiguration `json:"routeConfigurations,omitempty"`
165163
}
166164

167-
// +kubebuilder:validation:Pattern="^(HTTPRoute|TLSRoute|TCPRoute|UDPRoute|GRPCRoute)?:([^:]+)?:([^:]+)?$"
168-
type RouteIdentifier string
165+
// RouteIdentifier the complete set of route attributes that identify a route.
166+
type RouteIdentifier struct {
167+
RouteKind string `json:"kind,omitempty"`
168+
RouteNamespace string `json:"namespace,omitempty"`
169+
RouteName string `json:"name,omitempty"`
170+
}
169171

170172
// RouteConfiguration defines the per route configuration
171173
type RouteConfiguration struct {
172174
// name the identifier of the route, it should be in the form of ROUTE:NAMESPACE:NAME
173-
Identifier RouteIdentifier `json:"identifier"`
175+
RouteIdentifier RouteIdentifier `json:"routeIdentifier"`
174176

175177
// targetGroupProps the target group specific properties
176178
TargetGroupProps TargetGroupProps `json:"targetGroupProps"`
@@ -180,7 +182,7 @@ type RouteConfiguration struct {
180182
type TargetGroupProps struct {
181183
// targetGroupName specifies the name to assign to the Target Group. If not defined, then one is generated.
182184
// +optional
183-
TargetGroupName string `json:"targetGroupName,omitempty"`
185+
TargetGroupName *string `json:"targetGroupName,omitempty"`
184186

185187
// ipAddressType specifies whether the target group is of type IPv4 or IPv6. If unspecified, it will be automatically inferred.
186188
// +optional
@@ -214,15 +216,11 @@ type TargetGroupProps struct {
214216
// EnableMultiCluster [Application / Network LoadBalancer]
215217
// Allows for multiple Clusters / Services to use the generated TargetGroup ARN
216218
// +optional
217-
EnableMultiCluster bool `json:"enableMultiCluster,omitempty"`
218-
219-
// vpcID is the VPC of the TargetGroup. If unspecified, it will be automatically inferred.
220-
// +optional
221-
VpcID *string `json:"vpcID,omitempty"`
219+
EnableMultiCluster *bool `json:"enableMultiCluster,omitempty"`
222220

223-
// Tags defines list of Tags on target group.
221+
// Tags the Tags to add on the target group.
224222
// +optional
225-
Tags []Tag `json:"tags,omitempty"`
223+
Tags *map[string]string `json:"tags,omitempty"`
226224
}
227225

228226
// TargetGroupAttribute defines target group attribute.
@@ -234,15 +232,6 @@ type TargetGroupAttribute struct {
234232
Value string `json:"value"`
235233
}
236234

237-
// Tag defines a AWS Tag on resources.
238-
type Tag struct {
239-
// The key of the tag.
240-
Key string `json:"key"`
241-
242-
// The value of the tag.
243-
Value string `json:"value"`
244-
}
245-
246235
// TODO -- these can be used to set what generation the gateway is currently on to track progress on reconcile.
247236

248237
// TargetGroupConfigurationStatus defines the observed state of TargetGroupConfiguration
@@ -269,10 +258,6 @@ type TargetGroupConfiguration struct {
269258
Status TargetGroupConfigurationStatus `json:"status,omitempty"`
270259
}
271260

272-
func (tgConfig *TargetGroupConfiguration) GetTargetGroupConfigForRoute(name, namespace, kind string) *TargetGroupProps {
273-
return &tgConfig.Spec.DefaultConfiguration
274-
}
275-
276261
// +kubebuilder:object:root=true
277262

278263
// TargetGroupConfigurationList contains a list of TargetGroupConfiguration

apis/gateway/v1beta1/zz_generated.deepcopy.go

Lines changed: 32 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/gateway/gateway-crds.yaml

Lines changed: 20 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -496,21 +496,10 @@ spec:
496496
- GRPC
497497
type: string
498498
tags:
499-
description: Tags defines list of Tags on target group.
500-
items:
501-
description: Tag defines a AWS Tag on resources.
502-
properties:
503-
key:
504-
description: The key of the tag.
505-
type: string
506-
value:
507-
description: The value of the tag.
508-
type: string
509-
required:
510-
- key
511-
- value
512-
type: object
513-
type: array
499+
additionalProperties:
500+
type: string
501+
description: Tags the Tags to add on the target group.
502+
type: object
514503
targetGroupAttributes:
515504
description: targetGroupAttributes defines the attribute of target
516505
group
@@ -539,22 +528,25 @@ spec:
539528
- instance
540529
- ip
541530
type: string
542-
vpcID:
543-
description: vpcID is the VPC of the TargetGroup. If unspecified,
544-
it will be automatically inferred.
545-
type: string
546531
type: object
547532
routeConfigurations:
548533
description: routeConfigurations the route configuration for specific
549-
routes
534+
routes. the longest prefix match (kind:namespace:name) is taken
535+
to combine with the default properties.
550536
items:
551537
description: RouteConfiguration defines the per route configuration
552538
properties:
553-
identifier:
539+
routeIdentifier:
554540
description: name the identifier of the route, it should be
555541
in the form of ROUTE:NAMESPACE:NAME
556-
pattern: ^(HTTPRoute|TLSRoute|TCPRoute|UDPRoute|GRPCRoute)?:([^:]+)?:([^:]+)?$
557-
type: string
542+
properties:
543+
kind:
544+
type: string
545+
name:
546+
type: string
547+
namespace:
548+
type: string
549+
type: object
558550
targetGroupProps:
559551
description: targetGroupProps the target group specific properties
560552
properties:
@@ -699,21 +691,10 @@ spec:
699691
- GRPC
700692
type: string
701693
tags:
702-
description: Tags defines list of Tags on target group.
703-
items:
704-
description: Tag defines a AWS Tag on resources.
705-
properties:
706-
key:
707-
description: The key of the tag.
708-
type: string
709-
value:
710-
description: The value of the tag.
711-
type: string
712-
required:
713-
- key
714-
- value
715-
type: object
716-
type: array
694+
additionalProperties:
695+
type: string
696+
description: Tags the Tags to add on the target group.
697+
type: object
717698
targetGroupAttributes:
718699
description: targetGroupAttributes defines the attribute
719700
of target group
@@ -743,13 +724,9 @@ spec:
743724
- instance
744725
- ip
745726
type: string
746-
vpcID:
747-
description: vpcID is the VPC of the TargetGroup. If unspecified,
748-
it will be automatically inferred.
749-
type: string
750727
type: object
751728
required:
752-
- identifier
729+
- routeIdentifier
753730
- targetGroupProps
754731
type: object
755732
type: array

config/crd/gateway/gateway.k8s.aws_targetgroupconfigurations.yaml

Lines changed: 20 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -191,21 +191,10 @@ spec:
191191
- GRPC
192192
type: string
193193
tags:
194-
description: Tags defines list of Tags on target group.
195-
items:
196-
description: Tag defines a AWS Tag on resources.
197-
properties:
198-
key:
199-
description: The key of the tag.
200-
type: string
201-
value:
202-
description: The value of the tag.
203-
type: string
204-
required:
205-
- key
206-
- value
207-
type: object
208-
type: array
194+
additionalProperties:
195+
type: string
196+
description: Tags the Tags to add on the target group.
197+
type: object
209198
targetGroupAttributes:
210199
description: targetGroupAttributes defines the attribute of target
211200
group
@@ -234,22 +223,25 @@ spec:
234223
- instance
235224
- ip
236225
type: string
237-
vpcID:
238-
description: vpcID is the VPC of the TargetGroup. If unspecified,
239-
it will be automatically inferred.
240-
type: string
241226
type: object
242227
routeConfigurations:
243228
description: routeConfigurations the route configuration for specific
244-
routes
229+
routes. the longest prefix match (kind:namespace:name) is taken
230+
to combine with the default properties.
245231
items:
246232
description: RouteConfiguration defines the per route configuration
247233
properties:
248-
identifier:
234+
routeIdentifier:
249235
description: name the identifier of the route, it should be
250236
in the form of ROUTE:NAMESPACE:NAME
251-
pattern: ^(HTTPRoute|TLSRoute|TCPRoute|UDPRoute|GRPCRoute)?:([^:]+)?:([^:]+)?$
252-
type: string
237+
properties:
238+
kind:
239+
type: string
240+
name:
241+
type: string
242+
namespace:
243+
type: string
244+
type: object
253245
targetGroupProps:
254246
description: targetGroupProps the target group specific properties
255247
properties:
@@ -394,21 +386,10 @@ spec:
394386
- GRPC
395387
type: string
396388
tags:
397-
description: Tags defines list of Tags on target group.
398-
items:
399-
description: Tag defines a AWS Tag on resources.
400-
properties:
401-
key:
402-
description: The key of the tag.
403-
type: string
404-
value:
405-
description: The value of the tag.
406-
type: string
407-
required:
408-
- key
409-
- value
410-
type: object
411-
type: array
389+
additionalProperties:
390+
type: string
391+
description: Tags the Tags to add on the target group.
392+
type: object
412393
targetGroupAttributes:
413394
description: targetGroupAttributes defines the attribute
414395
of target group
@@ -438,13 +419,9 @@ spec:
438419
- instance
439420
- ip
440421
type: string
441-
vpcID:
442-
description: vpcID is the VPC of the TargetGroup. If unspecified,
443-
it will be automatically inferred.
444-
type: string
445422
type: object
446423
required:
447-
- identifier
424+
- routeIdentifier
448425
- targetGroupProps
449426
type: object
450427
type: array

controllers/gateway/config_resolver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type gatewayConfigResolverImpl struct {
2121

2222
func newGatewayConfigResolver() gatewayConfigResolver {
2323
return &gatewayConfigResolverImpl{
24-
configMergeFn: gateway.NewConfigMerger().Merge,
24+
configMergeFn: gateway.NewLoadBalancerConfigMerger().Merge,
2525
configResolverFn: resolveLoadBalancerConfig,
2626
}
2727
}

0 commit comments

Comments
 (0)