Skip to content

Commit fba07ed

Browse files
committed
svc/nlb/sg/validations: ensure annotations matches NLB SG
Ensure annotation matches feature NLB with Security Groups by preventing standard controller BYO SG annotations due existing controller limitations.
1 parent 9b394b8 commit fba07ed

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

pkg/providers/v1/aws_validations.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,26 @@ func ensureLoadBalancerValidation(v *awsValidationInput) error {
5353
func validateServiceAnnotations(v *awsValidationInput) error {
5454
isNLB := isNLB(v.annotations)
5555

56+
// ServiceAnnotationLoadBalancerSecurityGroups
57+
// NLB only: ensure the BYO annotations are not supported and return an error.
58+
// FIXME: the BYO SG for NLB implementation is blocked by https://github.com/kubernetes/cloud-provider-aws/pull/1209
59+
if _, hasBYOAnnotation := v.annotations[ServiceAnnotationLoadBalancerSecurityGroups]; hasBYOAnnotation {
60+
if isNLB {
61+
return fmt.Errorf("BYO security group annotation %q is not supported by NLB", ServiceAnnotationLoadBalancerSecurityGroups)
62+
}
63+
}
64+
65+
// ServiceAnnotationLoadBalancerExtraSecurityGroups
66+
if _, hasExtraBYOAnnotation := v.annotations[ServiceAnnotationLoadBalancerExtraSecurityGroups]; hasExtraBYOAnnotation {
67+
if isNLB {
68+
return fmt.Errorf("BYO extra security group annotation %q is not supported by NLB", ServiceAnnotationLoadBalancerExtraSecurityGroups)
69+
}
70+
}
71+
5672
// ServiceAnnotationLoadBalancerTargetGroupAttributes
5773
if _, present := v.annotations[ServiceAnnotationLoadBalancerTargetGroupAttributes]; present {
5874
if !isNLB {
59-
return fmt.Errorf("target group annotations attribute is only supported for NLB")
75+
return fmt.Errorf("target group annotations attributes are only supported for NLB")
6076
}
6177
if err := validateServiceAnnotationTargetGroupAttributes(v); err != nil {
6278
return err

0 commit comments

Comments
 (0)