Skip to content

Commit

Permalink
Support BYO dual-stack Network
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
MaysaMacedo and EmilienM committed Jan 18, 2024
1 parent 4182e2d commit ebe8b00
Show file tree
Hide file tree
Showing 16 changed files with 409 additions and 98 deletions.
17 changes: 17 additions & 0 deletions api/v1alpha5/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@ func Convert_v1alpha8_OpenStackClusterSpec_To_v1alpha5_OpenStackClusterSpec(in *
out.ExternalNetworkID = in.ExternalNetwork.ID
}

if in.Subnets != nil {
if len(in.Subnets) >= 1 {
if err := Convert_v1alpha8_SubnetFilter_To_v1alpha5_SubnetFilter(&in.Subnets[0], &out.Subnet, s); err != nil {
return err
}
}
}

return nil
}

Expand All @@ -211,6 +219,15 @@ func Convert_v1alpha5_OpenStackClusterSpec_To_v1alpha8_OpenStackClusterSpec(in *
}
}

emptySubnet := SubnetFilter{}
if in.Subnet != emptySubnet {
subnet := infrav1.SubnetFilter{}
if err := Convert_v1alpha5_SubnetFilter_To_v1alpha8_SubnetFilter(&in.Subnet, &subnet, s); err != nil {
return err
}
out.Subnets = []infrav1.SubnetFilter{subnet}
}

return nil
}

Expand Down
4 changes: 2 additions & 2 deletions api/v1alpha5/conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestConvertFrom(t *testing.T) {
Spec: OpenStackClusterSpec{},
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
"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}}",
"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}}",
},
},
},
Expand All @@ -64,7 +64,7 @@ func TestConvertFrom(t *testing.T) {
Spec: OpenStackClusterTemplateSpec{},
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
"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\":{}}}}}",
"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\":{}}}}}",
},
},
},
Expand Down
8 changes: 2 additions & 6 deletions api/v1alpha5/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions api/v1alpha6/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,14 @@ func Convert_v1alpha8_OpenStackClusterSpec_To_v1alpha6_OpenStackClusterSpec(in *
out.ExternalNetworkID = in.ExternalNetwork.ID
}

if in.Subnets != nil {
if len(in.Subnets) >= 1 {
if err := Convert_v1alpha8_SubnetFilter_To_v1alpha6_SubnetFilter(&in.Subnets[0], &out.Subnet, s); err != nil {
return err
}
}
}

return nil
}

Expand All @@ -501,6 +509,15 @@ func Convert_v1alpha6_OpenStackClusterSpec_To_v1alpha8_OpenStackClusterSpec(in *
}
}

emptySubnet := SubnetFilter{}
if in.Subnet != emptySubnet {
subnet := infrav1.SubnetFilter{}
if err := Convert_v1alpha6_SubnetFilter_To_v1alpha8_SubnetFilter(&in.Subnet, &subnet, s); err != nil {
return err
}
out.Subnets = []infrav1.SubnetFilter{subnet}
}

return nil
}

Expand Down
8 changes: 2 additions & 6 deletions api/v1alpha6/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions api/v1alpha7/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,15 @@ func Convert_v1alpha7_OpenStackClusterSpec_To_v1alpha8_OpenStackClusterSpec(in *
}
}

emptySubnet := SubnetFilter{}
if in.Subnet != emptySubnet {
subnet := infrav1.SubnetFilter{}
if err := Convert_v1alpha7_SubnetFilter_To_v1alpha8_SubnetFilter(&in.Subnet, &subnet, s); err != nil {
return err
}
out.Subnets = []infrav1.SubnetFilter{subnet}
}

return nil
}

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

if in.Subnets != nil {
if len(in.Subnets) >= 1 {
if err := Convert_v1alpha8_SubnetFilter_To_v1alpha7_SubnetFilter(&in.Subnets[0], &out.Subnet, s); err != nil {
return err
}
}
}

return nil
}
8 changes: 2 additions & 6 deletions api/v1alpha7/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions api/v1alpha8/openstackcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ type OpenStackClusterSpec struct {
// If NodeCIDR cannot be set this can be used to detect an existing network.
Network NetworkFilter `json:"network,omitempty"`

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

// NetworkMTU sets the maximum transmission unit (MTU) value to address fragmentation for the private network ID.
// This value will be used only if the Cluster actuator creates the network.
Expand Down
6 changes: 5 additions & 1 deletion api/v1alpha8/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5507,37 +5507,40 @@ spec:
tagsAny:
type: string
type: object
subnet:
subnets:
description: If NodeCIDR cannot be set this can be used to detect
an existing subnet.
properties:
cidr:
type: string
description:
type: string
gateway_ip:
type: string
id:
type: string
ipVersion:
type: integer
ipv6AddressMode:
type: string
ipv6RaMode:
type: string
name:
type: string
notTags:
type: string
notTagsAny:
type: string
projectId:
type: string
tags:
type: string
tagsAny:
type: string
type: object
existing IPv4 and/or IPv6 subnets.
items:
properties:
cidr:
type: string
description:
type: string
gateway_ip:
type: string
id:
type: string
ipVersion:
type: integer
ipv6AddressMode:
type: string
ipv6RaMode:
type: string
name:
type: string
notTags:
type: string
notTagsAny:
type: string
projectId:
type: string
tags:
type: string
tagsAny:
type: string
type: object
maxItems: 2
type: array
tags:
description: Tags for all resources in cluster
items:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2942,37 +2942,40 @@ spec:
tagsAny:
type: string
type: object
subnet:
subnets:
description: If NodeCIDR cannot be set this can be used to
detect an existing subnet.
properties:
cidr:
type: string
description:
type: string
gateway_ip:
type: string
id:
type: string
ipVersion:
type: integer
ipv6AddressMode:
type: string
ipv6RaMode:
type: string
name:
type: string
notTags:
type: string
notTagsAny:
type: string
projectId:
type: string
tags:
type: string
tagsAny:
type: string
type: object
detect existing IPv4 and/or IPv6 subnets.
items:
properties:
cidr:
type: string
description:
type: string
gateway_ip:
type: string
id:
type: string
ipVersion:
type: integer
ipv6AddressMode:
type: string
ipv6RaMode:
type: string
name:
type: string
notTags:
type: string
notTagsAny:
type: string
projectId:
type: string
tags:
type: string
tagsAny:
type: string
type: object
maxItems: 2
type: array
tags:
description: Tags for all resources in cluster
items:
Expand Down
Loading

0 comments on commit ebe8b00

Please sign in to comment.