Skip to content

Commit 188d6c0

Browse files
committed
Configure via spec only
Signed-off-by: Nolan Brubaker <nolan@nbrubaker.com>
1 parent d81c9a2 commit 188d6c0

File tree

4 files changed

+3
-137
lines changed

4 files changed

+3
-137
lines changed

pkg/providers/v1/aws_loadbalancer.go

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,7 @@ func isLBExternal(annotations map[string]string) bool {
9898
// getLBIPAddressType determines the load balancer IP address type from Service spec or annotations.
9999
// Priority order: annotations > spec fields > default (ipv4)
100100
func (c *Cloud) getLBIPAddressType(service *v1.Service) elbv2types.IpAddressType {
101-
// Check annotation first for backward compatibility
102-
if ipType, ok := service.Annotations[ServiceAnnotationLoadBalancerIPAddressType]; ok {
103-
klog.V(4).Infof("Using load balancer IP address type from annotation: %s", ipType)
104-
return elbv2types.IpAddressType(ipType)
105-
}
106-
107-
// Fall back to spec.ipFamilies and spec.ipFamilyPolicy
101+
// Determine from spec.IPFamilyPolicy and spec.IPFamilies
108102
if service.Spec.IPFamilyPolicy != nil {
109103
switch *service.Spec.IPFamilyPolicy {
110104
case v1.IPFamilyPolicyPreferDualStack, v1.IPFamilyPolicyRequireDualStack:
@@ -135,16 +129,9 @@ func (c *Cloud) getLBIPAddressType(service *v1.Service) elbv2types.IpAddressType
135129
return elbv2types.IpAddressTypeIpv4
136130
}
137131

138-
// getTargetGroupIPAddressType determines the target group IP address type from Service spec or annotations.
139-
// Priority order: annotations > spec fields > default (ipv4)
132+
// getTargetGroupIPAddressType determines the target group IP address type from Service spec.
140133
func (c *Cloud) getTargetGroupIPAddressType(service *v1.Service) elbv2types.TargetGroupIpAddressTypeEnum {
141-
// Check annotation first for backward compatibility
142-
if ipType, ok := service.Annotations[ServiceAnnotationLoadBalancerTargetGroupIPAddressType]; ok {
143-
klog.V(4).Infof("Using target group IP address type from annotation: %s", ipType)
144-
return elbv2types.TargetGroupIpAddressTypeEnum(ipType)
145-
}
146-
147-
// Determine from spec.ipFamilies - use the first family as primary
134+
// Determine from spec.ipFamilies - use the primary (first) family
148135
if len(service.Spec.IPFamilies) > 0 {
149136
primaryFamily := service.Spec.IPFamilies[0]
150137
if primaryFamily == v1.IPv6Protocol {

pkg/providers/v1/aws_loadbalancer_test.go

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -2373,38 +2373,6 @@ func TestGetLBIPAddressType(t *testing.T) {
23732373
service *v1.Service
23742374
expected elbv2types.IpAddressType
23752375
}{
2376-
// Annotation precedence tests
2377-
{
2378-
name: "annotation takes precedence over spec - dualstack annotation with SingleStack spec",
2379-
service: &v1.Service{
2380-
ObjectMeta: metav1.ObjectMeta{
2381-
Annotations: map[string]string{
2382-
ServiceAnnotationLoadBalancerIPAddressType: "dualstack",
2383-
},
2384-
},
2385-
Spec: v1.ServiceSpec{
2386-
IPFamilyPolicy: ptr.To(v1.IPFamilyPolicySingleStack),
2387-
IPFamilies: []v1.IPFamily{v1.IPv4Protocol},
2388-
},
2389-
},
2390-
expected: elbv2types.IpAddressTypeDualstack,
2391-
},
2392-
{
2393-
name: "annotation takes precedence - ipv4 annotation with PreferDualStack spec",
2394-
service: &v1.Service{
2395-
ObjectMeta: metav1.ObjectMeta{
2396-
Annotations: map[string]string{
2397-
ServiceAnnotationLoadBalancerIPAddressType: "ipv4",
2398-
},
2399-
},
2400-
Spec: v1.ServiceSpec{
2401-
IPFamilyPolicy: ptr.To(v1.IPFamilyPolicyPreferDualStack),
2402-
IPFamilies: []v1.IPFamily{v1.IPv4Protocol, v1.IPv6Protocol},
2403-
},
2404-
},
2405-
expected: elbv2types.IpAddressTypeIpv4,
2406-
},
2407-
24082376
// Dual-stack scenarios
24092377
{
24102378
name: "PreferDualStack with both IPv4 and IPv6 - returns dualstack",
@@ -2518,36 +2486,6 @@ func TestGetTargetGroupIPAddressType(t *testing.T) {
25182486
service *v1.Service
25192487
expected elbv2types.TargetGroupIpAddressTypeEnum
25202488
}{
2521-
// Priority: Annotations take precedence
2522-
{
2523-
name: "annotation takes precedence - ipv6 annotation with IPv4 spec",
2524-
service: &v1.Service{
2525-
ObjectMeta: metav1.ObjectMeta{
2526-
Annotations: map[string]string{
2527-
ServiceAnnotationLoadBalancerTargetGroupIPAddressType: "ipv6",
2528-
},
2529-
},
2530-
Spec: v1.ServiceSpec{
2531-
IPFamilies: []v1.IPFamily{v1.IPv4Protocol},
2532-
},
2533-
},
2534-
expected: elbv2types.TargetGroupIpAddressTypeEnumIpv6,
2535-
},
2536-
{
2537-
name: "annotation takes precedence - ipv4 annotation with IPv6 spec",
2538-
service: &v1.Service{
2539-
ObjectMeta: metav1.ObjectMeta{
2540-
Annotations: map[string]string{
2541-
ServiceAnnotationLoadBalancerTargetGroupIPAddressType: "ipv4",
2542-
},
2543-
},
2544-
Spec: v1.ServiceSpec{
2545-
IPFamilies: []v1.IPFamily{v1.IPv6Protocol},
2546-
},
2547-
},
2548-
expected: elbv2types.TargetGroupIpAddressTypeEnumIpv4,
2549-
},
2550-
25512489
// Spec-based: IPv6 primary
25522490
{
25532491
name: "IPv6 as first family - returns ipv6",

pkg/providers/v1/aws_validations.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,6 @@ func validateServiceAnnotations(v *awsValidationInput) error {
104104
}
105105
}
106106

107-
if _, present := v.annotations[ServiceAnnotationLoadBalancerIPAddressType]; present {
108-
if !isNLB {
109-
return fmt.Errorf("ip address type annotation is only supported for NLB")
110-
}
111-
}
112-
113-
if _, present := v.annotations[ServiceAnnotationLoadBalancerTargetGroupIPAddressType]; present {
114-
if !isNLB {
115-
return fmt.Errorf("target group ip address type annotation is only supported for NLB")
116-
}
117-
}
118107
return nil
119108
}
120109

pkg/providers/v1/aws_validations_test.go

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -419,54 +419,6 @@ func TestValidateServiceAnnotations(t *testing.T) {
419419
expectedError: "target group attributes annotation is only supported for NLB",
420420
},
421421

422-
// IPFamily annotation set to dualstack on NLB (should succeed)
423-
{
424-
name: "NLB with dualstack annotation - success",
425-
annotations: map[string]string{
426-
ServiceAnnotationLoadBalancerType: "nlb",
427-
ServiceAnnotationLoadBalancerIPAddressType: "dualstack",
428-
},
429-
expectedError: "",
430-
},
431-
432-
// IPFamily annotation set to dualstack on CLB (should fail)
433-
{
434-
name: "CLB with dualstack annotation - fail",
435-
annotations: map[string]string{
436-
ServiceAnnotationLoadBalancerIPAddressType: "dualstack",
437-
},
438-
expectedError: "ip address type annotation is only supported for NLB",
439-
},
440-
441-
// Target group IP address type annotation set to ipv6 on NLB (should succeed)
442-
{
443-
name: "NLB with ipv6 target group annotation - success",
444-
annotations: map[string]string{
445-
ServiceAnnotationLoadBalancerType: "nlb",
446-
ServiceAnnotationLoadBalancerTargetGroupIPAddressType: "ipv6",
447-
},
448-
expectedError: "",
449-
},
450-
451-
// Target group IP address type annotation set to ipv4 on NLB (should succeed)
452-
{
453-
name: "NLB with ipv4 target group annotation - success",
454-
annotations: map[string]string{
455-
ServiceAnnotationLoadBalancerType: "nlb",
456-
ServiceAnnotationLoadBalancerTargetGroupIPAddressType: "ipv4",
457-
},
458-
expectedError: "",
459-
},
460-
461-
// Target group IP address type annotation set on CLB (should fail)
462-
{
463-
name: "CLB with ipv6 target group annotation - fail",
464-
annotations: map[string]string{
465-
ServiceAnnotationLoadBalancerTargetGroupIPAddressType: "ipv6",
466-
},
467-
expectedError: "target group ip address type annotation is only supported for NLB",
468-
},
469-
470422
// No annotations (should succeed)
471423
{
472424
name: "no annotations - success",

0 commit comments

Comments
 (0)