Skip to content

Commit b358bd9

Browse files
committed
Added validation and comment for all ipv6 related fields
1 parent 6455529 commit b358bd9

9 files changed

+72
-144
lines changed

api/v1alpha3/zz_generated.conversion.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha4/zz_generated.conversion.go

Lines changed: 3 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta1/awscluster_webhook.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,5 +185,10 @@ func (r *AWSCluster) validateNetwork() field.ErrorList {
185185
if r.Spec.NetworkSpec.VPC.IsIPv6Enabled() {
186186
allErrs = append(allErrs, field.Invalid(field.NewPath("ipv6"), r.Spec.NetworkSpec.VPC.IPv6, "IPv6 cannot be used with unmanaged clusters at this time."))
187187
}
188+
for _, subnet := range r.Spec.NetworkSpec.Subnets {
189+
if subnet.IsIPv6 || subnet.IPv6CidrBlock != "" {
190+
allErrs = append(allErrs, field.Invalid(field.NewPath("subnets"), r.Spec.NetworkSpec.Subnets, "IPv6 cannot be used with unmanaged clusters at this time."))
191+
}
192+
}
188193
return allErrs
189194
}

api/v1beta1/awscluster_webhook_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,41 @@ func TestAWSCluster_ValidateCreate(t *testing.T) {
238238
},
239239
wantErr: true,
240240
},
241+
{
242+
name: "rejects ipv6 enabled subnet",
243+
cluster: &AWSCluster{
244+
Spec: AWSClusterSpec{
245+
NetworkSpec: NetworkSpec{
246+
Subnets: []SubnetSpec{
247+
{
248+
ID: "sub-1",
249+
IsIPv6: true,
250+
},
251+
{
252+
ID: "sub-2",
253+
},
254+
},
255+
},
256+
},
257+
},
258+
wantErr: true,
259+
},
260+
{
261+
name: "rejects ipv6 cidr block for subnets",
262+
cluster: &AWSCluster{
263+
Spec: AWSClusterSpec{
264+
NetworkSpec: NetworkSpec{
265+
Subnets: []SubnetSpec{
266+
{
267+
ID: "sub-1",
268+
IPv6CidrBlock: "2022:1234:5678:9101::/64",
269+
},
270+
},
271+
},
272+
},
273+
},
274+
wantErr: true,
275+
},
241276
}
242277
for _, tt := range tests {
243278
t.Run(tt.name, func(t *testing.T) {

api/v1beta1/network_types.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ type VPCSpec struct {
189189
// Defaults to 10.0.0.0/16.
190190
CidrBlock string `json:"cidrBlock,omitempty"`
191191

192-
// IPv6 contains ipv6 specific settings for the network.
192+
// IPv6 contains ipv6 specific settings for the network. Supported only in managed clusters.
193+
// This field cannot be set on AWSCluster object.
193194
// +optional
194195
IPv6 *IPv6 `json:"ipv6,omitempty"`
195196

@@ -248,6 +249,8 @@ type SubnetSpec struct {
248249

249250
// IPv6CidrBlock is the IPv6 CIDR block to be used when the provider creates a managed VPC.
250251
// A subnet can have an IPv4 and an IPv6 address.
252+
// IPv6 is only supported in managed clusters, this field cannot be set on AWSCluster object.
253+
// +optional
251254
IPv6CidrBlock string `json:"ipv6CidrBlock,omitempty"`
252255

253256
// AvailabilityZone defines the availability zone to use for this subnet in the cluster's region.
@@ -258,6 +261,7 @@ type SubnetSpec struct {
258261
IsPublic bool `json:"isPublic"`
259262

260263
// IsIPv6 defines the subnet as an IPv6 subnet. A subnet is IPv6 when it is associated with a VPC that has IPv6 enabled.
264+
// IPv6 is only supported in managed clusters, this field cannot be set on AWSCluster object.
261265
// +optional
262266
IsIPv6 bool `json:"isIpv6,omitempty"`
263267

config/crd/bases/controlplane.cluster.x-k8s.io_awsmanagedcontrolplanes.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2529,12 +2529,15 @@ spec:
25292529
ipv6CidrBlock:
25302530
description: IPv6CidrBlock is the IPv6 CIDR block to be
25312531
used when the provider creates a managed VPC. A subnet
2532-
can have an IPv4 and an IPv6 address.
2532+
can have an IPv4 and an IPv6 address. IPv6 is only supported
2533+
in managed clusters, this field cannot be set on AWSCluster
2534+
object.
25332535
type: string
25342536
isIpv6:
25352537
description: IsIPv6 defines the subnet as an IPv6 subnet.
25362538
A subnet is IPv6 when it is associated with a VPC that
2537-
has IPv6 enabled.
2539+
has IPv6 enabled. IPv6 is only supported in managed clusters,
2540+
this field cannot be set on AWSCluster object.
25382541
type: boolean
25392542
isPublic:
25402543
description: IsPublic defines the subnet as a public subnet.
@@ -2599,7 +2602,8 @@ spec:
25992602
type: string
26002603
ipv6:
26012604
description: IPv6 contains ipv6 specific settings for the
2602-
network.
2605+
network. Supported only in managed clusters. This field
2606+
cannot be set on AWSCluster object.
26032607
properties:
26042608
cidrBlock:
26052609
description: CidrBlock is the CIDR block provided by Amazon

config/crd/bases/infrastructure.cluster.x-k8s.io_awsclusters.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,12 +1787,15 @@ spec:
17871787
ipv6CidrBlock:
17881788
description: IPv6CidrBlock is the IPv6 CIDR block to be
17891789
used when the provider creates a managed VPC. A subnet
1790-
can have an IPv4 and an IPv6 address.
1790+
can have an IPv4 and an IPv6 address. IPv6 is only supported
1791+
in managed clusters, this field cannot be set on AWSCluster
1792+
object.
17911793
type: string
17921794
isIpv6:
17931795
description: IsIPv6 defines the subnet as an IPv6 subnet.
17941796
A subnet is IPv6 when it is associated with a VPC that
1795-
has IPv6 enabled.
1797+
has IPv6 enabled. IPv6 is only supported in managed clusters,
1798+
this field cannot be set on AWSCluster object.
17961799
type: boolean
17971800
isPublic:
17981801
description: IsPublic defines the subnet as a public subnet.
@@ -1857,7 +1860,8 @@ spec:
18571860
type: string
18581861
ipv6:
18591862
description: IPv6 contains ipv6 specific settings for the
1860-
network.
1863+
network. Supported only in managed clusters. This field
1864+
cannot be set on AWSCluster object.
18611865
properties:
18621866
cidrBlock:
18631867
description: CidrBlock is the CIDR block provided by Amazon

config/crd/bases/infrastructure.cluster.x-k8s.io_awsclustertemplates.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,11 +618,15 @@ spec:
618618
description: IPv6CidrBlock is the IPv6 CIDR block
619619
to be used when the provider creates a managed
620620
VPC. A subnet can have an IPv4 and an IPv6 address.
621+
IPv6 is only supported in managed clusters, this
622+
field cannot be set on AWSCluster object.
621623
type: string
622624
isIpv6:
623625
description: IsIPv6 defines the subnet as an IPv6
624626
subnet. A subnet is IPv6 when it is associated
625-
with a VPC that has IPv6 enabled.
627+
with a VPC that has IPv6 enabled. IPv6 is only
628+
supported in managed clusters, this field cannot
629+
be set on AWSCluster object.
626630
type: boolean
627631
isPublic:
628632
description: IsPublic defines the subnet as a public
@@ -691,7 +695,8 @@ spec:
691695
type: string
692696
ipv6:
693697
description: IPv6 contains ipv6 specific settings
694-
for the network.
698+
for the network. Supported only in managed clusters.
699+
This field cannot be set on AWSCluster object.
695700
properties:
696701
cidrBlock:
697702
description: CidrBlock is the CIDR block provided

templates/cluster-template-ipv6.yaml

Lines changed: 0 additions & 126 deletions
This file was deleted.

0 commit comments

Comments
 (0)