Repository navigation
Keep aws-load-balancer-type when switching exposure to traefik - #850
Merged
Merged
Conversation
Switching `exposure: loadbalancer -> traefik` patches the data service from type LoadBalancer to ClusterIP. We also nulled every LB annotation in that patch, including `service.beta.kubernetes.io/aws-load-balancer-type: nlb`. The in-tree service controller reads that annotation in EnsureLoadBalancerDeleted to tell an NLB from a Classic ELB. Without it the controller takes the Classic ELB path, fails to find the NLB, removes the cleanup finalizer anyway, and leaves the NLB orphaned on AWS. Retain the type annotation through the switch (it is inert on a ClusterIP service) so Kubernetes deletes the NLB. The remaining tuning annotations are still removed. LLM assisted: Claude Opus 4.8 (1M context)
goat-ssh
approved these changes
Jun 30, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
When
spec.cluster.exposureis switched fromloadbalancertotraefik, the operator patches the data service fromtype: LoadBalancertotype: ClusterIPin place. That same patch also nulled out every LB annotation — includingservice.beta.kubernetes.io/aws-load-balancer-type: nlb.The in-tree service controller reads that annotation in
EnsureLoadBalancerDeletedto distinguish an NLB from a Classic ELB. With it gone, the controller falls back to the Classic ELB API, can't find the NLB, removes theservice.kubernetes.io/load-balancer-cleanupfinalizer anyway, and the NLB is left orphaned on AWS.Fix
Retain
aws-load-balancer-typethrough the switch so the controller correctly identifies and deletes the NLB. The annotation is inert on aClusterIPservice (the controller only acts whentype == LoadBalancer), so leaving it is safe. The remaining tuning annotations (connection draining, idle timeout, cross-zone) and the external-dns hostname are still removed.This is also correct for legacy Classic-ELB clusters: with no annotation present the controller already uses the Classic ELB path, which deletes correctly.
Testing
pre-commit(black, flake8, isort, mypy, yamllint) passes.TestServiceModels::test_lb_type_annotation_retained_when_switching_to_clusterip, pairing with the existingtest_get_data_servicewhich asserts the annotation is added on create.Caveats for the reviewer
Refs: crate/cloud#2976, kubernetes/kubernetes#95042 #851