@@ -10,18 +10,19 @@ import (
1010 "gopkg.in/gcfg.v1"
1111 "gopkg.in/ini.v1"
1212
13+ "github.com/openshift/library-go/pkg/operator/configobserver/featuregates"
1314 awsconfig "k8s.io/cloud-provider-aws/pkg/providers/v1/config"
1415)
1516
1617// CloudConfigTransformer is used to inject OpenShift configuration defaults into the Cloud Provider config
1718// for the AWS Cloud Provider.
18- func CloudConfigTransformer (source string , infra * configv1.Infrastructure , network * configv1.Network ) (string , error ) {
19+ func CloudConfigTransformer (source string , infra * configv1.Infrastructure , network * configv1.Network , features featuregates. FeatureGate ) (string , error ) {
1920 cfg , err := readAWSConfig (source )
2021 if err != nil {
2122 return "" , fmt .Errorf ("failed to read the cloud.conf: %w" , err )
2223 }
2324
24- setOpenShiftDefaults (cfg )
25+ setOpenShiftDefaults (cfg , features )
2526
2627 return marshalAWSConfig (cfg )
2728}
@@ -76,11 +77,19 @@ func marshalAWSConfig(cfg *awsconfig.CloudConfig) (string, error) {
7677 return buf .String (), nil
7778}
7879
79- func setOpenShiftDefaults (cfg * awsconfig.CloudConfig ) {
80+ func setOpenShiftDefaults (cfg * awsconfig.CloudConfig , features featuregates. FeatureGate ) {
8081 if cfg .Global .ClusterServiceLoadBalancerHealthProbeMode == "" {
8182 // OpenShift uses Shared mode by default.
8283 // This attaches the health check for Cluster scope services to the "kube-proxy"
8384 // health check endpoint served by OVN.
8485 cfg .Global .ClusterServiceLoadBalancerHealthProbeMode = "Shared"
8586 }
87+ if features .Enabled ("AWSServiceLBNetworkSecurityGroup" ) {
88+ if cfg .Global .NLBSecurityGroupMode != awsconfig .NLBSecurityGroupModeManaged {
89+ // OpenShift enforces security group by default when deploying
90+ // service type loadbalancer NLB.
91+ cfg .Global .NLBSecurityGroupMode = awsconfig .NLBSecurityGroupModeManaged
92+ }
93+ }
94+
8695}
0 commit comments