@@ -2332,12 +2332,16 @@ func TestNodePortServicesIngressRules(t *testing.T) {
23322332
23332333 testCases := []struct {
23342334 name string
2335- cidrBlocks [] string
2335+ networkSpec infrav1. NetworkSpec
23362336 expectedIngresRules infrav1.IngressRules
23372337 }{
23382338 {
2339- name : "default node ports services ingress rules, no node port cidr block provided" ,
2340- cidrBlocks : nil ,
2339+ name : "default node ports services ingress rules, no node port cidr block provided" ,
2340+ networkSpec : infrav1.NetworkSpec {
2341+ VPC : infrav1.VPCSpec {
2342+ CidrBlock : "10.0.0.0/16" ,
2343+ },
2344+ },
23412345 expectedIngresRules : infrav1.IngressRules {
23422346 {
23432347 Description : "Node Port Services" ,
@@ -2356,8 +2360,39 @@ func TestNodePortServicesIngressRules(t *testing.T) {
23562360 },
23572361 },
23582362 {
2359- name : "node port cidr block provided, no default cidr block used for node port services ingress rule" ,
2360- cidrBlocks : []string {"10.0.0.0/16" },
2363+ name : "default node ports services ingress rules for IPv6, no node port cidr block provided" ,
2364+ networkSpec : infrav1.NetworkSpec {
2365+ VPC : infrav1.VPCSpec {
2366+ CidrBlock : "10.0.0.0/16" ,
2367+ IPv6 : & infrav1.IPv6 {},
2368+ },
2369+ },
2370+ expectedIngresRules : infrav1.IngressRules {
2371+ {
2372+ Description : "Node Port Services" ,
2373+ Protocol : infrav1 .SecurityGroupProtocolTCP ,
2374+ FromPort : 30000 ,
2375+ ToPort : 32767 ,
2376+ CidrBlocks : []string {services .AnyIPv4CidrBlock },
2377+ IPv6CidrBlocks : []string {services .AnyIPv6CidrBlock },
2378+ },
2379+ {
2380+ Description : "Kubelet API" ,
2381+ Protocol : infrav1 .SecurityGroupProtocolTCP ,
2382+ FromPort : 10250 ,
2383+ ToPort : 10250 ,
2384+ SourceSecurityGroupIDs : []string {"Id1" , "Id2" },
2385+ },
2386+ },
2387+ },
2388+ {
2389+ name : "node port cidr block provided, no default cidr block used for node port services ingress rule" ,
2390+ networkSpec : infrav1.NetworkSpec {
2391+ VPC : infrav1.VPCSpec {
2392+ CidrBlock : "10.0.0.0/16" ,
2393+ },
2394+ NodePortIngressRuleCidrBlocks : []string {"10.0.0.0/16" },
2395+ },
23612396 expectedIngresRules : infrav1.IngressRules {
23622397 {
23632398 Description : "Node Port Services" ,
@@ -2375,6 +2410,64 @@ func TestNodePortServicesIngressRules(t *testing.T) {
23752410 },
23762411 },
23772412 },
2413+ {
2414+ name : "node port cidr block provided for only IPv6, no default cidr block used for node port services ingress rule" ,
2415+ networkSpec : infrav1.NetworkSpec {
2416+ VPC : infrav1.VPCSpec {
2417+ CidrBlock : "10.0.0.0/16" ,
2418+ IPv6 : & infrav1.IPv6 {
2419+ CidrBlock : "2001:1234:5678:9a40::/56" ,
2420+ },
2421+ },
2422+ NodePortIngressRuleCidrBlocks : []string {"2001:1234:5678:9a40::/56" },
2423+ },
2424+ expectedIngresRules : infrav1.IngressRules {
2425+ {
2426+ Description : "Node Port Services" ,
2427+ Protocol : infrav1 .SecurityGroupProtocolTCP ,
2428+ FromPort : 30000 ,
2429+ ToPort : 32767 ,
2430+ CidrBlocks : []string {services .AnyIPv4CidrBlock },
2431+ IPv6CidrBlocks : []string {"2001:1234:5678:9a40::/56" },
2432+ },
2433+ {
2434+ Description : "Kubelet API" ,
2435+ Protocol : infrav1 .SecurityGroupProtocolTCP ,
2436+ FromPort : 10250 ,
2437+ ToPort : 10250 ,
2438+ SourceSecurityGroupIDs : []string {"Id1" , "Id2" },
2439+ },
2440+ },
2441+ },
2442+ {
2443+ name : "node port cidr block provided for both IPv4 and IPv6, no default cidr block used for node port services ingress rule" ,
2444+ networkSpec : infrav1.NetworkSpec {
2445+ VPC : infrav1.VPCSpec {
2446+ CidrBlock : "10.0.0.0/16" ,
2447+ IPv6 : & infrav1.IPv6 {
2448+ CidrBlock : "2001:1234:5678:9a40::/56" ,
2449+ },
2450+ },
2451+ NodePortIngressRuleCidrBlocks : []string {"10.0.0.0/16" , "2001:1234:5678:9a40::/56" },
2452+ },
2453+ expectedIngresRules : infrav1.IngressRules {
2454+ {
2455+ Description : "Node Port Services" ,
2456+ Protocol : infrav1 .SecurityGroupProtocolTCP ,
2457+ FromPort : 30000 ,
2458+ ToPort : 32767 ,
2459+ CidrBlocks : []string {"10.0.0.0/16" },
2460+ IPv6CidrBlocks : []string {"2001:1234:5678:9a40::/56" },
2461+ },
2462+ {
2463+ Description : "Kubelet API" ,
2464+ Protocol : infrav1 .SecurityGroupProtocolTCP ,
2465+ FromPort : 10250 ,
2466+ ToPort : 10250 ,
2467+ SourceSecurityGroupIDs : []string {"Id1" , "Id2" },
2468+ },
2469+ },
2470+ },
23782471 }
23792472
23802473 for _ , tc := range testCases {
@@ -2387,12 +2480,7 @@ func TestNodePortServicesIngressRules(t *testing.T) {
23872480 AWSCluster : & infrav1.AWSCluster {
23882481 Spec : infrav1.AWSClusterSpec {
23892482 ControlPlaneLoadBalancer : & infrav1.AWSLoadBalancerSpec {},
2390- NetworkSpec : infrav1.NetworkSpec {
2391- VPC : infrav1.VPCSpec {
2392- CidrBlock : "10.0.0.0/16" ,
2393- },
2394- NodePortIngressRuleCidrBlocks : tc .cidrBlocks ,
2395- },
2483+ NetworkSpec : tc .networkSpec ,
23962484 },
23972485 Status : infrav1.AWSClusterStatus {
23982486 Network : infrav1.NetworkStatus {
0 commit comments