@@ -185,9 +185,12 @@ func (c *Cloud) ensureLoadBalancerv2(namespacedName types.NamespacedName, loadBa
185
185
}
186
186
187
187
// actual maps FrontendPort to an elbv2.Listener
188
- actual := map [int64 ]* elbv2.Listener {}
188
+ actual := map [int64 ]map [ string ] * elbv2.Listener {}
189
189
for _ , listener := range listenerDescriptions .Listeners {
190
- actual [* listener .Port ] = listener
190
+ if actual [* listener .Port ] == nil {
191
+ actual [* listener .Port ] = map [string ]* elbv2.Listener {}
192
+ }
193
+ actual [* listener.Port ][* listener.Protocol ] = listener
191
194
}
192
195
193
196
actualTargetGroups , err := c .elbv2 .DescribeTargetGroups (
@@ -207,10 +210,11 @@ func (c *Cloud) ensureLoadBalancerv2(namespacedName types.NamespacedName, loadBa
207
210
// Handle additions/modifications
208
211
for _ , mapping := range mappings {
209
212
frontendPort := mapping .FrontendPort
213
+ frontendProtocol := mapping .FrontendProtocol
210
214
nodePort := mapping .TrafficPort
211
215
212
216
// modifications
213
- if listener , ok := actual [frontendPort ]; ok {
217
+ if listener , ok := actual [frontendPort ][ frontendProtocol ] ; ok {
214
218
listenerNeedsModification := false
215
219
216
220
if aws .StringValue (listener .Protocol ) != mapping .FrontendProtocol {
@@ -315,23 +319,27 @@ func (c *Cloud) ensureLoadBalancerv2(namespacedName types.NamespacedName, loadBa
315
319
dirty = true
316
320
}
317
321
318
- frontEndPorts := map [int64 ]bool {}
322
+ frontEndPorts := map [int64 ]map [ string ] bool {}
319
323
for i := range mappings {
320
- frontEndPorts [mappings [i ].FrontendPort ] = true
324
+ if frontEndPorts [mappings [i ].FrontendPort ] == nil {
325
+ frontEndPorts [mappings [i ].FrontendPort ] = map [string ]bool {}
326
+ }
327
+ frontEndPorts [mappings [i ].FrontendPort ][mappings [i ].FrontendProtocol ] = true
321
328
}
322
329
323
330
// handle deletions
324
- for port , listener := range actual {
325
- if _ , ok := frontEndPorts [port ]; ! ok {
326
- err := c .deleteListenerV2 (listener )
327
- if err != nil {
328
- return nil , err
331
+ for port := range actual {
332
+ for protocol := range actual [port ] {
333
+ if _ , ok := frontEndPorts [port ][protocol ]; ! ok {
334
+ err := c .deleteListenerV2 (actual [port ][protocol ])
335
+ if err != nil {
336
+ return nil , err
337
+ }
338
+ dirty = true
329
339
}
330
- dirty = true
331
340
}
332
341
}
333
342
}
334
-
335
343
if err := c .reconcileLBAttributes (aws .StringValue (loadBalancer .LoadBalancerArn ), annotations ); err != nil {
336
344
return nil , err
337
345
}
@@ -768,10 +776,14 @@ func (c *Cloud) updateInstanceSecurityGroupsForNLB(lbName string, instances map[
768
776
769
777
{
770
778
clientPorts := sets.Int64 {}
779
+ clientProtocol := "tcp"
771
780
healthCheckPorts := sets.Int64 {}
772
781
for _ , port := range portMappings {
773
782
clientPorts .Insert (port .TrafficPort )
774
783
healthCheckPorts .Insert (port .HealthCheckPort )
784
+ if port .TrafficProtocol == string (v1 .ProtocolUDP ) {
785
+ clientProtocol = "udp"
786
+ }
775
787
}
776
788
clientRuleAnnotation := fmt .Sprintf ("%s=%s" , NLBClientRuleDescription , lbName )
777
789
healthRuleAnnotation := fmt .Sprintf ("%s=%s" , NLBHealthCheckRuleDescription , lbName )
@@ -785,14 +797,14 @@ func (c *Cloud) updateInstanceSecurityGroupsForNLB(lbName string, instances map[
785
797
if err := c .updateInstanceSecurityGroupForNLBTraffic (sgID , sgPerms , healthRuleAnnotation , "tcp" , healthCheckPorts , vpcCIDRs ); err != nil {
786
798
return err
787
799
}
788
- if err := c .updateInstanceSecurityGroupForNLBTraffic (sgID , sgPerms , clientRuleAnnotation , "tcp" , clientPorts , clientCIDRs ); err != nil {
800
+ if err := c .updateInstanceSecurityGroupForNLBTraffic (sgID , sgPerms , clientRuleAnnotation , clientProtocol , clientPorts , clientCIDRs ); err != nil {
789
801
return err
790
802
}
791
803
} else {
792
804
if err := c .updateInstanceSecurityGroupForNLBTraffic (sgID , sgPerms , healthRuleAnnotation , "tcp" , nil , nil ); err != nil {
793
805
return err
794
806
}
795
- if err := c .updateInstanceSecurityGroupForNLBTraffic (sgID , sgPerms , clientRuleAnnotation , "tcp" , nil , nil ); err != nil {
807
+ if err := c .updateInstanceSecurityGroupForNLBTraffic (sgID , sgPerms , clientRuleAnnotation , clientProtocol , nil , nil ); err != nil {
796
808
return err
797
809
}
798
810
}
0 commit comments