@@ -2344,12 +2344,16 @@ func TestNodePortServicesIngressRules(t *testing.T) {
2344
2344
2345
2345
testCases := []struct {
2346
2346
name string
2347
- cidrBlocks [] string
2347
+ networkSpec infrav1. NetworkSpec
2348
2348
expectedIngresRules infrav1.IngressRules
2349
2349
}{
2350
2350
{
2351
- name : "default node ports services ingress rules, no node port cidr block provided" ,
2352
- cidrBlocks : nil ,
2351
+ name : "default node ports services ingress rules, no node port cidr block provided" ,
2352
+ networkSpec : infrav1.NetworkSpec {
2353
+ VPC : infrav1.VPCSpec {
2354
+ CidrBlock : "10.0.0.0/16" ,
2355
+ },
2356
+ },
2353
2357
expectedIngresRules : infrav1.IngressRules {
2354
2358
{
2355
2359
Description : "Node Port Services" ,
@@ -2368,8 +2372,39 @@ func TestNodePortServicesIngressRules(t *testing.T) {
2368
2372
},
2369
2373
},
2370
2374
{
2371
- name : "node port cidr block provided, no default cidr block used for node port services ingress rule" ,
2372
- cidrBlocks : []string {"10.0.0.0/16" },
2375
+ name : "default node ports services ingress rules for IPv6, no node port cidr block provided" ,
2376
+ networkSpec : infrav1.NetworkSpec {
2377
+ VPC : infrav1.VPCSpec {
2378
+ CidrBlock : "10.0.0.0/16" ,
2379
+ IPv6 : & infrav1.IPv6 {},
2380
+ },
2381
+ },
2382
+ expectedIngresRules : infrav1.IngressRules {
2383
+ {
2384
+ Description : "Node Port Services" ,
2385
+ Protocol : infrav1 .SecurityGroupProtocolTCP ,
2386
+ FromPort : 30000 ,
2387
+ ToPort : 32767 ,
2388
+ CidrBlocks : []string {services .AnyIPv4CidrBlock },
2389
+ IPv6CidrBlocks : []string {services .AnyIPv6CidrBlock },
2390
+ },
2391
+ {
2392
+ Description : "Kubelet API" ,
2393
+ Protocol : infrav1 .SecurityGroupProtocolTCP ,
2394
+ FromPort : 10250 ,
2395
+ ToPort : 10250 ,
2396
+ SourceSecurityGroupIDs : []string {"Id1" , "Id2" },
2397
+ },
2398
+ },
2399
+ },
2400
+ {
2401
+ name : "node port cidr block provided, no default cidr block used for node port services ingress rule" ,
2402
+ networkSpec : infrav1.NetworkSpec {
2403
+ VPC : infrav1.VPCSpec {
2404
+ CidrBlock : "10.0.0.0/16" ,
2405
+ },
2406
+ NodePortIngressRuleCidrBlocks : []string {"10.0.0.0/16" },
2407
+ },
2373
2408
expectedIngresRules : infrav1.IngressRules {
2374
2409
{
2375
2410
Description : "Node Port Services" ,
@@ -2387,6 +2422,64 @@ func TestNodePortServicesIngressRules(t *testing.T) {
2387
2422
},
2388
2423
},
2389
2424
},
2425
+ {
2426
+ name : "node port cidr block provided for only IPv6, no default cidr block used for node port services ingress rule" ,
2427
+ networkSpec : infrav1.NetworkSpec {
2428
+ VPC : infrav1.VPCSpec {
2429
+ CidrBlock : "10.0.0.0/16" ,
2430
+ IPv6 : & infrav1.IPv6 {
2431
+ CidrBlock : "2001:1234:5678:9a40::/56" ,
2432
+ },
2433
+ },
2434
+ NodePortIngressRuleCidrBlocks : []string {"2001:1234:5678:9a40::/56" },
2435
+ },
2436
+ expectedIngresRules : infrav1.IngressRules {
2437
+ {
2438
+ Description : "Node Port Services" ,
2439
+ Protocol : infrav1 .SecurityGroupProtocolTCP ,
2440
+ FromPort : 30000 ,
2441
+ ToPort : 32767 ,
2442
+ CidrBlocks : []string {services .AnyIPv4CidrBlock },
2443
+ IPv6CidrBlocks : []string {"2001:1234:5678:9a40::/56" },
2444
+ },
2445
+ {
2446
+ Description : "Kubelet API" ,
2447
+ Protocol : infrav1 .SecurityGroupProtocolTCP ,
2448
+ FromPort : 10250 ,
2449
+ ToPort : 10250 ,
2450
+ SourceSecurityGroupIDs : []string {"Id1" , "Id2" },
2451
+ },
2452
+ },
2453
+ },
2454
+ {
2455
+ name : "node port cidr block provided for both IPv4 and IPv6, no default cidr block used for node port services ingress rule" ,
2456
+ networkSpec : infrav1.NetworkSpec {
2457
+ VPC : infrav1.VPCSpec {
2458
+ CidrBlock : "10.0.0.0/16" ,
2459
+ IPv6 : & infrav1.IPv6 {
2460
+ CidrBlock : "2001:1234:5678:9a40::/56" ,
2461
+ },
2462
+ },
2463
+ NodePortIngressRuleCidrBlocks : []string {"10.0.0.0/16" , "2001:1234:5678:9a40::/56" },
2464
+ },
2465
+ expectedIngresRules : infrav1.IngressRules {
2466
+ {
2467
+ Description : "Node Port Services" ,
2468
+ Protocol : infrav1 .SecurityGroupProtocolTCP ,
2469
+ FromPort : 30000 ,
2470
+ ToPort : 32767 ,
2471
+ CidrBlocks : []string {"10.0.0.0/16" },
2472
+ IPv6CidrBlocks : []string {"2001:1234:5678:9a40::/56" },
2473
+ },
2474
+ {
2475
+ Description : "Kubelet API" ,
2476
+ Protocol : infrav1 .SecurityGroupProtocolTCP ,
2477
+ FromPort : 10250 ,
2478
+ ToPort : 10250 ,
2479
+ SourceSecurityGroupIDs : []string {"Id1" , "Id2" },
2480
+ },
2481
+ },
2482
+ },
2390
2483
}
2391
2484
2392
2485
for _ , tc := range testCases {
@@ -2399,12 +2492,7 @@ func TestNodePortServicesIngressRules(t *testing.T) {
2399
2492
AWSCluster : & infrav1.AWSCluster {
2400
2493
Spec : infrav1.AWSClusterSpec {
2401
2494
ControlPlaneLoadBalancer : & infrav1.AWSLoadBalancerSpec {},
2402
- NetworkSpec : infrav1.NetworkSpec {
2403
- VPC : infrav1.VPCSpec {
2404
- CidrBlock : "10.0.0.0/16" ,
2405
- },
2406
- NodePortIngressRuleCidrBlocks : tc .cidrBlocks ,
2407
- },
2495
+ NetworkSpec : tc .networkSpec ,
2408
2496
},
2409
2497
Status : infrav1.AWSClusterStatus {
2410
2498
Network : infrav1.NetworkStatus {
0 commit comments