Skip to content

Commit 1cb26b4

Browse files
authored
Merge pull request #1370 from dhnikolas/use-existing-router
✨ Add RouterName for use existing router
2 parents 8b57e0a + e2541be commit 1cb26b4

15 files changed

+166
-44
lines changed

api/v1alpha3/conversion_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ func TestFuzzyConversion(t *testing.T) {
233233
v1alpha7Cluster.Spec.APIServerFixedIP = ""
234234
v1alpha7Cluster.Spec.AllowAllInClusterTraffic = false
235235
v1alpha7Cluster.Spec.DisableAPIServerFloatingIP = false
236+
v1alpha7Cluster.Spec.Router = nil
236237
v1alpha7Cluster.Spec.APIServerLoadBalancer.AllowedCIDRs = nil
237238
v1alpha7Cluster.Spec.APIServerLoadBalancer.Provider = ""
238239
if v1alpha7Cluster.Spec.Bastion != nil {

api/v1alpha3/zz_generated.conversion.go

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

api/v1alpha4/conversion_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ func TestFuzzyConversion(t *testing.T) {
338338
v1alpha7Cluster.Spec.APIServerLoadBalancer.Provider = ""
339339

340340
v1alpha7Cluster.Spec.ControlPlaneOmitAvailabilityZone = false
341+
v1alpha7Cluster.Spec.Router = nil
341342

342343
if v1alpha7Cluster.Spec.Bastion != nil {
343344
v1alpha7Cluster.Spec.Bastion.Instance.Image = ""
@@ -418,6 +419,8 @@ func TestFuzzyConversion(t *testing.T) {
418419

419420
v1alpha7ClusterTemplate.Spec.Template.Spec.ControlPlaneOmitAvailabilityZone = false
420421

422+
v1alpha7ClusterTemplate.Spec.Template.Spec.Router = nil
423+
421424
if v1alpha7ClusterTemplate.Spec.Template.Spec.Bastion != nil {
422425
v1alpha7ClusterTemplate.Spec.Template.Spec.Bastion.Instance.Image = ""
423426
}

api/v1alpha4/zz_generated.conversion.go

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

api/v1alpha5/zz_generated.conversion.go

Lines changed: 1 addition & 0 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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ func restorev1alpha6MachineSpec(previous *OpenStackMachineSpec, dst *OpenStackMa
9191
func restorev1alpha7ClusterSpec(previous *infrav1.OpenStackClusterSpec, dst *infrav1.OpenStackClusterSpec) {
9292
// APIServerLoadBalancer.Provider is new in v1alpha7
9393
dst.APIServerLoadBalancer.Provider = previous.APIServerLoadBalancer.Provider
94+
dst.Router = previous.Router
9495
}
9596

9697
var _ ctrlconversion.Convertible = &OpenStackCluster{}
@@ -257,3 +258,7 @@ func Convert_v1alpha7_APIServerLoadBalancer_To_v1alpha6_APIServerLoadBalancer(in
257258
// Provider have been added in v1alpha7 but have no equivalent in v1alpha6
258259
return autoConvert_v1alpha7_APIServerLoadBalancer_To_v1alpha6_APIServerLoadBalancer(in, out, s)
259260
}
261+
262+
func Convert_v1alpha7_OpenStackClusterSpec_To_v1alpha6_OpenStackClusterSpec(in *infrav1.OpenStackClusterSpec, out *OpenStackClusterSpec, s conversion.Scope) error {
263+
return autoConvert_v1alpha7_OpenStackClusterSpec_To_v1alpha6_OpenStackClusterSpec(in, out, s)
264+
}

api/v1alpha6/zz_generated.conversion.go

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

api/v1alpha7/filter_convert.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package v1alpha7
1818

1919
import (
20+
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers"
2021
"github.com/gophercloud/gophercloud/openstack/networking/v2/networks"
2122
"github.com/gophercloud/gophercloud/openstack/networking/v2/subnets"
2223
)
@@ -51,3 +52,16 @@ func (networkFilter NetworkFilter) ToListOpt() networks.ListOpts {
5152
NotTagsAny: networkFilter.NotTagsAny,
5253
}
5354
}
55+
56+
func (routerFilter RouterFilter) ToListOpt() routers.ListOpts {
57+
return routers.ListOpts{
58+
ID: routerFilter.ID,
59+
Name: routerFilter.Name,
60+
Description: routerFilter.Description,
61+
ProjectID: routerFilter.ProjectID,
62+
Tags: routerFilter.Tags,
63+
TagsAny: routerFilter.TagsAny,
64+
NotTags: routerFilter.NotTags,
65+
NotTagsAny: routerFilter.NotTagsAny,
66+
}
67+
}

api/v1alpha7/openstackcluster_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ type OpenStackClusterSpec struct {
3939
// If you leave this empty, no network will be created.
4040
NodeCIDR string `json:"nodeCidr,omitempty"`
4141

42+
// If NodeCIDR is set this option can be used to detect an existing router.
43+
// If specified, no new router will be created.
44+
// +optional
45+
Router *RouterFilter `json:"router,omitempty"`
46+
4247
// If NodeCIDR cannot be set this can be used to detect an existing network.
4348
Network NetworkFilter `json:"network,omitempty"`
4449

api/v1alpha7/types.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,17 @@ type SubnetFilter struct {
104104
NotTagsAny string `json:"notTagsAny,omitempty"`
105105
}
106106

107+
type RouterFilter struct {
108+
ID string `json:"id,omitempty"`
109+
Name string `json:"name,omitempty"`
110+
Description string `json:"description,omitempty"`
111+
ProjectID string `json:"projectId,omitempty"`
112+
Tags string `json:"tags,omitempty"`
113+
TagsAny string `json:"tagsAny,omitempty"`
114+
NotTags string `json:"notTags,omitempty"`
115+
NotTagsAny string `json:"notTagsAny,omitempty"`
116+
}
117+
107118
type PortOpts struct {
108119
// Network is a query for an openstack network that the port will be created or discovered on.
109120
// This will fail if the query returns more than one network.

api/v1alpha7/zz_generated.deepcopy.go

Lines changed: 20 additions & 0 deletions
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: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6792,6 +6792,27 @@ spec:
67926792
connected to this subnet. If you leave this empty, no network will
67936793
be created.
67946794
type: string
6795+
router:
6796+
description: If NodeCIDR is set this option can be used to detect
6797+
an existing router. If specified, no new router will be created.
6798+
properties:
6799+
description:
6800+
type: string
6801+
id:
6802+
type: string
6803+
name:
6804+
type: string
6805+
notTags:
6806+
type: string
6807+
notTagsAny:
6808+
type: string
6809+
projectId:
6810+
type: string
6811+
tags:
6812+
type: string
6813+
tagsAny:
6814+
type: string
6815+
type: object
67956816
subnet:
67966817
description: If NodeCIDR cannot be set this can be used to detect
67976818
an existing subnet.

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2914,6 +2914,28 @@ spec:
29142914
and a router connected to this subnet. If you leave this
29152915
empty, no network will be created.
29162916
type: string
2917+
router:
2918+
description: If NodeCIDR is set this option can be used to
2919+
detect an existing router. If specified, no new router will
2920+
be created.
2921+
properties:
2922+
description:
2923+
type: string
2924+
id:
2925+
type: string
2926+
name:
2927+
type: string
2928+
notTags:
2929+
type: string
2930+
notTagsAny:
2931+
type: string
2932+
projectId:
2933+
type: string
2934+
tags:
2935+
type: string
2936+
tagsAny:
2937+
type: string
2938+
type: object
29172939
subnet:
29182940
description: If NodeCIDR cannot be set this can be used to
29192941
detect an existing subnet.

docs/book/src/clusteropenstack/configuration.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
- [Optional Configuration](#optional-configuration)
2020
- [Log level](#log-level)
2121
- [External network](#external-network)
22+
- [Use existing router](#use-existing-router)
2223
- [API server floating IP](#api-server-floating-ip)
2324
- [Disabling the API server floating IP](#disabling-the-api-server-floating-ip)
2425
- [Restrict Access to the API server](#restrict-access-to-the-api-server)
@@ -178,6 +179,22 @@ openstack network list --external
178179

179180
Note: If your openstack cluster does not already have a public network, you should contact your cloud service provider. We will not review how to troubleshoot this here.
180181

182+
## Use existing router
183+
184+
You can use a pre-existing router instead of creating a new one. When deleting a cluster a pre-existing router will not be deleted.
185+
186+
```yaml
187+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha6
188+
kind: OpenStackCluster
189+
metadata:
190+
name: <cluster-name>
191+
namespace: <cluster-namespace>
192+
spec:
193+
...
194+
router:
195+
id: <Router id>
196+
```
197+
181198
## API server floating IP
182199
183200
Unless explicitly disabled, a floating IP is automatically created and associated with the load balancer

0 commit comments

Comments
 (0)