Skip to content

Commit f19a6cc

Browse files
committed
Move FloatingIP to Bastion spec
1 parent ca25160 commit f19a6cc

13 files changed

+126
-50
lines changed

api/v1alpha5/conversion.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,16 @@ func Convert_v1alpha5_PortOpts_To_v1alpha7_PortOpts(in *PortOpts, out *infrav1.P
238238
return nil
239239
}
240240

241+
func Convert_v1alpha5_OpenStackMachineSpec_To_v1alpha7_Bastion(in *OpenStackMachineSpec, out *infrav1.Bastion, _ conversion.Scope) error {
242+
out.FloatingIP = in.FloatingIP
243+
return nil
244+
}
245+
246+
func Convert_v1alpha7_Bastion_To_v1alpha5_OpenStackMachineSpec(in *infrav1.Bastion, out *OpenStackMachineSpec, _ conversion.Scope) error {
247+
out.FloatingIP = in.FloatingIP
248+
return nil
249+
}
250+
241251
func Convert_v1alpha5_Instance_To_v1alpha7_BastionStatus(in *Instance, out *infrav1.BastionStatus, _ conversion.Scope) error {
242252
// BastionStatus is the same as Instance with unused fields removed
243253
out.ID = in.ID
@@ -437,3 +447,12 @@ func Convert_v1alpha5_OpenStackClusterStatus_To_v1alpha7_OpenStackClusterStatus(
437447
func Convert_v1alpha7_OpenStackMachineSpec_To_v1alpha5_OpenStackMachineSpec(in *infrav1.OpenStackMachineSpec, out *OpenStackMachineSpec, s conversion.Scope) error {
438448
return autoConvert_v1alpha7_OpenStackMachineSpec_To_v1alpha5_OpenStackMachineSpec(in, out, s)
439449
}
450+
451+
func Convert_v1alpha7_Bastion_To_v1alpha5_Bastion(in *infrav1.Bastion, out *Bastion, s conversion.Scope) error {
452+
err := autoConvert_v1alpha7_Bastion_To_v1alpha5_Bastion(in, out, s)
453+
if err != nil {
454+
return err
455+
}
456+
in.FloatingIP = out.Instance.FloatingIP
457+
return nil
458+
}

api/v1alpha5/zz_generated.conversion.go

Lines changed: 17 additions & 12 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: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ func restorev1alpha6MachineSpec(previous *OpenStackMachineSpec, dst *OpenStackMa
4040
dst.Networks = previous.Networks
4141
dst.Ports = previous.Ports
4242
dst.SecurityGroups = previous.SecurityGroups
43+
44+
// FloatingIP is removed from v1alpha7 with no replacement, so can't be
45+
// losslessly converted. Restore the previously stored value on down-conversion.
46+
dst.FloatingIP = previous.FloatingIP
4347
}
4448

4549
func restorev1alpha6ClusterStatus(previous *OpenStackClusterStatus, dst *OpenStackClusterStatus) {
@@ -472,6 +476,16 @@ func Convert_v1alpha7_PortOpts_To_v1alpha6_PortOpts(in *infrav1.PortOpts, out *P
472476
return nil
473477
}
474478

479+
func Convert_v1alpha6_OpenStackMachineSpec_To_v1alpha7_Bastion(in *OpenStackMachineSpec, out *infrav1.Bastion, _ apiconversion.Scope) error {
480+
out.FloatingIP = in.FloatingIP
481+
return nil
482+
}
483+
484+
func Convert_v1alpha7_Bastion_To_v1alpha6_OpenStackMachineSpec(in *infrav1.Bastion, out *OpenStackMachineSpec, _ apiconversion.Scope) error {
485+
out.FloatingIP = in.FloatingIP
486+
return nil
487+
}
488+
475489
func Convert_v1alpha6_Instance_To_v1alpha7_BastionStatus(in *Instance, out *infrav1.BastionStatus, _ apiconversion.Scope) error {
476490
// BastionStatus is the same as Instance with unused fields removed
477491
out.ID = in.ID
@@ -659,3 +673,12 @@ func Convert_v1alpha6_OpenStackClusterStatus_To_v1alpha7_OpenStackClusterStatus(
659673
func Convert_v1alpha7_OpenStackMachineSpec_To_v1alpha6_OpenStackMachineSpec(in *infrav1.OpenStackMachineSpec, out *OpenStackMachineSpec, s apiconversion.Scope) error {
660674
return autoConvert_v1alpha7_OpenStackMachineSpec_To_v1alpha6_OpenStackMachineSpec(in, out, s)
661675
}
676+
677+
func Convert_v1alpha7_Bastion_To_v1alpha6_Bastion(in *infrav1.Bastion, out *Bastion, s apiconversion.Scope) error {
678+
err := autoConvert_v1alpha7_Bastion_To_v1alpha6_Bastion(in, out, s)
679+
if err != nil {
680+
return err
681+
}
682+
in.FloatingIP = out.Instance.FloatingIP
683+
return nil
684+
}

api/v1alpha6/zz_generated.conversion.go

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

api/v1alpha7/openstackmachine_types.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,6 @@ type OpenStackMachineSpec struct {
6060
// If not specified a default port will be added for the default cluster network.
6161
Ports []PortOpts `json:"ports,omitempty"`
6262

63-
// The floatingIP which will be associated to the machine, only used for master.
64-
// The floatingIP should have been created and haven't been associated.
65-
FloatingIP string `json:"floatingIP,omitempty"`
66-
6763
// The names of the security groups to assign to the instance
6864
SecurityGroups []SecurityGroupFilter `json:"securityGroups,omitempty"`
6965

api/v1alpha7/types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,11 @@ type Bastion struct {
344344

345345
//+optional
346346
AvailabilityZone string `json:"availabilityZone,omitempty"`
347+
348+
// FloatingIP which will be associated to the bastion machine.
349+
// The floating IP should already exist and should not be associated with a port.
350+
//+optional
351+
FloatingIP string `json:"floatingIP,omitempty"`
347352
}
348353

349354
type APIServerLoadBalancer struct {

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3767,6 +3767,11 @@ spec:
37673767
type: string
37683768
enabled:
37693769
type: boolean
3770+
floatingIP:
3771+
description: FloatingIP which will be associated to the bastion
3772+
machine. The floating IP should already exist and should not
3773+
be associated with a port.
3774+
type: string
37703775
instance:
37713776
description: Instance for the bastion itself
37723777
properties:
@@ -3842,11 +3847,6 @@ spec:
38423847
description: The flavor reference for the flavor for your
38433848
server instance.
38443849
type: string
3845-
floatingIP:
3846-
description: The floatingIP which will be associated to the
3847-
machine, only used for master. The floatingIP should have
3848-
been created and haven't been associated.
3849-
type: string
38503850
identityRef:
38513851
description: IdentityRef is a reference to a identity to be
38523852
used when reconciling this cluster

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,6 +1607,11 @@ spec:
16071607
type: string
16081608
enabled:
16091609
type: boolean
1610+
floatingIP:
1611+
description: FloatingIP which will be associated to the
1612+
bastion machine. The floating IP should already exist
1613+
and should not be associated with a port.
1614+
type: string
16101615
instance:
16111616
description: Instance for the bastion itself
16121617
properties:
@@ -1688,11 +1693,6 @@ spec:
16881693
description: The flavor reference for the flavor for
16891694
your server instance.
16901695
type: string
1691-
floatingIP:
1692-
description: The floatingIP which will be associated
1693-
to the machine, only used for master. The floatingIP
1694-
should have been created and haven't been associated.
1695-
type: string
16961696
identityRef:
16971697
description: IdentityRef is a reference to a identity
16981698
to be used when reconciling this cluster

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,11 +1226,6 @@ spec:
12261226
flavor:
12271227
description: The flavor reference for the flavor for your server instance.
12281228
type: string
1229-
floatingIP:
1230-
description: The floatingIP which will be associated to the machine,
1231-
only used for master. The floatingIP should have been created and
1232-
haven't been associated.
1233-
type: string
12341229
identityRef:
12351230
description: IdentityRef is a reference to a identity to be used when
12361231
reconciling this cluster

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,11 +1030,6 @@ spec:
10301030
description: The flavor reference for the flavor for your
10311031
server instance.
10321032
type: string
1033-
floatingIP:
1034-
description: The floatingIP which will be associated to the
1035-
machine, only used for master. The floatingIP should have
1036-
been created and haven't been associated.
1037-
type: string
10381033
identityRef:
10391034
description: IdentityRef is a reference to a identity to be
10401035
used when reconciling this cluster

controllers/openstackcluster_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ func reconcileBastion(scope scope.Scope, cluster *clusterv1.Cluster, openStackCl
359359
return err
360360
}
361361
clusterName := fmt.Sprintf("%s-%s", cluster.Namespace, cluster.Name)
362-
fp, err := networkingService.GetOrCreateFloatingIP(openStackCluster, openStackCluster, clusterName, openStackCluster.Spec.Bastion.Instance.FloatingIP)
362+
fp, err := networkingService.GetOrCreateFloatingIP(openStackCluster, openStackCluster, clusterName, openStackCluster.Spec.Bastion.FloatingIP)
363363
if err != nil {
364364
handleUpdateOSCError(openStackCluster, fmt.Errorf("failed to get or create floating IP for bastion: %w", err))
365365
return fmt.Errorf("failed to get or create floating IP for bastion: %w", err)

docs/book/src/clusteropenstack/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ spec:
609609
...
610610
bastion:
611611
...
612-
floatingIP: <Floating IP address>
612+
floatingIP: <Floating IP address>
613613
```
614614

615615
If `managedSecurityGroups: true`, security group rule opening 22/tcp is added to security groups for bastion, controller, and worker nodes respectively. Otherwise, you have to add `securityGroups` to the `bastion` in `OpenStackCluster` spec and `OpenStackMachineTemplate` spec template respectively.

docs/book/src/topics/crd-changes/v1alpha6-to-v1alpha7.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- [`OpenStackMachine`](#openstackmachine)
99
- [⚠️ Removal of networks](#-removal-of-networks)
1010
- [Removal of subnet](#removal-of-subnet)
11+
- [Change to floatingIP](#change-to-floatingip)
1112
- [Change to securityGroups](#change-to-securitygroups)
1213
- [Changes to ports](#changes-to-ports)
1314
- [Change to securityGroupFilters](#change-to-securitygroupfilters)
@@ -121,6 +122,38 @@ to set the `accessIPv4` field on Nova servers. This feature was not widely
121122
used, difficult to use, and could not be extended to support IPv6. It is
122123
removed without replacement.
123124

125+
#### Change to floatingIP
126+
127+
The `OpenStackMachineSpec.FloatingIP` field has moved to `OpenStackClusterSpec.Bastion.FloatingIP`.
128+
For example, if you had the following `OpenStackMachineTemplate`:
129+
130+
```yaml
131+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha6
132+
kind: OpenStackMachineTemplate
133+
metadata:
134+
name: ${CLUSTER_NAME}-md-0
135+
spec:
136+
template:
137+
spec:
138+
..
139+
floatingIP: "1.2.3.4"
140+
```
141+
142+
This will safely converted to use `Bastion.FloatingIP` when upgrading to version 0.8.
143+
144+
To use the new `Bastion.FloatingIP` field, here is an example:
145+
146+
```yaml
147+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha7
148+
kind: OpenStackCluster
149+
metadata:
150+
name: ${CLUSTER_NAME}
151+
spec:
152+
..
153+
bastion:
154+
floatingIP: "1.2.3.4"
155+
```
156+
124157
#### Change to securityGroups
125158

126159
`securityGroups` has been simplified by the removal of a separate filter parameter. It was previously:

0 commit comments

Comments
 (0)