@@ -15,6 +15,7 @@ import (
1515 "github.com/openshift/installer/pkg/asset/installconfig"
1616 "github.com/openshift/installer/pkg/asset/machines/aws"
1717 "github.com/openshift/installer/pkg/asset/manifests/capiutils"
18+ "github.com/openshift/installer/pkg/types"
1819)
1920
2021// GenerateClusterAssets generates the manifests for the cluster-api.
@@ -157,20 +158,65 @@ func GenerateClusterAssets(installConfig *installconfig.InstallConfig, clusterID
157158 PresignedURLDuration : & metav1.Duration {Duration : 1 * time .Hour },
158159 },
159160 ControlPlaneLoadBalancer : & capa.AWSLoadBalancerSpec {
160- Name : ptr .To (clusterID .InfraID + "-ext" ),
161- LoadBalancerType : capa .LoadBalancerTypeNLB ,
162- Scheme : & capa .ELBSchemeInternetFacing ,
161+ Name : ptr .To (clusterID .InfraID + "-int" ),
162+ LoadBalancerType : capa .LoadBalancerTypeNLB ,
163+ Scheme : & capa .ELBSchemeInternal ,
164+ CrossZoneLoadBalancing : true ,
163165 AdditionalListeners : []capa.AdditionalListenerSpec {
164166 {
165167 Port : 22623 ,
166168 Protocol : capa .ELBProtocolTCP ,
167169 },
168170 },
171+ IngressRules : []capa.IngressRule {
172+ {
173+ Description : "Machine Config Server internal traffic from cluster" ,
174+ Protocol : capa .SecurityGroupProtocolTCP ,
175+ FromPort : 22623 ,
176+ ToPort : 22623 ,
177+ CidrBlocks : []string {mainCIDR .String ()},
178+ },
179+ },
169180 },
170181 AdditionalTags : tags ,
171182 },
172183 }
173184
185+ if installConfig .Config .Publish == types .ExternalPublishingStrategy {
186+ // FIXME: CAPA bug. Remove when fixed upstream
187+ // The primary and secondary load balancers in CAPA share the same
188+ // security group. However, specifying an ingress rule only in the
189+ // second LB does not seem to take effect, forcing us to add it to the
190+ // primary LB instead.
191+ // https://github.com/kubernetes-sigs/cluster-api-provider-aws/issues/4865
192+ awsCluster .Spec .ControlPlaneLoadBalancer .IngressRules = append (
193+ awsCluster .Spec .ControlPlaneLoadBalancer .IngressRules ,
194+ capa.IngressRule {
195+ Description : "Kubernetes API Server traffic for public access" ,
196+ Protocol : capa .SecurityGroupProtocolTCP ,
197+ FromPort : 6443 ,
198+ ToPort : 6443 ,
199+ CidrBlocks : []string {"0.0.0.0/0" },
200+ },
201+ )
202+
203+ awsCluster .Spec .SecondaryControlPlaneLoadBalancer = & capa.AWSLoadBalancerSpec {
204+ Name : ptr .To (clusterID .InfraID + "-ext" ),
205+ LoadBalancerType : capa .LoadBalancerTypeNLB ,
206+ Scheme : & capa .ELBSchemeInternetFacing ,
207+ CrossZoneLoadBalancing : true ,
208+ IngressRules : []capa.IngressRule {
209+ {
210+ Description : "Kubernetes API Server traffic for public access" ,
211+ Protocol : capa .SecurityGroupProtocolTCP ,
212+ FromPort : 6443 ,
213+ ToPort : 6443 ,
214+ CidrBlocks : []string {"0.0.0.0/0" },
215+ },
216+ },
217+ }
218+ }
219+
174220 // If the install config has subnets, use them.
175221 if len (installConfig .AWS .Subnets ) > 0 {
176222 privateSubnets , err := installConfig .AWS .PrivateSubnets (context .TODO ())
0 commit comments