-
Notifications
You must be signed in to change notification settings - Fork 637
🐛fix: classic elb fix for TLS issues #5346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
k8s-ci-robot
merged 1 commit into
kubernetes-sigs:main
from
richardcase:classic_elb_130_fix
Mar 4, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -33,6 +33,11 @@ import ( | |||||||||
| "sigs.k8s.io/cluster-api/util/annotations" | ||||||||||
| ) | ||||||||||
|
|
||||||||||
| const ( | ||||||||||
| warningClassicELB = "%s load balancer is using a classic elb which is deprecated & support will be removed in a future release, please consider using another type of load balancer instead" | ||||||||||
| warningHealthCheckProtocolNotSet = "healthcheck protocol is not set, the default value has changed from SSL to TCP. Health checks for existing clusters will be updated to TCP" | ||||||||||
| ) | ||||||||||
|
|
||||||||||
| // log is for logging in this package. | ||||||||||
| var _ = ctrl.Log.WithName("awscluster-resource") | ||||||||||
|
|
||||||||||
|
|
@@ -53,15 +58,23 @@ var ( | |||||||||
| // ValidateCreate implements webhook.Validator so a webhook will be registered for the type. | ||||||||||
| func (r *AWSCluster) ValidateCreate() (admission.Warnings, error) { | ||||||||||
| var allErrs field.ErrorList | ||||||||||
| var allWarnings admission.Warnings | ||||||||||
|
|
||||||||||
| allErrs = append(allErrs, r.Spec.Bastion.Validate()...) | ||||||||||
| allErrs = append(allErrs, r.validateSSHKeyName()...) | ||||||||||
| allErrs = append(allErrs, r.Spec.AdditionalTags.Validate()...) | ||||||||||
| allErrs = append(allErrs, r.Spec.S3Bucket.Validate()...) | ||||||||||
| allErrs = append(allErrs, r.validateNetwork()...) | ||||||||||
| allErrs = append(allErrs, r.validateControlPlaneLBs()...) | ||||||||||
|
|
||||||||||
| return nil, aggregateObjErrors(r.GroupVersionKind().GroupKind(), r.Name, allErrs) | ||||||||||
| warnings, errs := r.validateControlPlaneLBs() | ||||||||||
| if len(errs) > 0 { | ||||||||||
| allErrs = append(allErrs, errs...) | ||||||||||
| } | ||||||||||
| if len(warnings) > 0 { | ||||||||||
| allWarnings = append(allWarnings, warnings...) | ||||||||||
| } | ||||||||||
|
|
||||||||||
| return allWarnings, aggregateObjErrors(r.GroupVersionKind().GroupKind(), r.Name, allErrs) | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // ValidateDelete implements webhook.Validator so a webhook will be registered for the type. | ||||||||||
|
|
@@ -72,6 +85,7 @@ func (r *AWSCluster) ValidateDelete() (admission.Warnings, error) { | |||||||||
| // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. | ||||||||||
| func (r *AWSCluster) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { | ||||||||||
| var allErrs field.ErrorList | ||||||||||
| var allWarnings admission.Warnings | ||||||||||
|
|
||||||||||
| allErrs = append(allErrs, r.validateGCTasksAnnotation()...) | ||||||||||
|
|
||||||||||
|
|
@@ -139,7 +153,23 @@ func (r *AWSCluster) ValidateUpdate(old runtime.Object) (admission.Warnings, err | |||||||||
| allErrs = append(allErrs, r.Spec.AdditionalTags.Validate()...) | ||||||||||
| allErrs = append(allErrs, r.Spec.S3Bucket.Validate()...) | ||||||||||
|
|
||||||||||
| return nil, aggregateObjErrors(r.GroupVersionKind().GroupKind(), r.Name, allErrs) | ||||||||||
| if r.Spec.ControlPlaneLoadBalancer != nil { | ||||||||||
| if r.Spec.ControlPlaneLoadBalancer.LoadBalancerType == LoadBalancerTypeClassic { | ||||||||||
| allWarnings = append(allWarnings, fmt.Sprintf(warningClassicELB, "primary control plane")) | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| if r.Spec.SecondaryControlPlaneLoadBalancer != nil { | ||||||||||
| if r.Spec.SecondaryControlPlaneLoadBalancer.LoadBalancerType == LoadBalancerTypeClassic { | ||||||||||
| allWarnings = append(allWarnings, fmt.Sprintf(warningClassicELB, "secondary control plane")) | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| if r.Spec.ControlPlaneLoadBalancer == nil || r.Spec.ControlPlaneLoadBalancer.HealthCheckProtocol == nil { | ||||||||||
| allWarnings = append(allWarnings, fmt.Sprintf("%s. Existing load balancers will be updates", warningHealthCheckProtocolNotSet)) | ||||||||||
| } | ||||||||||
|
|
||||||||||
| return allWarnings, aggregateObjErrors(r.GroupVersionKind().GroupKind(), r.Name, allErrs) | ||||||||||
| } | ||||||||||
|
|
||||||||||
| func (r *AWSCluster) validateControlPlaneLoadBalancerUpdate(oldlb, newlb *AWSLoadBalancerSpec) field.ErrorList { | ||||||||||
|
|
@@ -184,11 +214,13 @@ func (r *AWSCluster) validateControlPlaneLoadBalancerUpdate(oldlb, newlb *AWSLoa | |||||||||
| // Block the update for Protocol : | ||||||||||
| // - if it was not set in old spec but added in new spec | ||||||||||
| // - if it was set in old spec but changed in new spec | ||||||||||
| if !cmp.Equal(newlb.HealthCheckProtocol, oldlb.HealthCheckProtocol) { | ||||||||||
| allErrs = append(allErrs, | ||||||||||
| field.Invalid(field.NewPath("spec", "controlPlaneLoadBalancer", "healthCheckProtocol"), | ||||||||||
| newlb.HealthCheckProtocol, "field is immutable once set"), | ||||||||||
| ) | ||||||||||
| if oldlb.LoadBalancerType != LoadBalancerTypeClassic { | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I think a comment might be helpful.
Suggested change
|
||||||||||
| if !cmp.Equal(newlb.HealthCheckProtocol, oldlb.HealthCheckProtocol) { | ||||||||||
| allErrs = append(allErrs, | ||||||||||
| field.Invalid(field.NewPath("spec", "controlPlaneLoadBalancer", "healthCheckProtocol"), | ||||||||||
| newlb.HealthCheckProtocol, "field is immutable once set"), | ||||||||||
| ) | ||||||||||
| } | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
|
|
@@ -301,8 +333,21 @@ func (r *AWSCluster) validateNetwork() field.ErrorList { | |||||||||
| return allErrs | ||||||||||
| } | ||||||||||
|
|
||||||||||
| func (r *AWSCluster) validateControlPlaneLBs() field.ErrorList { | ||||||||||
| func (r *AWSCluster) validateControlPlaneLBs() (admission.Warnings, field.ErrorList) { | ||||||||||
| var allErrs field.ErrorList | ||||||||||
| var allWarnings admission.Warnings | ||||||||||
|
|
||||||||||
| if r.Spec.ControlPlaneLoadBalancer != nil && r.Spec.ControlPlaneLoadBalancer.LoadBalancerType == LoadBalancerTypeClassic { | ||||||||||
| allWarnings = append(allWarnings, fmt.Sprintf(warningClassicELB, "primary control plane")) | ||||||||||
|
|
||||||||||
| if r.Spec.ControlPlaneLoadBalancer.HealthCheckProtocol == nil { | ||||||||||
| allWarnings = append(allWarnings, warningHealthCheckProtocolNotSet) | ||||||||||
| } | ||||||||||
|
|
||||||||||
| if r.Spec.ControlPlaneLoadBalancer.HealthCheckProtocol != nil && *r.Spec.ControlPlaneLoadBalancer.HealthCheckProtocol == ELBProtocolSSL { | ||||||||||
| allWarnings = append(allWarnings, "loadbalancer is using a classic elb with SSL health check, this causes issues with ciper suites with kubernetes v1.30+") | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // If the secondary is defined, check that the name is not empty and different from the primary. | ||||||||||
| // Also, ensure that the secondary load balancer is an NLB | ||||||||||
|
|
@@ -322,6 +367,9 @@ func (r *AWSCluster) validateControlPlaneLBs() field.ErrorList { | |||||||||
| if r.Spec.SecondaryControlPlaneLoadBalancer.LoadBalancerType != LoadBalancerTypeNLB { | ||||||||||
| allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "secondaryControlPlaneLoadBalancer", "loadBalancerType"), r.Spec.SecondaryControlPlaneLoadBalancer.LoadBalancerType, "secondary control plane load balancer must be a Network Load Balancer")) | ||||||||||
| } | ||||||||||
| if r.Spec.SecondaryControlPlaneLoadBalancer.LoadBalancerType == LoadBalancerTypeClassic { | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this needed if we're also setting an error for this case on L367? |
||||||||||
| allWarnings = append(allWarnings, fmt.Sprintf(warningClassicELB, "secondary control plane")) | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // Additional listeners are only supported for NLBs. | ||||||||||
|
|
@@ -378,7 +426,7 @@ func (r *AWSCluster) validateControlPlaneLBs() field.ErrorList { | |||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| return allErrs | ||||||||||
| return allWarnings, allErrs | ||||||||||
| } | ||||||||||
|
|
||||||||||
| func (r *AWSCluster) validateIngressRule(rule IngressRule) field.ErrorList { | ||||||||||
|
|
||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This case shouldn't even be possible, see the webhook: https://github.com/kubernetes-sigs/cluster-api-provider-aws/blob/main/api/v1beta2/awscluster_webhook.go#L322
That being said, I think we can remove this code in a follow up PR rather than block this further.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch!
Also see #5346 (comment)