@@ -1317,6 +1317,64 @@ func TestControlPlaneLoadBalancerIngressRules(t *testing.T) {
13171317 },
13181318 },
13191319 },
1320+ {
1321+ name : "defined rules are used when using internal and external LB" ,
1322+ awsCluster : & infrav1.AWSCluster {
1323+ Spec : infrav1.AWSClusterSpec {
1324+ ControlPlaneLoadBalancer : & infrav1.AWSLoadBalancerSpec {
1325+ IngressRules : []infrav1.IngressRule {
1326+ {
1327+ Description : "My custom ingress rule" ,
1328+ Protocol : infrav1 .SecurityGroupProtocolTCP ,
1329+ FromPort : 1234 ,
1330+ ToPort : 1234 ,
1331+ CidrBlocks : []string {"172.126.1.1/0" },
1332+ },
1333+ },
1334+ Scheme : & infrav1 .ELBSchemeInternal ,
1335+ },
1336+ SecondaryControlPlaneLoadBalancer : & infrav1.AWSLoadBalancerSpec {
1337+ IngressRules : []infrav1.IngressRule {
1338+ {
1339+ Description : "Another custom ingress rule" ,
1340+ Protocol : infrav1 .SecurityGroupProtocolTCP ,
1341+ FromPort : 2345 ,
1342+ ToPort : 2345 ,
1343+ CidrBlocks : []string {"0.0.0.0/0" },
1344+ },
1345+ },
1346+ },
1347+ NetworkSpec : infrav1.NetworkSpec {
1348+ VPC : infrav1.VPCSpec {
1349+ CidrBlock : "10.0.0.0/16" ,
1350+ },
1351+ },
1352+ },
1353+ },
1354+ expectedIngresRules : infrav1.IngressRules {
1355+ infrav1.IngressRule {
1356+ Description : "Kubernetes API" ,
1357+ Protocol : infrav1 .SecurityGroupProtocolTCP ,
1358+ FromPort : 6443 ,
1359+ ToPort : 6443 ,
1360+ CidrBlocks : []string {"10.0.0.0/16" },
1361+ },
1362+ infrav1.IngressRule {
1363+ Description : "My custom ingress rule" ,
1364+ Protocol : infrav1 .SecurityGroupProtocolTCP ,
1365+ FromPort : 1234 ,
1366+ ToPort : 1234 ,
1367+ CidrBlocks : []string {"172.126.1.1/0" },
1368+ },
1369+ infrav1.IngressRule {
1370+ Description : "Another custom ingress rule" ,
1371+ Protocol : infrav1 .SecurityGroupProtocolTCP ,
1372+ FromPort : 2345 ,
1373+ ToPort : 2345 ,
1374+ CidrBlocks : []string {"0.0.0.0/0" },
1375+ },
1376+ },
1377+ },
13201378 }
13211379
13221380 for _ , tc := range testCases {
0 commit comments