Skip to content

Commit 5b2dabf

Browse files
committed
✨ elbv2/tg/api: expose API to customize LB/TG health check config
Expose the target health check attributes/API allowing customizations for both API (default from LB), and additional listeners, for each Load Balancer. Considering the risk of wrong configurations, the The customization for the target group attributes of API listener is limited to the health check probe configurations (interval, timeout, threshold, etc). The health check for the additional listeners can be customized, including health check protocol, port, path, etc
1 parent e9c8095 commit 5b2dabf

8 files changed

+588
-7
lines changed

api/v1beta1/awscluster_conversion.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ func restoreIPAMPool(restored, dst *infrav2.IPAMPool) {
152152
func restoreControlPlaneLoadBalancer(restored, dst *infrav2.AWSLoadBalancerSpec) {
153153
dst.Name = restored.Name
154154
dst.HealthCheckProtocol = restored.HealthCheckProtocol
155+
dst.HealthCheck = restored.HealthCheck
155156
dst.LoadBalancerType = restored.LoadBalancerType
156157
dst.DisableHostsRewrite = restored.DisableHostsRewrite
157158
dst.PreserveClientIP = restored.PreserveClientIP

api/v1beta1/zz_generated.conversion.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta2/awscluster_types.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,10 @@ type AWSLoadBalancerSpec struct {
220220
// +optional
221221
HealthCheckProtocol *ELBProtocol `json:"healthCheckProtocol,omitempty"`
222222

223+
// HealthCheck sets custom health check configuration to the API target group.
224+
// +optional
225+
HealthCheck *TargetGroupHealthCheckAPISpec `json:"healthCheck,omitempty"`
226+
223227
// AdditionalSecurityGroups sets the security groups used by the load balancer. Expected to be security group IDs
224228
// This is optional - if not provided new security groups will be created for the load balancer
225229
// +optional
@@ -257,11 +261,16 @@ type AdditionalListenerSpec struct {
257261
// +kubebuilder:validation:Minimum=1
258262
// +kubebuilder:validation:Maximum=65535
259263
Port int64 `json:"port"`
264+
260265
// Protocol sets the protocol for the additional listener.
261266
// Currently only TCP is supported.
262267
// +kubebuilder:validation:Enum=TCP
263268
// +kubebuilder:default=TCP
264269
Protocol ELBProtocol `json:"protocol,omitempty"`
270+
271+
// HealthCheck sets the optional custom health check configuration to the API target group.
272+
// +optional
273+
HealthCheck *TargetGroupHealthCheckAdditionalSpec `json:"healthCheck,omitempty"`
265274
}
266275

267276
// AWSClusterStatus defines the observed state of AWSCluster.

api/v1beta2/network_types.go

Lines changed: 84 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,90 @@ var (
104104

105105
// TargetGroupHealthCheck defines health check settings for the target group.
106106
type TargetGroupHealthCheck struct {
107-
Protocol *string `json:"protocol,omitempty"`
108-
Path *string `json:"path,omitempty"`
109-
Port *string `json:"port,omitempty"`
110-
IntervalSeconds *int64 `json:"intervalSeconds,omitempty"`
111-
TimeoutSeconds *int64 `json:"timeoutSeconds,omitempty"`
112-
ThresholdCount *int64 `json:"thresholdCount,omitempty"`
107+
Protocol *string `json:"protocol,omitempty"`
108+
Path *string `json:"path,omitempty"`
109+
Port *string `json:"port,omitempty"`
110+
IntervalSeconds *int64 `json:"intervalSeconds,omitempty"`
111+
TimeoutSeconds *int64 `json:"timeoutSeconds,omitempty"`
112+
ThresholdCount *int64 `json:"thresholdCount,omitempty"`
113+
UnhealthyThresholdCount *int64 `json:"unhealthyThresholdCount,omitempty"`
114+
}
115+
116+
// TargetGroupHealthCheckAPISpec defines the optional health check settings for the API target group.
117+
type TargetGroupHealthCheckAPISpec struct {
118+
// The approximate amount of time, in seconds, between health checks of an individual
119+
// target.
120+
// +kubebuilder:validation:Minimum=5
121+
// +kubebuilder:validation:Maximum=300
122+
// +optional
123+
IntervalSeconds *int64 `json:"intervalSeconds,omitempty"`
124+
125+
// The amount of time, in seconds, during which no response from a target means
126+
// a failed health check.
127+
// +kubebuilder:validation:Minimum=2
128+
// +kubebuilder:validation:Maximum=120
129+
// +optional
130+
TimeoutSeconds *int64 `json:"timeoutSeconds,omitempty"`
131+
132+
// The number of consecutive health check successes required before considering
133+
// a target healthy.
134+
// +kubebuilder:validation:Minimum=2
135+
// +kubebuilder:validation:Maximum=10
136+
// +optional
137+
ThresholdCount *int64 `json:"thresholdCount,omitempty"`
138+
139+
// The number of consecutive health check failures required before considering
140+
// a target unhealthy.
141+
// +kubebuilder:validation:Minimum=2
142+
// +kubebuilder:validation:Maximum=10
143+
// +optional
144+
UnhealthyThresholdCount *int64 `json:"unhealthyThresholdCount,omitempty"`
145+
}
146+
147+
// TargetGroupHealthCheckAdditionalSpec defines the optional health check settings for the additional target groups.
148+
type TargetGroupHealthCheckAdditionalSpec struct {
149+
// The protocol to use to health check connect with the target. When not specified the Protocol
150+
// will be the same of the listener.
151+
// +kubebuilder:validation:Enum=TCP;HTTP;HTTPS
152+
// +optional
153+
Protocol *string `json:"protocol,omitempty"`
154+
155+
// The port the load balancer uses when performing health checks for additional target groups. When
156+
// not specified this value will be set for the same of listener port.
157+
// +optional
158+
Port *string `json:"port,omitempty"`
159+
160+
// The destination for health checks on the targets when using the protocol HTTP or HTTPS,
161+
// otherwise the path will be ignored.
162+
// +optional
163+
Path *string `json:"path,omitempty"`
164+
// The approximate amount of time, in seconds, between health checks of an individual
165+
// target.
166+
// +kubebuilder:validation:Minimum=5
167+
// +kubebuilder:validation:Maximum=300
168+
// +optional
169+
IntervalSeconds *int64 `json:"intervalSeconds,omitempty"`
170+
171+
// The amount of time, in seconds, during which no response from a target means
172+
// a failed health check.
173+
// +kubebuilder:validation:Minimum=2
174+
// +kubebuilder:validation:Maximum=120
175+
// +optional
176+
TimeoutSeconds *int64 `json:"timeoutSeconds,omitempty"`
177+
178+
// The number of consecutive health check successes required before considering
179+
// a target healthy.
180+
// +kubebuilder:validation:Minimum=2
181+
// +kubebuilder:validation:Maximum=10
182+
// +optional
183+
ThresholdCount *int64 `json:"thresholdCount,omitempty"`
184+
185+
// The number of consecutive health check failures required before considering
186+
// a target unhealthy.
187+
// +kubebuilder:validation:Minimum=2
188+
// +kubebuilder:validation:Maximum=10
189+
// +optional
190+
UnhealthyThresholdCount *int64 `json:"unhealthyThresholdCount,omitempty"`
113191
}
114192

115193
// TargetGroupAttribute defines attribute key values for V2 Load Balancer Attributes.

api/v1beta2/zz_generated.deepcopy.go

Lines changed: 103 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/controlplane.cluster.x-k8s.io_awsmanagedcontrolplanes.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,6 +1462,9 @@ spec:
14621462
timeoutSeconds:
14631463
format: int64
14641464
type: integer
1465+
unhealthyThresholdCount:
1466+
format: int64
1467+
type: integer
14651468
type: object
14661469
vpcId:
14671470
type: string
@@ -1678,6 +1681,9 @@ spec:
16781681
timeoutSeconds:
16791682
format: int64
16801683
type: integer
1684+
unhealthyThresholdCount:
1685+
format: int64
1686+
type: integer
16811687
type: object
16821688
vpcId:
16831689
type: string
@@ -3364,6 +3370,9 @@ spec:
33643370
timeoutSeconds:
33653371
format: int64
33663372
type: integer
3373+
unhealthyThresholdCount:
3374+
format: int64
3375+
type: integer
33673376
type: object
33683377
vpcId:
33693378
type: string
@@ -3580,6 +3589,9 @@ spec:
35803589
timeoutSeconds:
35813590
format: int64
35823591
type: integer
3592+
unhealthyThresholdCount:
3593+
format: int64
3594+
type: integer
35833595
type: object
35843596
vpcId:
35853597
type: string

0 commit comments

Comments
 (0)