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