@@ -3396,7 +3396,7 @@ func (c *Cloud) EnsureLoadBalancer(ctx context.Context, clusterName string, apiS
3396
3396
listeners := []* elb.Listener {}
3397
3397
v2Mappings := []nlbPortMapping {}
3398
3398
3399
- portList := getPortSets (annotations [ServiceAnnotationLoadBalancerSSLPorts ])
3399
+ sslPorts := getPortSets (annotations [ServiceAnnotationLoadBalancerSSLPorts ])
3400
3400
for _ , port := range apiService .Spec .Ports {
3401
3401
if port .Protocol != v1 .ProtocolTCP {
3402
3402
return nil , fmt .Errorf ("Only TCP LoadBalancer is supported for AWS ELB" )
@@ -3407,16 +3407,32 @@ func (c *Cloud) EnsureLoadBalancer(ctx context.Context, clusterName string, apiS
3407
3407
}
3408
3408
3409
3409
if isNLB (annotations ) {
3410
- v2Mappings = append (v2Mappings , nlbPortMapping {
3411
- FrontendPort : int64 (port .Port ),
3412
- TrafficPort : int64 (port .NodePort ),
3410
+ portMapping := nlbPortMapping {
3411
+ FrontendPort : int64 (port .Port ),
3412
+ FrontendProtocol : string (port .Protocol ),
3413
+ TrafficPort : int64 (port .NodePort ),
3414
+ TrafficProtocol : string (port .Protocol ),
3415
+
3413
3416
// if externalTrafficPolicy == "Local", we'll override the
3414
3417
// health check later
3415
3418
HealthCheckPort : int64 (port .NodePort ),
3416
3419
HealthCheckProtocol : elbv2 .ProtocolEnumTcp ,
3417
- })
3420
+ }
3421
+
3422
+ certificateARN := annotations [ServiceAnnotationLoadBalancerCertificate ]
3423
+ if certificateARN != "" && (sslPorts == nil || sslPorts .numbers .Has (int64 (port .Port )) || sslPorts .names .Has (port .Name )) {
3424
+ portMapping .FrontendProtocol = elbv2 .ProtocolEnumTls
3425
+ portMapping .SSLCertificateARN = certificateARN
3426
+ portMapping .SSLPolicy = annotations [ServiceAnnotationLoadBalancerSSLNegotiationPolicy ]
3427
+
3428
+ if backendProtocol := annotations [ServiceAnnotationLoadBalancerBEProtocol ]; backendProtocol == "ssl" {
3429
+ portMapping .TrafficProtocol = elbv2 .ProtocolEnumTls
3430
+ }
3431
+ }
3432
+
3433
+ v2Mappings = append (v2Mappings , portMapping )
3418
3434
}
3419
- listener , err := buildListener (port , annotations , portList )
3435
+ listener , err := buildListener (port , annotations , sslPorts )
3420
3436
if err != nil {
3421
3437
return nil , err
3422
3438
}
0 commit comments