Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions api/v1alpha5/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,3 +504,21 @@ func Convert_v1alpha8_OpenStackMachineStatus_To_v1alpha5_OpenStackMachineStatus(
// ReferencedResources have no equivalent in v1alpha5
return autoConvert_v1alpha8_OpenStackMachineStatus_To_v1alpha5_OpenStackMachineStatus(in, out, s)
}

func Convert_v1alpha8_Bastion_To_v1alpha5_Bastion(in *infrav1.Bastion, out *Bastion, s conversion.Scope) error {
err := autoConvert_v1alpha8_Bastion_To_v1alpha5_Bastion(in, out, s)
if err != nil {
return err
}
in.FloatingIP = out.Instance.FloatingIP
return nil
}

func Convert_v1alpha5_Bastion_To_v1alpha8_Bastion(in *Bastion, out *infrav1.Bastion, s conversion.Scope) error {
err := autoConvert_v1alpha5_Bastion_To_v1alpha8_Bastion(in, out, s)
if err != nil {
return err
}
in.Instance.FloatingIP = out.FloatingIP
return nil
}
34 changes: 12 additions & 22 deletions api/v1alpha5/zz_generated.conversion.go

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

6 changes: 6 additions & 0 deletions api/v1alpha6/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ func restorev1alpha6MachineSpec(previous *OpenStackMachineSpec, dst *OpenStackMa
dst.Networks = previous.Networks
dst.Ports = previous.Ports
dst.SecurityGroups = previous.SecurityGroups

// FloatingIP is removed from v1alpha7 with no replacement, so can't be
// losslessly converted. Restore the previously stored value on down-conversion.
dst.FloatingIP = previous.FloatingIP
}

func restorev1alpha6ClusterStatus(previous *OpenStackClusterStatus, dst *OpenStackClusterStatus) {
Expand Down Expand Up @@ -759,6 +763,7 @@ func Convert_v1alpha6_Bastion_To_v1alpha8_Bastion(in *Bastion, out *infrav1.Bast
out.Instance.ServerGroup = nil
}

out.FloatingIP = in.Instance.FloatingIP
return nil
}

Expand All @@ -772,5 +777,6 @@ func Convert_v1alpha8_Bastion_To_v1alpha6_Bastion(in *infrav1.Bastion, out *Bast
out.Instance.ServerGroupID = in.Instance.ServerGroup.ID
}

out.Instance.FloatingIP = in.FloatingIP
return nil
}
4 changes: 2 additions & 2 deletions api/v1alpha6/zz_generated.conversion.go

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

28 changes: 26 additions & 2 deletions api/v1alpha7/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ var v1alpha8OpenStackClusterRestorer = conversion.RestorerFor[*infrav1.OpenStack
),
}

func restorev1alpha7MachineSpec(previous *OpenStackMachineSpec, dst *OpenStackMachineSpec) {
dst.FloatingIP = previous.FloatingIP
}

func restorev1alpha8MachineSpec(previous *infrav1.OpenStackMachineSpec, dst *infrav1.OpenStackMachineSpec) {
dst.ServerGroup = previous.ServerGroup
dst.Image = previous.Image
Expand Down Expand Up @@ -169,7 +173,14 @@ func (r *OpenStackClusterTemplate) ConvertFrom(srcRaw ctrlconversion.Hub) error

var _ ctrlconversion.Convertible = &OpenStackMachine{}

var v1alpha7OpenStackMachineRestorer = conversion.RestorerFor[*OpenStackMachine]{}
var v1alpha7OpenStackMachineRestorer = conversion.RestorerFor[*OpenStackMachine]{
"spec": conversion.HashedFieldRestorer(
func(c *OpenStackMachine) *OpenStackMachineSpec {
return &c.Spec
},
restorev1alpha7MachineSpec,
),
}

var v1alpha8OpenStackMachineRestorer = conversion.RestorerFor[*infrav1.OpenStackMachine]{
"spec": conversion.HashedFieldRestorer(
Expand Down Expand Up @@ -221,7 +232,18 @@ func (r *OpenStackMachineList) ConvertFrom(srcRaw ctrlconversion.Hub) error {

var _ ctrlconversion.Convertible = &OpenStackMachineTemplate{}

var v1alpha7OpenStackMachineTemplateRestorer = conversion.RestorerFor[*OpenStackMachineTemplate]{}
func restorev1alpha7MachineTemplateSpec(previous *OpenStackMachineTemplateSpec, dst *OpenStackMachineTemplateSpec) {
restorev1alpha7MachineSpec(&previous.Template.Spec, &dst.Template.Spec)
}

var v1alpha7OpenStackMachineTemplateRestorer = conversion.RestorerFor[*OpenStackMachineTemplate]{
"spec": conversion.HashedFieldRestorer(
func(c *OpenStackMachineTemplate) *OpenStackMachineTemplateSpec {
return &c.Spec
},
restorev1alpha7MachineTemplateSpec,
),
}

var v1alpha8OpenStackMachineTemplateRestorer = conversion.RestorerFor[*infrav1.OpenStackMachineTemplate]{
"spec": conversion.HashedFieldRestorer(
Expand Down Expand Up @@ -331,6 +353,7 @@ func Convert_v1alpha7_Bastion_To_v1alpha8_Bastion(in *Bastion, out *infrav1.Bast
out.Instance.ServerGroup = nil
}

out.FloatingIP = in.Instance.FloatingIP
return nil
}

Expand All @@ -344,6 +367,7 @@ func Convert_v1alpha8_Bastion_To_v1alpha7_Bastion(in *infrav1.Bastion, out *Bast
out.Instance.ServerGroupID = in.Instance.ServerGroup.ID
}

out.Instance.FloatingIP = in.FloatingIP
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions api/v1alpha7/zz_generated.conversion.go

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

4 changes: 0 additions & 4 deletions api/v1alpha8/openstackmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ type OpenStackMachineSpec struct {
// If not specified a default port will be added for the default cluster network.
Ports []PortOpts `json:"ports,omitempty"`

// The floatingIP which will be associated to the machine, only used for master.
// The floatingIP should have been created and haven't been associated.
FloatingIP string `json:"floatingIP,omitempty"`

// The names of the security groups to assign to the instance
SecurityGroups []SecurityGroupFilter `json:"securityGroups,omitempty"`

Expand Down
5 changes: 5 additions & 0 deletions api/v1alpha8/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,11 @@ type Bastion struct {

//+optional
AvailabilityZone string `json:"availabilityZone,omitempty"`

// FloatingIP which will be associated to the bastion machine.
// The floating IP should already exist and should not be associated with a port.
//+optional
FloatingIP string `json:"floatingIP,omitempty"`
}

type APIServerLoadBalancer struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4906,6 +4906,11 @@ spec:
type: string
enabled:
type: boolean
floatingIP:
description: |-
FloatingIP which will be associated to the bastion machine.
The floating IP should already exist and should not be associated with a port.
type: string
instance:
description: Instance for the bastion itself
properties:
Expand Down Expand Up @@ -4981,11 +4986,6 @@ spec:
description: The flavor reference for the flavor for your
server instance.
type: string
floatingIP:
description: |-
The floatingIP which will be associated to the machine, only used for master.
The floatingIP should have been created and haven't been associated.
type: string
identityRef:
description: IdentityRef is a reference to a identity to be
used when reconciling this cluster
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2331,6 +2331,11 @@ spec:
type: string
enabled:
type: boolean
floatingIP:
description: |-
FloatingIP which will be associated to the bastion machine.
The floating IP should already exist and should not be associated with a port.
type: string
instance:
description: Instance for the bastion itself
properties:
Expand Down Expand Up @@ -2407,11 +2412,6 @@ spec:
description: The flavor reference for the flavor for
your server instance.
type: string
floatingIP:
description: |-
The floatingIP which will be associated to the machine, only used for master.
The floatingIP should have been created and haven't been associated.
type: string
identityRef:
description: IdentityRef is a reference to a identity
to be used when reconciling this cluster
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1780,11 +1780,6 @@ spec:
flavor:
description: The flavor reference for the flavor for your server instance.
type: string
floatingIP:
description: |-
The floatingIP which will be associated to the machine, only used for master.
The floatingIP should have been created and haven't been associated.
type: string
identityRef:
description: IdentityRef is a reference to a identity to be used when
reconciling this cluster
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1455,11 +1455,6 @@ spec:
description: The flavor reference for the flavor for your
server instance.
type: string
floatingIP:
description: |-
The floatingIP which will be associated to the machine, only used for master.
The floatingIP should have been created and haven't been associated.
type: string
identityRef:
description: IdentityRef is a reference to a identity to be
used when reconciling this cluster
Expand Down
2 changes: 1 addition & 1 deletion controllers/openstackcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ func reconcileBastion(scope scope.Scope, cluster *clusterv1.Cluster, openStackCl
}

clusterName := fmt.Sprintf("%s-%s", cluster.Namespace, cluster.Name)
floatingIP := openStackCluster.Spec.Bastion.Instance.FloatingIP
floatingIP := openStackCluster.Spec.Bastion.FloatingIP
if openStackCluster.Status.Bastion.FloatingIP != "" {
// Some floating IP has already been created for this bastion, make sure we re-use it
floatingIP = openStackCluster.Status.Bastion.FloatingIP
Expand Down
2 changes: 1 addition & 1 deletion docs/book/src/clusteropenstack/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ spec:
...
bastion:
...
floatingIP: <Floating IP address>
floatingIP: <Floating IP address>
```

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.
Expand Down
Loading