Skip to content

Commit ebe8b00

Browse files
MaysaMacedoEmilienM
andcommitted
Support BYO dual-stack Network
This commit adds support to specify more than one existent subnet on the `OpenStackCluster`. The existent `OpenStackClusterSpec.Subnet` is removed in favor of `OpenStackClusterSpec.Subnets`. Co-Authored-By: Emilien Macchi <[email protected]>
1 parent 4182e2d commit ebe8b00

16 files changed

+409
-98
lines changed

api/v1alpha5/conversion.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,14 @@ func Convert_v1alpha8_OpenStackClusterSpec_To_v1alpha5_OpenStackClusterSpec(in *
196196
out.ExternalNetworkID = in.ExternalNetwork.ID
197197
}
198198

199+
if in.Subnets != nil {
200+
if len(in.Subnets) >= 1 {
201+
if err := Convert_v1alpha8_SubnetFilter_To_v1alpha5_SubnetFilter(&in.Subnets[0], &out.Subnet, s); err != nil {
202+
return err
203+
}
204+
}
205+
}
206+
199207
return nil
200208
}
201209

@@ -211,6 +219,15 @@ func Convert_v1alpha5_OpenStackClusterSpec_To_v1alpha8_OpenStackClusterSpec(in *
211219
}
212220
}
213221

222+
emptySubnet := SubnetFilter{}
223+
if in.Subnet != emptySubnet {
224+
subnet := infrav1.SubnetFilter{}
225+
if err := Convert_v1alpha5_SubnetFilter_To_v1alpha8_SubnetFilter(&in.Subnet, &subnet, s); err != nil {
226+
return err
227+
}
228+
out.Subnets = []infrav1.SubnetFilter{subnet}
229+
}
230+
214231
return nil
215232
}
216233

api/v1alpha5/conversion_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func TestConvertFrom(t *testing.T) {
4949
Spec: OpenStackClusterSpec{},
5050
ObjectMeta: metav1.ObjectMeta{
5151
Annotations: map[string]string{
52-
"cluster.x-k8s.io/conversion-data": "{\"spec\":{\"allowAllInClusterTraffic\":false,\"apiServerLoadBalancer\":{},\"cloudName\":\"\",\"controlPlaneEndpoint\":{\"host\":\"\",\"port\":0},\"disableAPIServerFloatingIP\":false,\"disableExternalNetwork\":false,\"externalNetwork\":{},\"managedSecurityGroups\":false,\"network\":{},\"subnet\":{}},\"status\":{\"ready\":false}}",
52+
"cluster.x-k8s.io/conversion-data": "{\"spec\":{\"allowAllInClusterTraffic\":false,\"apiServerLoadBalancer\":{},\"cloudName\":\"\",\"controlPlaneEndpoint\":{\"host\":\"\",\"port\":0},\"disableAPIServerFloatingIP\":false,\"disableExternalNetwork\":false,\"externalNetwork\":{},\"managedSecurityGroups\":false,\"network\":{}},\"status\":{\"ready\":false}}",
5353
},
5454
},
5555
},
@@ -64,7 +64,7 @@ func TestConvertFrom(t *testing.T) {
6464
Spec: OpenStackClusterTemplateSpec{},
6565
ObjectMeta: metav1.ObjectMeta{
6666
Annotations: map[string]string{
67-
"cluster.x-k8s.io/conversion-data": "{\"spec\":{\"template\":{\"spec\":{\"allowAllInClusterTraffic\":false,\"apiServerLoadBalancer\":{},\"cloudName\":\"\",\"controlPlaneEndpoint\":{\"host\":\"\",\"port\":0},\"disableAPIServerFloatingIP\":false,\"disableExternalNetwork\":false,\"externalNetwork\":{},\"managedSecurityGroups\":false,\"network\":{},\"subnet\":{}}}}}",
67+
"cluster.x-k8s.io/conversion-data": "{\"spec\":{\"template\":{\"spec\":{\"allowAllInClusterTraffic\":false,\"apiServerLoadBalancer\":{},\"cloudName\":\"\",\"controlPlaneEndpoint\":{\"host\":\"\",\"port\":0},\"disableAPIServerFloatingIP\":false,\"disableExternalNetwork\":false,\"externalNetwork\":{},\"managedSecurityGroups\":false,\"network\":{}}}}}",
6868
},
6969
},
7070
},

api/v1alpha5/zz_generated.conversion.go

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

api/v1alpha6/conversion.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,14 @@ func Convert_v1alpha8_OpenStackClusterSpec_To_v1alpha6_OpenStackClusterSpec(in *
486486
out.ExternalNetworkID = in.ExternalNetwork.ID
487487
}
488488

489+
if in.Subnets != nil {
490+
if len(in.Subnets) >= 1 {
491+
if err := Convert_v1alpha8_SubnetFilter_To_v1alpha6_SubnetFilter(&in.Subnets[0], &out.Subnet, s); err != nil {
492+
return err
493+
}
494+
}
495+
}
496+
489497
return nil
490498
}
491499

@@ -501,6 +509,15 @@ func Convert_v1alpha6_OpenStackClusterSpec_To_v1alpha8_OpenStackClusterSpec(in *
501509
}
502510
}
503511

512+
emptySubnet := SubnetFilter{}
513+
if in.Subnet != emptySubnet {
514+
subnet := infrav1.SubnetFilter{}
515+
if err := Convert_v1alpha6_SubnetFilter_To_v1alpha8_SubnetFilter(&in.Subnet, &subnet, s); err != nil {
516+
return err
517+
}
518+
out.Subnets = []infrav1.SubnetFilter{subnet}
519+
}
520+
504521
return nil
505522
}
506523

api/v1alpha6/zz_generated.conversion.go

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

api/v1alpha7/conversion.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,15 @@ func Convert_v1alpha7_OpenStackClusterSpec_To_v1alpha8_OpenStackClusterSpec(in *
383383
}
384384
}
385385

386+
emptySubnet := SubnetFilter{}
387+
if in.Subnet != emptySubnet {
388+
subnet := infrav1.SubnetFilter{}
389+
if err := Convert_v1alpha7_SubnetFilter_To_v1alpha8_SubnetFilter(&in.Subnet, &subnet, s); err != nil {
390+
return err
391+
}
392+
out.Subnets = []infrav1.SubnetFilter{subnet}
393+
}
394+
386395
return nil
387396
}
388397

@@ -396,5 +405,13 @@ func Convert_v1alpha8_OpenStackClusterSpec_To_v1alpha7_OpenStackClusterSpec(in *
396405
out.ExternalNetworkID = in.ExternalNetwork.ID
397406
}
398407

408+
if in.Subnets != nil {
409+
if len(in.Subnets) >= 1 {
410+
if err := Convert_v1alpha8_SubnetFilter_To_v1alpha7_SubnetFilter(&in.Subnets[0], &out.Subnet, s); err != nil {
411+
return err
412+
}
413+
}
414+
}
415+
399416
return nil
400417
}

api/v1alpha7/zz_generated.conversion.go

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

api/v1alpha8/openstackcluster_types.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ type OpenStackClusterSpec struct {
4747
// If NodeCIDR cannot be set this can be used to detect an existing network.
4848
Network NetworkFilter `json:"network,omitempty"`
4949

50-
// If NodeCIDR cannot be set this can be used to detect an existing subnet.
51-
Subnet SubnetFilter `json:"subnet,omitempty"`
50+
// If NodeCIDR cannot be set this can be used to detect existing IPv4 and/or IPv6 subnets.
51+
// +kubebuilder:validation:MaxItems=2
52+
Subnets []SubnetFilter `json:"subnets,omitempty"`
5253

5354
// NetworkMTU sets the maximum transmission unit (MTU) value to address fragmentation for the private network ID.
5455
// This value will be used only if the Cluster actuator creates the network.

api/v1alpha8/zz_generated.deepcopy.go

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

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

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5507,37 +5507,40 @@ spec:
55075507
tagsAny:
55085508
type: string
55095509
type: object
5510-
subnet:
5510+
subnets:
55115511
description: If NodeCIDR cannot be set this can be used to detect
5512-
an existing subnet.
5513-
properties:
5514-
cidr:
5515-
type: string
5516-
description:
5517-
type: string
5518-
gateway_ip:
5519-
type: string
5520-
id:
5521-
type: string
5522-
ipVersion:
5523-
type: integer
5524-
ipv6AddressMode:
5525-
type: string
5526-
ipv6RaMode:
5527-
type: string
5528-
name:
5529-
type: string
5530-
notTags:
5531-
type: string
5532-
notTagsAny:
5533-
type: string
5534-
projectId:
5535-
type: string
5536-
tags:
5537-
type: string
5538-
tagsAny:
5539-
type: string
5540-
type: object
5512+
existing IPv4 and/or IPv6 subnets.
5513+
items:
5514+
properties:
5515+
cidr:
5516+
type: string
5517+
description:
5518+
type: string
5519+
gateway_ip:
5520+
type: string
5521+
id:
5522+
type: string
5523+
ipVersion:
5524+
type: integer
5525+
ipv6AddressMode:
5526+
type: string
5527+
ipv6RaMode:
5528+
type: string
5529+
name:
5530+
type: string
5531+
notTags:
5532+
type: string
5533+
notTagsAny:
5534+
type: string
5535+
projectId:
5536+
type: string
5537+
tags:
5538+
type: string
5539+
tagsAny:
5540+
type: string
5541+
type: object
5542+
maxItems: 2
5543+
type: array
55415544
tags:
55425545
description: Tags for all resources in cluster
55435546
items:

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

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2942,37 +2942,40 @@ spec:
29422942
tagsAny:
29432943
type: string
29442944
type: object
2945-
subnet:
2945+
subnets:
29462946
description: If NodeCIDR cannot be set this can be used to
2947-
detect an existing subnet.
2948-
properties:
2949-
cidr:
2950-
type: string
2951-
description:
2952-
type: string
2953-
gateway_ip:
2954-
type: string
2955-
id:
2956-
type: string
2957-
ipVersion:
2958-
type: integer
2959-
ipv6AddressMode:
2960-
type: string
2961-
ipv6RaMode:
2962-
type: string
2963-
name:
2964-
type: string
2965-
notTags:
2966-
type: string
2967-
notTagsAny:
2968-
type: string
2969-
projectId:
2970-
type: string
2971-
tags:
2972-
type: string
2973-
tagsAny:
2974-
type: string
2975-
type: object
2947+
detect existing IPv4 and/or IPv6 subnets.
2948+
items:
2949+
properties:
2950+
cidr:
2951+
type: string
2952+
description:
2953+
type: string
2954+
gateway_ip:
2955+
type: string
2956+
id:
2957+
type: string
2958+
ipVersion:
2959+
type: integer
2960+
ipv6AddressMode:
2961+
type: string
2962+
ipv6RaMode:
2963+
type: string
2964+
name:
2965+
type: string
2966+
notTags:
2967+
type: string
2968+
notTagsAny:
2969+
type: string
2970+
projectId:
2971+
type: string
2972+
tags:
2973+
type: string
2974+
tagsAny:
2975+
type: string
2976+
type: object
2977+
maxItems: 2
2978+
type: array
29762979
tags:
29772980
description: Tags for all resources in cluster
29782981
items:

0 commit comments

Comments
 (0)