@@ -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
}
@@ -765,10 +773,14 @@ func (c *Cloud) updateInstanceSecurityGroupsForNLB(lbName string, instances map[
765
773
766
774
{
767
775
clientPorts := sets.Int64 {}
776
+ clientProtocol := "tcp"
768
777
healthCheckPorts := sets.Int64 {}
769
778
for _ , port := range portMappings {
770
779
clientPorts .Insert (port .TrafficPort )
771
780
healthCheckPorts .Insert (port .HealthCheckPort )
781
+ if port .TrafficProtocol == string (v1 .ProtocolUDP ) {
782
+ clientProtocol = "udp"
783
+ }
772
784
}
773
785
clientRuleAnnotation := fmt .Sprintf ("%s=%s" , NLBClientRuleDescription , lbName )
774
786
healthRuleAnnotation := fmt .Sprintf ("%s=%s" , NLBHealthCheckRuleDescription , lbName )
@@ -782,14 +794,14 @@ func (c *Cloud) updateInstanceSecurityGroupsForNLB(lbName string, instances map[
782
794
if err := c .updateInstanceSecurityGroupForNLBTraffic (sgID , sgPerms , healthRuleAnnotation , "tcp" , healthCheckPorts , vpcCIDRs ); err != nil {
783
795
return err
784
796
}
785
- if err := c .updateInstanceSecurityGroupForNLBTraffic (sgID , sgPerms , clientRuleAnnotation , "tcp" , clientPorts , clientCIDRs ); err != nil {
797
+ if err := c .updateInstanceSecurityGroupForNLBTraffic (sgID , sgPerms , clientRuleAnnotation , clientProtocol , clientPorts , clientCIDRs ); err != nil {
786
798
return err
787
799
}
788
800
} else {
789
801
if err := c .updateInstanceSecurityGroupForNLBTraffic (sgID , sgPerms , healthRuleAnnotation , "tcp" , nil , nil ); err != nil {
790
802
return err
791
803
}
792
- if err := c .updateInstanceSecurityGroupForNLBTraffic (sgID , sgPerms , clientRuleAnnotation , "tcp" , nil , nil ); err != nil {
804
+ if err := c .updateInstanceSecurityGroupForNLBTraffic (sgID , sgPerms , clientRuleAnnotation , clientProtocol , nil , nil ); err != nil {
793
805
return err
794
806
}
795
807
}
0 commit comments